Essentials of Managing Kubernetes Contexts
Get information about our current cluster context. Ensure we are login to correct cluster.
Note: * mark on cluster which we are on in output of the command
kubectl config get-contexts
Change our context if needed by specify name
kubectl config use-context <name>
Get information about the API server for our current context
kubectl cluster-info
Get the list of resources available in cluster
kubectl api-resources | more
Explain to see the structure of a resource
kubectl explain pods | more
Explain more or closely
kubectl explain pod.spec | morekueectl explain pod.spec.containers | more
Creating a pod with YAML file
kubectl apply -f pod.yaml
Pod.yaml is a file for creating pod:
apiVersion: v1kind: Podmetadata:name: my-podlabels:app: my-appannotations:my-label: my-labelspec:containers:- name: my-containerimage: my-imageports:- name: my-portprotocol: TCPcontainerPort: 80- name: my-containerimage: my-imageports:- name: my-portprotocol: TCPcontainerPort: 80
Get a list of currently running pods
kubectl get pods
Delete the pod
kubectl delete pod <podname>