0

I want to use envoy as my kubernetes deployment service proxy, and my application uses grpc to communicate with client-side.

My steps:

  1. Write a yaml file for envoy configuration.

Envoy configuration:

admin:
  access_log_path: /tmp/admin_access.log
  address:
    socket_address: { address: 0.0.0.0, port_value: 9901 }

static_resources:
  listeners:
    - name: http_listener
      address:
        socket_address: { address: 0.0.0.0, port_value: 8080 }
      filter_chains:
      - filters:
        - name: envoy.filters.network.http_connection_manager
          typed_config:
            "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
            codec_type: auto
            stat_prefix: ingress_http
            route_config:
              name: local_route
              virtual_hosts:
                - name: local_service
                  domains: [ "*" ]
                  routes:
                    - match:
                        { prefix: "/" }
                      route:
                        cluster: my_app_prod_service
                        timeout: 30s
                        max_grpc_timeout: 30s
                  cors:
                    allow_origin_string_match:
                      - safe_regex: { regex: ".*", google_re2: { } }
                    allow_methods: GET, PUT, DELETE, POST, OPTIONS
                    allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
                    max_age: "1728000"
                    expose_headers: custom-header-1,grpc-status,grpc-message
            http_filters:
              - name: envoy.filters.http.router
  clusters:
    - name: my_app_prod_service
      connect_timeout: 0.5s
      type: strict_dns
      http2_protocol_options: {}
      lb_policy: round_robin
      load_assignment:
        cluster_name: my_app_prod_service
        endpoints:
        - lb_endpoints:
          - endpoint:
              address:
                socket_address:
                  address: my-app-service-staging
                  port_value: 30015
  1. Deploy it as config map.
kubectl create configmap envoy-config-prod \
  --from-file=envoy_config_prod.yaml \
  -o yaml --dry-run=client | kubectl replace --force -f -
  1. Deploy envoy deployment and service, and mount the config map.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: envoy-server-prod
spec:
  replicas: 3
  selector:
    matchLabels:
      app: envoy-server-prod
  template:
    metadata:
      labels:
        app: envoy-server-prod
    spec:
      containers:
        - name: envoy-server-prod
          image: envoyproxy/envoy:v1.18.2
          args:
            - -c
            - /etc/envoy/envoy_config_prod.yaml
            - --log-path
            - /tmp/envoy_info.log
          ports:
          - name: http
            containerPort: 8080
          - name: envoy-admin
            containerPort: 9901
          resources:
            requests:
              cpu: 5
              memory: 5Gi
          volumeMounts:
            - mountPath: /etc/envoy
              name: envoy-config-prod
      volumes:
        - name: envoy-config-prod
          configMap:
            name: envoy-config-prod
---
kind: Service
apiVersion: v1
metadata:
  name: envoy-service-prod
  labels:
    app: envoy-service-prod
spec:
  selector:
    app: envoy-server-prod
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
  type: ClusterIP
  externalIPs:
    - 10.1.4.63
  1. Make a headless service and its deployment.
apiVersion: v1
kind: Service
metadata:
  name: my-app-service-staging
  labels:
    app: my-app-service-staging
spec:
  clusterIP: None
  ports:
    - name: grpc
      port: 30015
      targetPort: 30015
      protocol: TCP
  selector:
    app: my-app-deploy-staging
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-deploy-staging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app-deploy-staging
  template:
    metadata:
      labels:
        app: my-app-deploy-staging
    spec:
      containers:
      - name: my-app-deploy-staging
        image: $IMAGE_SHA
        resources:
          requests:
            memory: 2G
            cpu: 1

I checked that in the envoy deployment, /etc/envoy/envoy_config_prod.yaml and /tmp/envoy_info.log both exist, and I don't see error messages in it.

I tried to make http connections to envoy service, hoping it to transfer it to my application deployment.


> curl -v 10.1.4.63:8080
*   Trying 10.1.4.63:8080...
* TCP_NODELAY set
* connect to 10.1.4.63 port 8080 failed: Connection timed out
* Failed to connect to 10.1.4.63 port 8080: Connection timed out
* Closing connection 0
curl: (28) Failed to connect to 10.1.4.63 port 8080: Connection timed out

But it just time outs.

I tried to get the services and deployments.

> k get svc
my-app-service-staging       ClusterIP   None            <none>        30015/TCP   3h54m
envoy-service-prod           ClusterIP   10.43.157.121   10.1.4.63     8080/TCP    6h55m

> k get deploy
my-deploy-deploy-staging        1/1     1            1           29d

I'm wondering, how should debug this issue?

Tinyden
  • 524
  • 4
  • 13

1 Answers1

0

Envoy supports a wide range of timeouts that may need to be configured depending on the deployment. Configure timeouts summarize the most important timeouts used in various scenarios.

Refer to Debug Envoy Proxy.

Please go through this similar SO1 & SO2, which may help to resolve your issue.

Veera Nagireddy
  • 1,656
  • 1
  • 3
  • 12
  • Hi, I suspect my issue is a connection issue: I cannot curl to my deployment, rather than a timeout one. My reasoning is: the curl timeout after several minutes, rather than a few seconds, which is the timeout value I set. Do you think that make sense to you? – Tinyden Dec 30 '22 at 11:26