[Kubernetes] Cluster IP Service

less than 1 minute read


Cluster IP service

# watch pods in runtime
kubectl get pods -w

# starting a simple http server
kubectl create deployment httpenv --image=bretfisher/httpenv

# scaling the server to 5 replicas
kubectl scale deployment/httpenv --replicas=5

# create a ClusterIP service
kubectl expose deployment/httpenv --port 8888

# look up what ip was allocated
kubectl get service
# since this ip is cluster internal only,
# the easiest way to curl it is using kubectl run
# since the containers can talk to each other when they share in the same cluster??

# name of the pod: tmp-shell
# --rm: after pod stops remove it
# --it: shell into the pod after running it
# --image: the image that will be used
#  -- {cmd}: after the container starts, the container should stop looking at options and run the specified command
kubectl run tmp-shell --rm -it --image bretfisher/netshoot -- bash

# inside the pod
curl httpenv:8888