Kubernetes kubectl

Inspect

Node

1
kubectl describe node [NODE_NAME]

Proxy

Proxy Service

1
2
3
kubectl port-forward $(kubectl get pod --selector="label=value" --output jsonpath='{.items[0].metadata.name}') local_port:remote_port

# kubectl port-forward $(kubectl get pod --selector="component=portal" --output jsonpath='{.items[0].metadata.name}') 9000:80

Label

Add label to Node

1
kubectl label nodes <node-name> <label-key>=<label-value>

example:

1
kubectl label nodes gke-xxx-cc361276-cvfg node=elasticsearch

Remove label on Node

1
kubectl label node node_name label_name-

Taint

Add taint to Node

1
2
3
kubectl taint nodes node1 key1=value1:NoSchedule
kubectl taint nodes node1 key1=value1:NoExecute
kubectl taint nodes node1 key2=value2:NoSchedule

Remove taint on Node

1
kubectl patch node node_name -p '{"spec":{"taints":[]}}'