| by Arround The Web | No comments

How to Get Ingress Using “kubectl get ingress”

In Kubernetes, the Ingress is an API object that is used to manage and control the incoming traffic of an application. It is used to expose the service outside the Kubernetes cluster. It is also utilized to manage the host and path-based routing, provide SSL termination, and many more. Traffic management rules are defined in the Ingress resource (yaml file). This ingress resource file is then processed with the help of the Ingress controller.

This blog will demonstrate:

Prerequisite: Deploy Ingress Controller and Create Ingress in Kubernetes

The ingress resource (yaml) file is managed and operated through the Ingress controller. To start using ingress to route the application traffic, the user must need to deploy the ingress controller in the Kubernetes cluster. After that, the user can create the new ingress in Kubernetes by applying the Ingress resource yaml file or using the “kubectl create” command.

After deploying the Ingress controller and creating the ingress, the user can access the Kubernetes ingress using the “kubectl get ingress” command. To deploy the ingress controller and to create and use the ingress, follow our associated “Deploy ingress controller in Kubernetes” and “Create Ingress in Kubernetes” articles respectively.

How to Get Ingress Using “kubectl get”?

To get the Ingress in Kubernetes, follow the below steps.

Step 1: Launch PowerShell

First, launch the Windows PowerShell with administrator rights. Administrative privileges are required to run the minikube cluster on Windows built-in Hyper-V:

Step 2: Start Kubernetes Cluster

Next, start the Kubernetes cluster using the “minikube start” command:

minikube start

Step 3: Get Ingress

To get all the resources of Kubernetes, the user usually uses the “kubectl get all” command. But this command does not contain the information about Kubernetes ingress and egress:

kubectl get all

This will only display the “Pods”, “Deployments”, “ReplicaSet”, and “Services”:

In order to access the Kubernetes ingress, either use the “kubectl get in” or “kubectl get ingress” command:

kubectl get ingress

Here, you can see currently we have only one ingress named “demo-ingress”:

How to Get and Save Ingress in Yaml Using “kubectl get ingress”?

Sometimes, users want to access the ingress details along with their configurations and routing rules. To do so, they can access the ingress in a user-defined format through a given command. Here, “-o” is used to specify the output format:

kubectl get ingress demo-ingress -o yaml

Here, you can see that the user can view the routing rules that are defined in “demo-ingress”:

To save the ingress configuration and routing rules in a new file, use the below command. After the “>” operator, set the file name in which you want to store the ingress data and routing rules:

kubectl get ingress demo-ingress -o yaml > new-ingress.yml

This command is also helpful for creating the backup of ingress:

For verification, list down the current directory files using the “ls” command:

ls

Here, you can see we have successfully saved the output of the “kubectl get ingress” command in the “new-ingress.yml” file:

How to Describe Ingress in Kubernetes?

Sometimes the user may forget the routing path or rule that is defined in the Ingress resource or may want to inspect the ingress in detail. For this purpose, they can describe the ingress using the “kubectl describe ingress <ingress-name>” command:

kubectl describe ingress demo-ingress

That is all about getting ingress using the “kubectl get ingress” command.

Conclusion

To get ingress in Kubernetes, first, deploy the Ingress controller and create an ingress. After that, access the Kubernetes ingress using the “kubectl get ingress” command. To access the ingress details and routing rules in Yaml format, use the “kubectl get ingress <ingress-name> -o yaml” command. To describe or inspect the ingress, use the “kubectl describe ingress <ingress-name>” command. We have demonstrated how to get Kubernetes ingress using the “kubectl get ingress” command.

Share Button

Source: linuxhint.com

Leave a Reply