Last active
July 27, 2020 18:23
-
-
Save jfblaine/0e778d48ff128eb0e8c87e644cff6c44 to your computer and use it in GitHub Desktop.
Envoy sidecar example to do url rewrite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # to test: | |
| # curl http://envoy-test.apps.86cc.example.opentlc.com/config-server | |
| # apache output: | |
| # 127.0.0.1 - - [27/Feb/2020:01:33:48 +0000] "GET / HTTP/1.1" 403 3985 "-" "curl/7.29.0" | |
| # | |
| # curl http://envoy-test.apps.86cc.example.opentlc.com/config-server/foo | |
| # 127.0.0.1 - - [27/Feb/2020:01:35:58 +0000] "GET /foo HTTP/1.1" 404 196 "-" "curl/7.29.0" | |
| # | |
| # curl http://envoy-test.apps.86cc.example.opentlc.com/config-server/foo/bar | |
| # 127.0.0.1 - - [27/Feb/2020:01:36:35 +0000] "GET /foo/bar HTTP/1.1" 404 196 "-" "curl/7.29.0" | |
| # | |
| # curl envoy-test.apps.86cc.example.opentlc.com/config-server/foo/bar/this/is/a/test?id=23566 | |
| # 127.0.0.1 - - [27/Feb/2020:09:04:03 +0000] "GET /foo/bar/this/is/a/test?id=23566 HTTP/1.1" 404 196 "-" "curl/7.29.0" | |
| # | |
| # Template contents below. To run "oc process -f filename.yaml | oc create -f -" | |
| # If parameter override is needed, do the following: | |
| # "oc process -f envoy-test.yaml NAMESPACE=foo WILDCARD_DNS=apps.example.com | oc create -f -" | |
| # | |
| # | |
| apiVersion: v1 | |
| kind: Template | |
| labels: | |
| template: "envoy-test-template" | |
| metadata: | |
| name: envoy-test-template | |
| annotations: | |
| description: "Demo of envoy url rewriting" | |
| tags: "envoy" | |
| objects: | |
| - apiVersion: v1 | |
| data: | |
| envoy.yaml: | | |
| static_resources: | |
| listeners: | |
| - address: | |
| socket_address: | |
| address: 0.0.0.0 | |
| port_value: 8081 | |
| filter_chains: | |
| - filters: | |
| - name: envoy.http_connection_manager | |
| config: | |
| stat_prefix: ingress_http | |
| route_config: | |
| name: local_route | |
| virtual_hosts: | |
| - name: local_service | |
| domains: ["*"] | |
| routes: | |
| - match: { prefix: "/config-server/" } | |
| route: { prefix_rewrite: "/", cluster: local_service } | |
| - match: { prefix: "/config-server" } | |
| route: { prefix_rewrite: "/", cluster: local_service } | |
| - match: { prefix: "/" } | |
| route: { prefix_rewrite: "/", cluster: local_service } | |
| http_filters: | |
| - name: envoy.router | |
| http_filters: | |
| - name: envoy.router | |
| typed_config: {} | |
| clusters: | |
| - name: local_service | |
| type: STRICT_DNS | |
| connect_timeout: 1s | |
| hosts: | |
| - socket_address: | |
| address: 127.0.0.1 | |
| port_value: 8080 | |
| admin: | |
| access_log_path: "/dev/null" | |
| address: | |
| socket_address: | |
| address: 0.0.0.0 | |
| port_value: 8085 | |
| kind: ConfigMap | |
| metadata: | |
| name: envoy-config | |
| namespace: "${NAMESPACE}" | |
| labels: | |
| app: envoy-test | |
| - apiVersion: extensions/v1beta1 | |
| kind: Deployment | |
| metadata: | |
| annotations: | |
| deployment.kubernetes.io/revision: "1" | |
| labels: | |
| app: envoy-test | |
| name: envoy-test | |
| namespace: "${NAMESPACE}" | |
| spec: | |
| progressDeadlineSeconds: 600 | |
| replicas: 1 | |
| revisionHistoryLimit: 0 | |
| selector: | |
| matchLabels: | |
| app: envoy-test | |
| strategy: | |
| rollingUpdate: | |
| maxSurge: 25% | |
| maxUnavailable: 25% | |
| type: RollingUpdate | |
| template: | |
| metadata: | |
| labels: | |
| app: envoy-test | |
| spec: | |
| containers: | |
| - image: docker-registry.default.svc:5000/openshift/httpd | |
| imagePullPolicy: IfNotPresent | |
| name: httpd | |
| resources: | |
| limits: | |
| cpu: 200m | |
| memory: 200Mi | |
| requests: | |
| cpu: 100m | |
| memory: 100Mi | |
| terminationMessagePath: /dev/termination-log | |
| terminationMessagePolicy: File | |
| - image: envoyproxy/envoy-dev:d4533b6da770e1a1a90a7dd766a83d3f37d5d1d6 | |
| imagePullPolicy: IfNotPresent | |
| name: envoy | |
| ports: | |
| - containerPort: 8081 | |
| name: http | |
| protocol: TCP | |
| - containerPort: 8085 | |
| name: http-admin | |
| protocol: TCP | |
| resources: | |
| limits: | |
| cpu: 200m | |
| memory: 200Mi | |
| requests: | |
| cpu: 100m | |
| memory: 100Mi | |
| terminationMessagePath: /dev/termination-log | |
| terminationMessagePolicy: File | |
| volumeMounts: | |
| - mountPath: /etc/envoy | |
| name: envoy-config | |
| dnsPolicy: ClusterFirst | |
| restartPolicy: Always | |
| schedulerName: default-scheduler | |
| securityContext: {} | |
| terminationGracePeriodSeconds: 30 | |
| volumes: | |
| - configMap: | |
| defaultMode: 420 | |
| name: envoy-config | |
| name: envoy-config | |
| - apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| labels: | |
| app: envoy-test | |
| name: envoy-test | |
| namespace: "${NAMESPACE}" | |
| spec: | |
| ports: | |
| - name: 8081-tcp | |
| port: 8081 | |
| protocol: TCP | |
| targetPort: 8081 | |
| - name: 8085-tcp | |
| port: 8085 | |
| protocol: TCP | |
| targetPort: 8085 | |
| selector: | |
| app: envoy-test | |
| sessionAffinity: None | |
| type: ClusterIP | |
| - apiVersion: route.openshift.io/v1 | |
| kind: Route | |
| metadata: | |
| labels: | |
| app: envoy-test | |
| name: envoy-admin | |
| namespace: "${NAMESPACE}" | |
| spec: | |
| host: envoy-admin.${WILDCARD_DNS} | |
| port: | |
| targetPort: 8085 | |
| to: | |
| kind: Service | |
| name: envoy-test | |
| weight: 100 | |
| wildcardPolicy: None | |
| - apiVersion: route.openshift.io/v1 | |
| kind: Route | |
| metadata: | |
| labels: | |
| app: envoy-test | |
| name: envoy-test | |
| namespace: "${NAMESPACE}" | |
| spec: | |
| host: envoy-test.${WILDCARD_DNS} | |
| path: /config-server | |
| port: | |
| targetPort: 8081 | |
| to: | |
| kind: Service | |
| name: envoy-test | |
| weight: 100 | |
| wildcardPolicy: None | |
| parameters: | |
| - name: WILDCARD_DNS | |
| displayName: Wildcard DNS | |
| description: The wildcard dns entry for routes on this cluster | |
| required: true | |
| - name: NAMESPACE | |
| displayName: Target Namespace | |
| description: The target namespace for object creation | |
| required: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment