Creating a Kubernetes Ingress resource for GCP/GKE by example

9/1/2021

I'm trying to make sense of an example Kubernetes YAML config file that I am trying to customize:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-web-server
  namespace: myapp
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/security-groups: my-sec-group
    app.kubernetes.io/name: my-alb-ingress-web-server
    app.kubernetes.io/component: my-alb-ingress
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: my-web-server
              servicePort: 8080

The documentation for this example claims its for creating an "Ingress", or a K8s object that manages inbound traffic to a service or pod.

This particular Ingress resource appears to use AWS ALB (Application Load Balancers) and I need to adapt it to create and Ingress resource in GCP/GKE.

I'm Googling the Kubernetes documentation high and low and although I found the kubernetes.io/ingress.class docs I don't see where they define "alb" as a valid value for this property. I'm asking because I obviously need to find the correct kubernetes.io/ingress.class value for GCP/GKE and I assume if I can find the K8s/AWS Ingress documentation I should be able to find the K8s/GCP Ingress documentation.

I'm assuming K8s has AWS, GCP, Azure, etc. built-in client to kubectl for connecting to these clouds/providers?

So I ask: how does the above configuration tell K8s that we are creating an AWS Ingress (as opposed to an Azure Ingress, GCP Ingress, etc.) and where is the documentation for this?

-- simplezarg
amazon-web-services
kubectl
kubernetes
kustomize

1 Answer

9/3/2021

The documentation you're looking for is : https://cloud.google.com/kubernetes-engine/docs/concepts/ingress https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-multi-ssl

An example of an ingress resource :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: 
       name: ingress-front-api
       namespace: example
       annotations:
             networking.gke.io/managed-certificates: "front.example.com, api.example.com"
             kubernetes.io/ingress.global-static-ip-name: "prod-ingress-static-ip"
spec:
  rules:
  - host: front.example.com
    http:
          paths:
          - backend:
                service:
                      name: front
                      port:
                            number: 80
          path: /*
          pathType: ImplementationSpecific
 - host: api.example.com
    http:
          paths:
          - backend:
                service:
                      name: api
                      port:
                            number: 80
          path: /*
          pathType: ImplementationSpecific
-- Idka
Source: StackOverflow