Kubernetes for Developers
上QQ阅读APP看书,第一时间看更新

Pod name

Since we are working with a web server, using a proxy would make the most sense, as it will forward HTTP traffic through a URL based on the name of the Pod. Before we do that, we will use the port-forward command, which will be more relevant if what you're writing doesn't use the HTTP protocol.

The key thing you will need is the name of the Pod that was created. When we ran kubectl get pods earlier, you probably noticed that the name wasn't just flask, but included some additional characters in the name: flask-1599974757-b68pw. When we invoked kubectl run, it created a deployment, which consists of a Kubernetes ReplicaSet wrapped around a Pod. The first part of the name (flask) is from the deployment, the second part (1599974757) is the unique name assigned to the ReplicaSet that was created, and the third part (b68pw) is the unique name assigned to the Pod that was created. If you run the following command:

kubectl get replicaset

The result will show you the replicasets:

NAME               DESIRED   CURRENT   READY     AGE
flask-1599974757 1 1 1 21h

You can see that the ReplicaSet name is the first two parts of the Pod's name.