If we re-run “minikube addons checklist” command, this time we should see the standing of ingress is enabled.
Run following kubectl command to confirm whether or not ingress controller’s pod is working or not.
Above output confirms that nginx-controller has been enabled and began its pod efficiently beneath kube-system namespace.
Notice: I’m assuming Kubernetes cluster is up and working.
Run following kubectl command to confirm the standing of nginx-ingress controller pods,
[email protected]:~$ kubectl get pods -n ingress-nginx -l app.kubernetes.io/title=ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-v7ftn 0/1 Accomplished 0 6m12s
ingress-nginx-admission-patch-njdnf 0/1 Accomplished 0 6m12s
ingress-nginx-controller-75f84dfcd7-p5dct 1/1 Working 0 6m23s
[email protected]:~$
Good, above output confirms that NGINX Ingress Controller has been deployed efficiently and it’s pod is presently working.
Take a look at Ingress Controller
To check Ingress controller, we are going to create two functions based mostly on httpd and nginx container and can expose these functions through their respective companies after which will create ingress useful resource which is able to permit exterior customers to entry these functions utilizing their respective urls.
Deploy httpd based mostly deployment and its service with NodePort kind listening on the port 80, Create the next yaml file which incorporates deployment and repair part,
[[email protected] ~]# vi httpd-deployment.yaml
apiVersion: apps/v1
form: Deployment
metadata:
title: httpd-deployment
spec:
replicas: 1
selector:
matchLabels:
run: httpd-deployment
template:
metadata:
labels:
run: httpd-deployment
spec:
containers:
– picture: httpd
title: httpd-webserver
—
apiVersion: v1
form: Service
metadata:
title: httpd-service
spec:
kind: NodePort
selector:
run: httpd-deployment
ports:
– port: 80
Save and shut the file.
Run kubectl command to deploy above httpd based mostly deployment and its service,
[[email protected] ~]# kubectl create -f httpd-deployment.yaml
deployment.apps/httpd-deployment created
service/httpd-service created
[[email protected] ~]#
Deploy our subsequent NGINX based mostly deployment and its service with NodePort as its kind and port as 80, Content material of yaml file listed under,
[[email protected] ~]# vi nginx-deployment.yaml
apiVersion: apps/v1
form: Deployment
metadata:
title: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
run: nginx-deployment
template:
metadata:
labels:
run: nginx-deployment
spec:
containers:
– picture: nginx
title: nginx-webserver
—
apiVersion: v1
form: Service
metadata:
title: nginx-service
spec:
kind: NodePort
selector:
run: nginx-deployment
ports:
– port: 80
Save and exit the file
Now run following kubectl command to deploy above nginx based mostly deployment and its service,
[[email protected] ~]# kubectl create -f nginx-deployment.yaml
deployment.apps/nginx-deployment created
service/nginx-service created
[[email protected] ~]#
Run under command to confirm the standing of each deployments and their companies
[[email protected] ~]# kubectl get deployments.apps httpd-deployment
NAME READY UP-TO-DATE AVAILABLE AGE
httpd-deployment 1/1 1 1 19m
[[email protected] ~]#
[[email protected] ~]# kubectl get deployments.apps nginx-deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 1/1 1 1 24m
[[email protected] ~]#
[[email protected] ~]# kubectl get service nginx-service httpd-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service NodePort 10.103.75.91 80:30042/TCP 78m
httpd-service NodePort 10.98.6.131 80:31770/TCP 73m
[[email protected] ~]#
Create and Deploy Ingress Useful resource
Create the next ingress useful resource yaml file which is able to route the request to the respective service based mostly url or path. In our instance we be utilizing url or fqdn.
[[email protected] ~]# vim myweb-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
form: Ingress
metadata:
title: name-based-virtualhost-ingress
spec:
guidelines:
– host: httpd.instance.com
http:
paths:
– backend:
serviceName: httpd-service
servicePort: 80
– host: nginx.instance.com
http:
paths:
– backend:
serviceName: nginx-service
servicePort: 80
save and shut the file.
Execute beneath kubectl command to create above ingress useful resource,
[[email protected] ~]# kubectl create -f myweb-ingress.yaml
ingress.networking.k8s.io/name-based-virtualhost-ingress created
[[email protected] ~]#
Run following to confirm the standing of above created ingress useful resource
[[email protected] ~]# kubectl get ingress name-based-virtualhost-ingress
[[email protected] ~]# kubectl describe ingress name-based-virtualhost-ingress
Good, above output confirms that ingress assets have been created efficiently.
Earlier than accessing these urls from outdoors of the cluster please ensure so as to add the next entries in hosts file of your system from the place you supposed to entry these.
192.168.1.190 httpd.instance.com
192.168.1.190 nginx.instance.com
Now attempt to entry these URLs from internet browser, kind
http://httpd.instance.com
http://nginx.instance.com
Nice, above confirms that we’ve efficiently deployed and setup nginx ingress controller in Kubernetes. Please do share your priceless suggestions and feedback.
nginx ingress controller example,kubernetes ingress controller,nginx-ingress controller helm,kubernetes nginx example,kubernetes ingress tutorial,nginx ingress controller bare metal,eks nginx ingress controller,gke nginx ingress