K8S常用的一些命令及工具
【代码】K8S常用的一些命令及工具。
已json格式输出
[root@k8master1 ~]# yum install epel-release
[root@k8master1 ~]# yum -y install jq
[root@k8master1 ~]# kubectl get --raw /api/v1/namespaces/dev | jq
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "dev",
"uid": "8af74190-5caf-4618-84ee-aab217d0c3cf",
"resourceVersion": "422603",
"creationTimestamp": "2023-08-31T14:07:23Z",
"labels": {
"kubernetes.io/metadata.name": "dev"
},
"managedFields": [
{
"manager": "kubectl-create",
"operation": "Update",
"apiVersion": "v1",
"time": "2023-08-31T14:07:23Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
".": {},
"f:kubernetes.io/metadata.name": {}
}
}
}
}
]
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"phase": "Active"
}
}
kubectl get nodes
kubectl get pods --all-namespaces
kubectl delete pods ingress-nginx-admission-create-hsr8b -n ingress-nginx
kubectl apply -f recommended.yaml
kubectl delete -f recommended.yaml
kubectl get all
kubectl get all --all-namespaces
kubectl get ns
kubectl get po
kubectl get pods -o wide --all-namespaces
kubectl get deploy
kubectl get svc nginx-pvc -o yaml
kubectl logs -f nginx-deploy-pvc-568d695777-ldqjx
kubectl get svc nginx-pvc -o yaml
kubectl exec -it nginx-deploy-pvc-7c466b8668-cfpsg – bash
kubectl edit svc nginx-pvc
kubectl get pod,svc -n kubernetes-dashboard
kubectl describe pods kubernetes-dashboard-78f87ddfc-pdjq6 -n kubernetes-dashboard -o wide
kubeadm token list
kubeadm create token
kubectl get lease -n kube-node-lease -o yaml
kubectl explain pod.spec
kubectl describe nodes k8node1.meng.com
更多推荐
所有评论(0)