Iam trying to follow this guide https://aws.amazon.com/blogs/containers/using-alb-ingress-controller-with-amazon-eks-on-fargate/
Steps below:
Cluster provisioning AWS_REGION=us-east-1 CLUSTER_NAME=eks-fargate-alb-demo
eksctl create cluster --name $CLUSTER_NAME --region $AWS_REGION --fargate
kubectl get svc You should get the following response: NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.100.0.1 443/TCP 16h
Set up OIDC provider with the cluster and create the IAM policy used by the ALB Ingress Controller wget -O alb-ingress-iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/iam-policy.json aws iam create-policy --policy-name ALBIngressControllerIAMPolicy --policy-document file://alb-ingress-iam-policy.json
STACK_NAME=eksctl-$CLUSTER_NAME-cluster VPC_ID=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" | jq -r '[.Stacks[0].Outputs[] | {key: .OutputKey, value: .OutputValue}] | from_entries' | jq -r '.VPC') AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account')
cat > rbac-role.yaml <<-EOF
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: alb-ingress-controller name: alb-ingress-controller rules: - apiGroups: - "" - extensions resources: - configmaps - endpoints - events - ingresses - ingresses/status - services verbs: - create - get - list - update - watch - patch - apiGroups: - "" - extensions resources: - nodes - pods - secrets - services - namespaces verbs: - get - list
- watch
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: app.kubernetes.io/name: alb-ingress-controller name: alb-ingress-controller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: alb-ingress-controller subjects: - kind: ServiceAccount name: alb-ingress-controller namespace: kube-system EOF
kubectl apply -f rbac-role.yaml These commands will create two resources for us and the output should be similar to this:
clusterrole.rbac.authorization.k8s.io/alb-ingress-controller created clusterrolebinding.rbac.authorization.k8s.io/alb-ingress-controller created And finally the Kubernetes Service Account:
eksctl create iamserviceaccount \ --name alb-ingress-controller \ --namespace kube-system \ --cluster $CLUSTER_NAME \ --attach-policy-arn arn:aws:iam::$AWS_ACCOUNT_ID:policy/ALBIngressControllerIAMPolicy \ --approve This eksctl command will deploy a new CloudFormation stack with an IAM role. Wait for it to finish before keep executing the next steps.
Deploy the ALB Ingress Controller Let’s now deploy the ALB Ingress Controller to our cluster:
cat > alb-ingress-controller.yaml <<-EOF apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/name: alb-ingress-controller name: alb-ingress-controller namespace: kube-system spec: selector: matchLabels: app.kubernetes.io/name: alb-ingress-controller template: metadata: labels: app.kubernetes.io/name: alb-ingress-controller spec: containers: - name: alb-ingress-controller args: - --ingress-class=alb - --cluster-name=$CLUSTER_NAME - --aws-vpc-id=$VPC_ID - --aws-region=$AWS_REGION image: docker.io/amazon/aws-alb-ingress-controller:v1.1.4 serviceAccountName: alb-ingress-controller EOF kubectl apply -f alb-ingress-controller.yaml
Deploy sample application to the cluster Now that we have our ingress controller running, we can deploy the application to the cluster and create an ingress resource to expose it.
Let’s start with a deployment:
cat > nginx-deployment.yaml <<-EOF apiVersion: extensions/v1beta1 kind: Deployment metadata: name: "nginx-deployment" namespace: "default" spec: replicas: 3 template: metadata: labels: app: "nginx" spec: containers: - image: nginx:latest imagePullPolicy: Always name: "nginx" ports: - containerPort: 80 EOF
kubectl apply -f nginx-deployment.yaml The output should be similar to:
deployment.apps/alb-ingress-controller created Then, let’s create a service so we can expose the NGINX pods:
cat > nginx-service.yaml <<-EOF apiVersion: v1 kind: Service metadata: annotations: alb.ingress.kubernetes.io/target-type: ip name: "nginx-service" namespace: "default" spec: ports: - port: 80 targetPort: 80 protocol: TCP type: NodePort selector: app: "nginx" EOF
kubectl apply -f nginx-service.yaml The output will be similar to:
deployment.extensions/nginx-deployment created Finally, let’s create our ingress resource:
cat > nginx-ingress.yaml <<-EOF apiVersion: extensions/v1beta1 kind: Ingress metadata: name: "nginx-ingress" namespace: "default" annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing labels: app: nginx-ingress spec: rules: - http: paths: - path: /* backend: serviceName: "nginx-service" servicePort: 80 EOF kubectl apply -f nginx-ingress.yaml
The output will be:
ingress.extensions/nginx-ingress created Once everything is done, you will be able to get the ALB URL by running the following command:
kubectl get ingress nginx-ingress The output of this command will be similar to this one:
NAME HOSTS ADDRESS PORTS AGE nginx-ingress * 5e07dbe1-default-ngnxingr-2e9-113757324.us-east-2.elb.amazonaws.com 80 9s
but Iam unable to get the ALB URL in this step kubectl get ingress nginx-ingress
Any help.. Thanks in advance..