NGINX Ingress on Kubernetes
NGINX Ingress on Kubernetes
https://www.nginx.com/products/nginx/kubernetes-ingress-controller/
By default, pods of Kubernetes services are not accessible from the external network, but only by other pods within the Kubernetes cluster. Kubernetes has a built‑in configuration for HTTP load balancing, called Ingress, that defines rules for external connectivity to Kubernetes services.
The Ingress controller can then automatically program a frontend load balancer to enable Ingress configuration. The NGINX Ingress Controller for Kubernetes is what enables Kubernetes to configure NGINX and NGINX Plus for load balancing Kubernetes services.
Deploy Ingress NGINX
https://kubernetes.github.io/ingress-nginx/deploy/
First, we'll need to initialize our user as a cluster-admin with the following command:
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
Now we can deploy to our cluster via:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
Running a check on the service might show a Pending status:
alexvallejo:showcase-mde$ kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
nginx-ingress-controller-7b887b65b7-d99kh 0/1 Pending 0 22m
Quick Google search shows a potential fix that should address that:
https://github.com/kubernetes/ingress-nginx/issues/4775#issuecomment-558381452
kubectl label node --all kubernetes.io/os=linux
https://blog.rcmmd.com/www-to-non-www-with-kubernetes/
To the Ingress service yml:
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
// this is the required part
nginx.ingress.kubernetes.io/from-to-www-redirect: 'true'
More Resources:
https://devopscube.com/setup-ingress-kubernetes-nginx-controller/
https://cloud.google.com/community/tutorials/nginx-ingress-gke
https://stackoverflow.com/questions/48763805/does-gke-support-nginx-ingress-with-static-ip