KOP Recipes - AWS Load Balancer Controller Access - Rafay Product Documentation

Access

In this part, you will


Step 1: Create Namespace

Let us create a namespace where we will deploy our YAML workload.


Step 2: Create Workload YAML

We are using a game-2048 deployment in this example to create an Ingress resource which will provision an ALB.

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-2048
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: app-2048
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app-2048
    spec:
      containers:
      - image: alexwhen/docker-2048
        imagePullPolicy: Always
        name: app-2048
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: service-2048
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    app.kubernetes.io/name: app-2048
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-2048
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-west-2:####:certificate/####
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/healthcheck-path: /
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
spec:
  rules:
    - host: alb.example.com
      http:
        paths:
          - path: /*
            backend:
             serviceName: ssl-redirect
             servicePort: use-annotation
          - path: /*
            backend:
              serviceName: service-2048
              servicePort: 80

Step 3: Create Workload

In this step, we will create a workload based on the YAML from the previous step and publish it to our cluster.


Step 4: Verify Workload

kubectl get ingresses -n game-2048

NAME           CLASS    HOSTS                        ADDRESS                                                                  PORTS   AGE
ingress-2048   <none>   alb.yog.dev.rafay-edge.net   k8s-game2048-ingress2-bcac0b5b37-768944746.us-west-2.elb.amazonaws.com   80      47s

Recap

Congratulations!

You have successfully created a custom cluster blueprint with the "aws-load-balancer-controller" addon and applied it to a cluster. You can now use this blueprint on as many clusters as you require.