Jump to content

How to Get Ingress Using “kubectl get ingress”


Linux Hint

Recommended Posts

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:

word-image-407661-1.png

Step 2: Start Kubernetes Cluster

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

minikube start

word-image-407661-2.png

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”:

word-image-407661-3.png

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”:

word-image-407661-4.png

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

word-image-407661-5.png

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

word-image-407661-6.png

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:

word-image-407661-7.png

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:

word-image-407661-8.png

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

word-image-407661-9.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...