May 2018
Intermediate to advanced
554 pages
13h 51m
English
Kubernetes Pods covered by Service require labels, so that Service can recognize who is the one it should take charge of. In the following commands, we create a Pod with labels first, and attach a Service on it:
// using subcommand "run" with "never" restart policy, and without replica, you can get a Pod// here we create a nginx container with port 80 exposed to outside world of Pod$ kubectl run nginx-pod --image=nginx --port=80 --restart="Never" --labels="project=My-Happy-Web,role=frontend,env=test"pod "nginx-pod" created// expose Pod "nginx-pod" with a Service officially with port 8080, target port would be the exposed port of pod$ kubectl expose pod nginx-pod --port=8080 --target-port=80 --name="nginx-service" ...
Read now
Unlock full access