...

/

Inspecting Ingress Objects

Inspecting Ingress Objects

Learn how we can inspect and test Ingress objects.

Use the following widget to execute all your commands.

apiVersion: v1
kind: Service
metadata:
  name: svc-shield
spec:
  type: ClusterIP
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    env: shield
---
apiVersion: v1
kind: Service
metadata:
  name: svc-hydra
spec:
  type: ClusterIP
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    env: hydra
---
apiVersion: v1
kind: Pod
metadata:
  name: shield
  labels:
    env: shield
spec:
  containers:
  - image: nigelpoulton/k8sbook:shield-ingress
    name: shield-ctr
    ports:
    - containerPort: 8080
    imagePullPolicy: Always
---
apiVersion: v1
kind: Pod
metadata:
  name: hydra
  labels:
    env: hydra
spec:
  containers:
  - image: nigelpoulton/k8sbook:hydra-ingress
    name: hydra-ctr
    ports:
    - containerPort: 8080
    imagePullPolicy: Always
Playground

List all Ingress objects in the default Namespace. If your cluster is on a cloud, it can take a minute or so to get an ADDRESS while the cloud provisions the load balancer.

Please wait for the NGINX ingress pods to run before executing the following commands. You can view the status of the controller pod by executing this command: watch kubectl get pods -n ingress-nginx .

$ kubectl apply -f ig-all.yml
ingress.networking.k8s.io/mcu-all created
$ kubectl get ing
NAME CLASS HOSTS ADDRESS PORTS
mcu-all nginx shield.mcu.com,hydra.mcu.com,mcu.com 212.2.246.150 80
Create the Ingress object and get its status

The CLASS field shows which Ingress class is handling this set of rules. It may show as <None> if we only have a single Ingress controller and didn’t configure classes. The HOSTS field is a list of hostnames the Ingress will handle traffic for. The ADDRESS field is the load balancer endpoint. If you’re working on a cloud cluster, it will be a public IP or public DNS name. If you’re on a local cluster, it’ll probably be localhost. The PORTS field can be 80 or 443.

On the topic of ports, Ingress only supports HTTP and HTTPS. Let’s now describe the Ingress. The output is trimmed to fit the page.

$ kubectl describe ing mcu-all
Name: mcu-all
Namespace: default
Address: 212.2.246.150
Ingress Class: nginx
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
shield.mcu.com / svc-shield:8080 (10.36.1.5:8080)
hydra.mcu.com / svc-hydra:8080 (10.36.0.7:8080)
mcu.com /shield svc-shield:8080 (10.36.1.5:8080)
/hydra svc-hydra:8080 (10.36.0.7:8080)
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /
Events: <none>
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 27s (x2 over 28s) nginx-ingress-controller Scheduled for sync
Get the attributes of an Ingress object

Let’s go through the output.

The Address line is the IP or DNS name of the load balancer created by the Ingress. It might be localhost on local clusters.

Default backend ...