After you have a running cluster you can manage it with the kubectl
command. Most of the commands you can get with the kubectl --help
command, but I show you the most common commands, for manage and getting info about your cluster, nodes, pods, services and labels.
For getting information about the cluster you can user the following command
kubectl cluster-info
It will show you the running address and port.
For getting short information about the nodes, pods, services, etc. or any resources which got a place on the cluster you can use the following command
kubectl get {nodes, pods, services, ...}
The output mostly one line per resource.
For getting detailed description about the resources you can use the describe
flag for the kubectl
kubectl describe {nodes, pods, ...}
The deployed apps are only visible inside the cluster, so if you want to get the output from outside the cluster you should create a route between the terminal and kubernetes cluster.
kubectl proxy
It will open a API, where we can get everything from the cluster. If you want to get the name of the pods for getting information about, you should use the following command:
kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
It will list the pods for later usage.
curl http://localhost:8001/api/v1/proxy/namespaces/default/pods/{pod_name}/
Two other common command is the getting logs and the execute a command from/in the containerized app.
kubectl logs {pod_name}
kubectl exec {pod_name} {command}
Configuring tab completion for your shell can be done with:
source <(kubectl completion zsh) # if you're using zsh
source <(kubectl completion bash) # if you're using bash
or more programatically:
source <(kubectl completion "${0/-/}")