Kubernetes Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
* [[kubeadm]]
* [[kubeadm]]
* [[kustomize]]
* [[kustomize]]
* <span id='Namespace_Operations'></span>[[Kubernetes Namespace Operations|Namespace Operations]]
* <span id='Pod_Operations'></span>[[Kubernetes Pod Operations|Pod Operations]]
* <span id='Secrets_Operations'></span>[[Kubernetes Secrets Operations|Secrets Operations]]


=Runtimes=
=Runtimes=

Revision as of 16:25, 22 August 2019

Internal

Subjects

Runtimes

Namespace Operations

kubectl get namespaces|ns
kubectl delete namespace|ns <namespace-name>

Pod Operations

kubectl get pods|po
kubectl describe pod <pod-name>
kubectl log <pod-name>

To Redistribute

Get the Manifest for an Existing Object

The manifest can be used to recreate the object:

kubectl get pod pod-name --export -o yaml

Note that --export is deprecated and will be removed in the future so find an equivalent.

Kill Immediately

kubectl delete -n my-ns pod my-pod --force --grace-period=0

Logging

"Tail" logging:

kubectl -n my-namespace logs -f my-pod

Logging that survives pod restart:

while ! kubectl -n my-namespace logs -f my-pod; do sleep 1; done

Port Fowarding

 while ! kubectl -n my-namespace port-forward service/my-service 8787:8787; do sleep 1; done

Get an Individual Attribute Only

https://gist.github.com/so0k/42313dbb3b547a0f51a547bb968696ba

kubectl ... -o jsonpath="{.status.phase}"
kubectl ... -o jsonpath="{.items[?(@.spec.unschedulable)].metadata.name}"