Setting up external gateway for gke


Enable certificate manager API

gcloud services enable certificatemanager.googleapis.com

Then create a certificate map

gcloud beta certificate-manager maps create store-example-com-map

Generate your certificate using 

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

Setup your certificate 

gcloud beta certificate-manager certificates create store-example-com-cert     --certificate-file="cert.pem" --private-key-file="key.pem"

Create map entries 

gcloud beta certificate-manager maps entries create store-example-com-map-entry --map=store-example-com-map --hostname=store.example.com --certificates=store-example-com-cert

You should be able to see the following in certificate manager



Next create the following gateway class


kind: Gateway
apiVersion: gateway.networking.k8s.io/v1beta1
metadata:
  name: external-http
  annotations:
    networking.gke.io/certmap: store-example-com-map
spec:
  gatewayClassName: gke-l7-global-external-managed
  listeners:
  - name: https
    protocol: HTTPS
    port: 443

Then you can see  a new load balancer is being created :- 




Deploy the corresponding applications:

kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/gke-networking-recipes/main/gateway/gke-gateway-controller/app/store.yaml

Create HTTP Route


kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1beta1
metadata:
  name: store-external
spec:
  parentRefs:
  - kind: Gateway
    name: external-http
  hostnames:
  - "store.example.com"
  rules:
  - backendRefs:
    - name: store-v1
      port: 8080
  - matches:
    - headers:
      - name: env
        value: canary
    backendRefs:
    - name: store-v2
      port: 8080
  - matches:
    - path:
        value: /de
    backendRefs:
    - name: store-german
      port: 8080

Sending traffic to your applications

curl https://store.example.com --resolve store.example.com:443:34.111.64.253 -k

curl -H "env: canary" https://store.example.com"/de --resolve store.example.com:443:34.111.64.253 -k







Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type