create the pod from your YAML file, use the kubectl create command:
kubectl create -f kubia-manual.yaml
kubectl get po kubia-zxzij -o yaml
when creating a pod manifest from scratch, you can start by asking kubectl to explain pods:
kubectl explain pods
kubectl explain pods.spec
Log of specififc container
docker logs <container id>
kubectl logs kubia-manual
kubectl logs kubia-manual -c kubia
kubectl port-forward kubia-manual 8888:8080
In a different terminal, you can now use curl to send an HTTP request to your
pod through the kubectl port-forward proxy running on localhost:8888:
kubectl create -f kubia-manual-with-labels.yaml
The kubectl get pods command doesn’t list any labels by default, but you can see them by using the --show-labels switch:
kubectl get po --show-labels
Instead of listing all labels, if you’re only interested in certain labels,
you can specify them with the -L switch and have each displayed in its own column
kubectl get po -L creation_method,env
Modifying labels of existing pods
Because the kubia-manual pod was also created manually, let’s add the creation_method=manual label to it:
kubectl label po kubia-manual creation_method=manual
Listing pods using a label selector
kubectl get po -l creation_method=manual
To list all pods that include the env label, whatever its value is:
And those that don’t have the env label:
Using labels for categorizing worker nodes
kubectl label node gke-kubia-85f6-node-0rrx gpu=true
kubectl get nodes -l gpu=true
kubectl delete po <pod_name>
Delete all the pods with label creation_method:manual
kubectl delete po -l creation_method=manual
kubectl annotate pods <podname> creator="Ashish"
see the annotation by urself
kubectl describe pod <podname>
kubectl get po --namespace kube-system
kubectl create -f custom-namespace.yaml
kubectl create namespace custom-namespace
Create a resource specific to a namespace
kubectl create -f kubia-manual.yaml -n custom-namespace