Inspecting Ingress Objects
Learn how we can inspect and test Ingress objects.
We'll cover the following...
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: AlwaysList 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.ymlingress.networking.k8s.io/mcu-all created$ kubectl get ingNAME CLASS HOSTS ADDRESS PORTSmcu-all nginx shield.mcu.com,hydra.mcu.com,mcu.com 212.2.246.150 80
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-allName: mcu-allNamespace: defaultAddress: 212.2.246.150Ingress Class: nginxDefault 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
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 ...