kdeng / my-blogs

Kefeng's blogs
0 stars 0 forks source link

Learning Kubernetes -2 #10

Open kdeng opened 5 years ago

kdeng commented 5 years ago

Using minikube to create and run a cluster

# Check environment 
minikube version
kubectl version

# start a new cluster
minikube start

# view the cluster details
kubectl cluster-info

# show all nodes that can be used to host the applications
kubectl get nodes

Deploy app

kubectl run kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 --port=8080

Get deployment

kubectl get deployments

Build a connection between the host and the kubernetes cluster

kubectl proxy

Get pod name

kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')

Send a request to the application running in the pod

curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/