envoyproxy / gateway

Manages Envoy Proxy as a Standalone or Kubernetes-based Application Gateway
https://gateway.envoyproxy.io
Apache License 2.0
1.55k stars 333 forks source link

How to configure a static IP for gateway in GKE to avoid dynamic IP issues? #4335

Closed SergeiCherevko closed 2 days ago

SergeiCherevko commented 2 days ago

Hello, I have a Gateway configuration that I use in a GKE cluster.

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: eg
  namespace: xxx
spec:
  gatewayClassName: eg
  infrastructure:
    parametersRef:
      group: gateway.envoyproxy.io
      kind: EnvoyProxy
      name: envoy-custom-config
  listeners:
    - name: https
      protocol: HTTPS
      hostname: xxx.example.com
      port: 443
      tls:
        mode: Terminate
        certificateRefs:
          - kind: Secret
            name: xxx-example-com
            namespace: xxx
    - name: http
      protocol: HTTP
      port: 80

It works well, but I receive a dynamic IP. After that, I need to manually update the DNS with this IP, which is very inconvenient.

If the IP resets, it can cause a lot of problems with ingress and infrastructure, because in the next deployment, I will receive a new address for the gateway. Therefore, I need to first create a static IP address using Terraform, connect this address with DNS, and then specify the name of this IP address in the gateway configuration.

I couldn't find any relevant documentation for this.

I tried to create static ip in GCP

image

and use in gateway spec

spec:
  addresses:
    - type: IPAddress
      value: xxx.xxx.xxx.190

Then i check

kubectl get gateway

NAME   CLASS            ADDRESS         PROGRAMMED   AGE
eg       eg       xxx.xxx.xxx.190       True         3m

but as you see on screenshot from GCP, i don't have forwarding rule which must create by k8s because i use it in gateway resource. Instead of that i have "NONE" with yellow triangle

and why i can't use named ip address with envoy gateway?

  addresses:
  - type: NamedAddress
    value: IP_ADDRESS

When i put same ip in nginx ingress controller i see forwarding rule

SergeiCherevko commented 2 days ago

I think i found solution, you need override config envoyproxy by adding in spec 'envoyService'

But of course better put name of ip address not address itself, but its not working as i understood

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  name: envoy-custom-config
  namespace: journal
spec:
  provider:
    type: Kubernetes
    kubernetes:
      envoyDeployment:
        replicas: 15
        container:
          resources:
            requests:
              cpu: 1
              memory: 1024Mi
            limits:
              cpu: 2
              memory: 2048Mi
      envoyService:
        loadBalancerIP: xxx.xxx.xxx.190