2

Could somebody write up the steps of setting up HTTP Load Balancing with Nginx Ingress Controller for Google Kubernetes Engine?

I followed this GKE tutorial for a basic Ingress. It got a Forwarding Rule in Load Balancing tab in the end. I guess if I want to delete that Load Balancer, I will need to use Nginx Ingress Controller?

I looked at this Nginx Ingress GKE tutorial, but I don't know how to combine those two tutorials to make the "Hello-app" work without a Load Balancer.

1

I. If you are using GKE ingress controller

1)

  kubectl run web --image=gcr.io/google-samples/hello-app:1.0 --port=8080

2)

kubectl expose deployment web --target-port=8080 --type=NodePort

3)

cat <<EOF > ./ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
spec:
  backend:
    serviceName: web
    servicePort: 8080 
EOF

4)

kubectl apply -f ingress.yaml

5) Wait up to 5 minutes until GKE apllies firewall rules for your ingress

6) Curl your web app

curl $(kubectl get ingress nginx | awk 'NR==2{print $3}')

II. If you want to do it with nginx ingress controller

1)

  kubectl run web --image=gcr.io/google-samples/hello-app:1.0 --port=8080

2)

kubectl expose deployment web --target-port=8080 --type=NodePort

3)

helm install stable/nginx-ingress

4)

cat <<EOF > ./ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: nginx-ingress
spec:
  backend:
    serviceName: web
    servicePort: 8080
EOF

5)

kubectl apply -f ingress.yaml

6)

curl $(kubectl get svc |grep nginx-ingress-controller|awk '{print $4}')
  • Thanks a lot for the write up. With nginx-ingress-controller, step 3 creates a Forwarding Rule in Load Balancing. How to not use a Forwarding Rule? – lucahuy Apr 17 '19 at 5:01
  • As long as you will be using GKE LB you'll be getting that Forwarding Rule. MetalLB is an alternative - metallb.universe.tf/installation – A_Suh Apr 17 '19 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.