K8S常用命令

1. 获取资源

]# kubectl get [资源] -n [namespace] -o|--output wide -A|--all-namespaces -l|--selector [标签] -w|--watch

2. 创建资源

]# kubectl create [资源] -f xxx.yaml # 通过yaml文件创建资源
]# kubectl create deploy NAME --image=NAME --dry-run=client -o wide
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}

3. 查看资源字段

]# kubectl explain pod.spec
posted @ 2021-05-24 08:28  西伯利亚狼666  阅读(55)  评论(0)    收藏  举报