kubectl Command


kubectl

kubectl --help

# -o jsonpath
kubectl get deploy coredns -n kube-system -o jsonpath='{.spec.template.spec.containers[0].name}{":\t"}{.spec.template.spec.containers[0].image}{"\n"}'

kubectl get ds efs-csi-node -n kube-system -o jsonpath='{"hostNetwork:"}{"\t"}{.spec.template.spec.hostNetwork}{"\n"}'

k get nodes ip-10-20-11-153.ap-northeast-2.compute.internal -o jsonpath='{.spec.providerID}{"\t"}'

# --show-managed-fields
kubectl get nodes ip-10-20-10-82.ap-northeast-2.compute.internal -o yaml --show-managed-fields


# taints
kubectl taint node1 key1=value1:NoSchedule
kubectl taint node1 key1=value1:NoExecute

# logs
kubectl logs --tail=-1 --since-time="2024-05-21T00:00:00.000Z" --timestamps=true -l k8s-app=kube-dns -n kube-system >> coredns.log
kubectl logs --tail=-1 --since-time="2024-08-15T00:00:00.000Z" --timestamps=true -l app.kubernetes.io/name=karpenter -n karpenter >> karpenter.log

Tag: [ cli  kubectl  ]