Ingress is one of the kubernets used to process the allocation of a collection of tasks over a set of resources, such as the load balance. Ingress exposes HTTP and HTTPS routes from outside the cluster to cluster services. Here's a clear example of how an Ingress sends all its traffic to one service, Before i start to next section, please download this file for this pages tutorial,


To implement Ingrees, we need to edit httpd.yaml , ingress-httpd.yaml , mandatory.yaml , and service-nodeport.yaml, at VM1 (Manager)

  • cp -r '/var/run/vmblock-fuse/blockdir/pTM1hY/test-ingress-nginx' /root

  • # cp means copy a directory to some specified path

    # -r means recursive processing which process all files in the specified directory with subdirectories

    After you pull the file, then type the command,

    • kubectl apply -f mandatory.yaml

      kubectl apply -f service-nodeport.yaml

    • mandatory.yaml is for build a deployment of ingress-nginx and service-nodeport.yaml is for build a service of ingress-nginx. After you apply those two file, you can type this command kubectl get deployments ,and you will found something wrong, type the command below,

      • kubectl get deployment -n ingress-nginx

        kubectl get pods -n ingress-nginx

      • When you build a deployment, the pods will be create by deployment, so when you delete a pod, it will be create again, because of the deployment, so if you delete the deployment first, then delete pods after, then the pods will not create again. you also can see the service in kubernetes, type the command below

        • kubectl get svc -n ingress-nginx

        • Next step is to create service of httpd and check the httpd’s cluster-IP,

          • kubectl apply -f httpd.yaml

            kubectl get svc

          • Then, you can use curl , but it depends on your IP Address code that for testing the result, if it display "it works !" . It means your httpd is work on kubernetes, Now edit ingress-httpd.yaml , change the serviceName=httpd run the command below to build ingress-nginx on httpd,

            • kubectl apply -f ingress-httpd.yaml

              kubectl get ingress

            • now edit /etc/hosts , and add ip address VM12 www.a.com , ip address VM2 www.b.com , and we can use ping www.a.com to check the command is work on the /etc/hosts

              Kubernetes Ingrees Pods

              To prove the Ingress is work on different pods, first we can run the command,

              • kubectl get pods -o wide

                kubectl exec name -it -- bash

                echo "vm3 www.a.com" > hi.htm

              • Now you can test the website for www.b.com, edit ingress-httpd2.yaml need to change the “name:httpd2”, “host:www.b.com” and “serviceName:httpd2”

                • cp httpd.yaml httpd2.yaml

                  cp ingress-httpd.yaml ingress-httpd2.yaml

                  kubectl apply -f httpd2.yaml

                  kubectl get svc

                  kubectl get deployment

                  kubectl get ingress

                  kubectl get pods

                  kubectl exec name pods -it -- bash

                  echo "www.b.com" > hi.htm

                • # kubectl apply means build the deployment and service of kubernetes