k8s2

kubectl run kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 --port=8080: The run command creates a new deployment. We need to provide the deployment name and app image location (include the full repository url for images hosted outside Docker hub). We want to run the app on a specific port so we add the --port parameter:

kubectl get deployments: To list your deployments

kubectl get nodes: Kubernetes will choose where to deploy our application based on Node available resources.

kubectl proxy: You can see all those APIs hosted through the proxy endpoint, now available at through http://localhost:8001. For example, we can query the version directly through the API using the curl command:

curl http://localhost:8001/version: The API server will automatically create an endpoint for each pod, based on the pod name, that is also accessible through the proxy.

export POD_NAME=$(kubectl get pods -o go-template --template ‘{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}’)
echo Name of the Pod: $POD_NAME : The API server will automatically create an endpoint for each pod, based on the pod name, that is also accessible through the proxy. First we need to get the Pod name, and we’ll store in the environment variable POD_NAME

curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/: Now we can make an HTTP request to the application running in that pod:

猜你喜欢

转载自blog.csdn.net/q386538588/article/details/88219584
k8s