apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: web name: web spec: replicas: 1 selector: matchLabels: app: web strategy: {} template: metadata: creationTimestamp: null labels: app: web spec: containers: - image: nginx name: nginx resources: {} statu...
例如:在名称为dev的namespace下创建一个Nginx的Pod kubectl run nginx --image=nginx:1.17.1 --port=80 --namespace=dev 1. 常用指令 kubectl get pods -n dev kubectl describe pod nginx -n dev kubectl get pods -n dev -o wide kubectl get pods -n dev -o json kubectl get pods -n dev -o ...
kubectl describe <resource> [-o wide | json | yaml] [-n namespace] 每个资源对象都有用户期望的状态(Spec)和现有的实际状态(Status)两种状态信息,get命令可以查看用户期望的状态,而describe命令可以查看某个资源的两种状态信息。 $ kubectl describe namespace/istio-demo Name: istio-demo Labels: istio-inje...
--all-namespaces 或-A :表示显示所有命令空间, --show-labels :显示所有标签 -l app:仅显示标签为app的资源 -l app=nginx :仅显示包含app标签, 且值为nginx的资源 //查看master 节点状态 kubectlgetcomponentstatuses kubectlgetcs //查看命令空间 kubectlgetnamespacekubectlgetns //命令空间的作用:用于允许不...
# kubectl attach <pod_name> -c <container_name> 类似于docker attach的功能,用于取得实时的类似于kubectl logs的信息 5、查看kubernetes配置 6、查看资源对象拥有的字段 kubectl explain pod kubectl explain pod.apiVersion 7、查看节点标签 kubectl get node --show-labels ...
NAME STATUS AGE charts Active 8d default Active 9d kube-node-lease Active 9d kube-public Active 9d kube-system Active 9d 每个get命令还可以通过-namespace或者-n参数指定对应的命名空间。当你想查看kube-system中的pods时将会非常有用,这些pods是Kubernetes自身运行时所必须的服务。
Name:app-svc Namespace:app Labels:app=app-deploy Annotations:<none>Selector: app=app-deploy Type: ClusterIP IP: 192.168.28.124 Port:<unset>80/TCP TargetPort: 80/TCP Endpoints: 172.7.21.8:80 进入pods (exec) Usage: kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [ar...
kubectl get pod --show-labels 获取该节点的所有命名空间: kubectl get namespace 说明: 类似可以使用“kubectl get svc”,“kubectl get nodes”,“kubectl get deploy”等获取其他资源的信息。 以YAML格式输出Pod的详细信息: kubectl get pod <podname> -o yaml ...
NAME STATUS AGE charts Active 8d default Active 9dkube-node-leaseActive 9d kube-public Active 9d kube-system Active 9d 每个get命令都可以使用–namespace或-n参数指定对应的命名空间。这点对于查看kube-system中的 Pods 会非常有用,因为这些 Pods 是 Kubernetes 自身运行所需的服务。
# 根据重启次数排序列出 pod$ kubectl get pods --sort-by='.status.containerStatuses[0].restartCount' # 获取所有具有 app=cassandra 的 pod 中的 version 标签$ kubectl get pods --selector=app=cassandra rc -o \jsonpath='{.items[*].metadata.l...