In this blog, we are going to implement the NGINX ingress for Kubernetes Cluster.
Deploy Ingress Controller
# Add NGINX stable repo
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
# Deploy NGINX Controller
helm install ingress-nginx ingress-nginx/ingress-nginx
Deploy Hello App (Pod and Service)
In Progress
Deploy Ingress without TLS
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- backend:
service:
name: hello-app
port:
number: 8080
path: /
pathType: Prefix
Deploy Ingress with TLS
Create Kubernetes Secret
In this example, I am creating a self-signed certificate
export HOST="zaid.cloud.com"
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=${HOST}/O=${HOST}"
kubectl create secret tls ingress-tls-sec --key tls.key --cert tls.crt
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-ingress
namespace: default
annotations:
kubernetes.io/ingress.class: nginx
spec:
tls:
- hosts:
- zaid.cloud.com
secretName: ingress-tls-sec
rules:
- host: zaid.cloud.com
http:
paths:
- backend:
service:
name: hello-app
port:
number: 8080
path: /
pathType: Prefix
Validate the Ingress
# Get the NGINX service external LB IP
kubcetl get service
# Curl to test the Ingress
curl -v -k --resolve zaid.cloud.com:443:<LB-External-IP>https://zaid.cloud.com
Like this:
Like Loading...