Exercise
-
Create a deployment named ghost with 3 pods based on the ghost:4 image
-
Expose the deployment with a ClusterIP service
Note: ghost application listens on port 2368
-
From the service, retreived the IP addresses of the pods
-
Inspect the Endpoints resource created
-
Delete the deployment and service
Solution
- Create a deployment with 3 pods based on the ghost:4 image
k create deploy ghost --image=ghost:4 --replicas=3
- Expose the deployment with a ClusterIP service
k expose deploy/ghost --port 2368
- From the service, retreived the IP addresses of the pods
The pods IP addresses are listed in the Endpoints property:
k describe svc/ghost
Name: ghost
Namespace: default
Labels: app=ghost
Annotations: <none>
Selector: app=ghost
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.110.190.83
IPs: 10.110.190.83
Port: <unset> 2368/TCP
TargetPort: 2368/TCP
Endpoints: 10.32.0.3:2368,10.38.0.3:2368,10.38.0.5:2368 <- pods' IP addresses
Session Affinity: None
Events: <none>
- Inspect the Endpoints resource created
When creating the service a Endpoints resource have been created as well. It lists the IP:PORT of pods in the Ready status and can be described like any other Kubernetes resources:
k describe Endpoints ghost
Name: ghost
Namespace: default
Labels: app=ghost
Annotations: <none>
Subsets:
Addresses: 10.32.0.3,10.38.0.3,10.38.0.5
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
<unset> 2368 TCP
Events: <none>
- Delete the deployment and service
k delete deploy/ghost svc/ghost