Skip to content

Commit

Permalink
docs: (envoyproxy#3137) retrofit remaining 'kubectl apply' yaml snipp…
Browse files Browse the repository at this point in the history
…ets using tabs

Signed-off-by: Eitan Suez <eitan@tetrate.io>
  • Loading branch information
Eitan Suez committed Apr 23, 2024
1 parent 1e25232 commit 2613c33
Show file tree
Hide file tree
Showing 31 changed files with 3,569 additions and 49 deletions.
111 changes: 110 additions & 1 deletion site/content/en/latest/tasks/extensibility/envoy-patch-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Before proceeding, you should be able to query the example backend using HTTP.
* The default installation of Envoy Gateway installs a default [EnvoyGateway][] configuration and attaches it
using a `ConfigMap`. In the next step, we will update this resource to enable EnvoyPatchPolicy.


{{< tabpane text=true >}}
{{% tab header="Apply from stdin" %}}
```shell
cat <<EOF | kubectl apply -f -
apiVersion: v1
Expand All @@ -52,6 +53,30 @@ data:
enableEnvoyPatchPolicy: true
EOF
```
{{% /tab %}}
{{% tab header="Apply from file" %}}
Save and apply the following resource to your cluster:

```yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: envoy-gateway-config
namespace: envoy-gateway-system
data:
envoy-gateway.yaml: |
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyGateway
provider:
type: Kubernetes
gateway:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
extensionApis:
enableEnvoyPatchPolicy: true
```
{{% /tab %}}
{{< /tabpane >}}
* After updating the `ConfigMap`, you will need to restart the `envoy-gateway` deployment so the configuration kicks in

Expand All @@ -68,6 +93,8 @@ the status code is `404`

* Apply the configuration

{{< tabpane text=true >}}
{{% tab header="Apply from stdin" %}}
```shell
cat <<EOF | kubectl apply -f -
apiVersion: gateway.envoyproxy.io/v1alpha1
Expand Down Expand Up @@ -103,10 +130,52 @@ spec:
inline_string: "could not find what you are looking for"
EOF
```
{{% /tab %}}
{{% tab header="Apply from file" %}}
Save and apply the following resource to your cluster:

```yaml
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyPatchPolicy
metadata:
name: custom-response-patch-policy
namespace: default
spec:
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
name: eg
namespace: default
type: JSONPatch
jsonPatches:
- type: "type.googleapis.com/envoy.config.listener.v3.Listener"
# The listener name is of the form <GatewayNamespace>/<GatewayName>/<GatewayListenerName>
name: default/eg/http
operation:
op: add
path: "/default_filter_chain/filters/0/typed_config/local_reply_config"
value:
mappers:
- filter:
status_code_filter:
comparison:
op: EQ
value:
default_value: 404
runtime_key: key_b
status_code: 406
body:
inline_string: "could not find what you are looking for"
```
{{% /tab %}}
{{< /tabpane >}}

When mergeGateways is enabled, there will be one Envoy deployment for all Gateways in the cluster.
Then the EnvoyPatchPolicy should target a specific GatewayClass.

{{< tabpane text=true >}}
{{% tab header="Apply from stdin" %}}
```shell
cat <<EOF | kubectl apply -f -
apiVersion: gateway.envoyproxy.io/v1alpha1
Expand Down Expand Up @@ -142,6 +211,46 @@ spec:
inline_string: "could not find what you are looking for"
EOF
```
{{% /tab %}}
{{% tab header="Apply from file" %}}
Save and apply the following resource to your cluster:

```yaml
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyPatchPolicy
metadata:
name: custom-response-patch-policy
namespace: default
spec:
targetRef:
group: gateway.networking.k8s.io
kind: GatewayClass
name: eg
namespace: default
type: JSONPatch
jsonPatches:
- type: "type.googleapis.com/envoy.config.listener.v3.Listener"
# The listener name is of the form <GatewayNamespace>/<GatewayName>/<GatewayListenerName>
name: default/eg/http
operation:
op: add
path: "/default_filter_chain/filters/0/typed_config/local_reply_config"
value:
mappers:
- filter:
status_code_filter:
comparison:
op: EQ
value:
default_value: 404
runtime_key: key_b
status_code: 406
body:
inline_string: "could not find what you are looking for"
```
{{% /tab %}}
{{< /tabpane >}}

* Edit the HTTPRoute resource from the Quickstart to only match on paths with value `/get`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ You can configure a collector that supports the OTLP protocol, which includes bu
Assuming the OpenTelemetry Collector is running in the `observability` namespace, and it has a service named `otel-svc`,
we only want to sample `50%` of the trace data. We would configure it as follows:

{{< tabpane text=true >}}
{{% tab header="Apply from stdin" %}}
```shell
cat <<EOF | kubectl apply -f -
apiVersion: v1
Expand Down Expand Up @@ -62,6 +64,38 @@ data:
url: otel-svc.observability.svc.cluster.local:4318
EOF
```
{{% /tab %}}
{{% tab header="Apply from file" %}}
Save and apply the following resource to your cluster:

```yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: envoy-gateway-config
namespace: envoy-gateway-system
data:
envoy-gateway.yaml: |
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyGateway
provider:
type: Kubernetes
gateway:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
rateLimit:
backend:
type: Redis
redis:
url: redis-service.default.svc.cluster.local:6379
telemetry:
tracing:
sampleRate: 50
provider:
url: otel-svc.observability.svc.cluster.local:4318
```
{{% /tab %}}
{{< /tabpane >}}
After updating the ConfigMap, you will need to restart the envoy-gateway deployment so the configuration kicks in:
Expand Down
Loading

0 comments on commit 2613c33

Please sign in to comment.