查询k8s支持的对象
kubectl api-resources
# 查看当前版本支持的所有对象
kubectl explain pod
kubectl explain pod.metadata
kubeclt explain pod.spec
kubeclt explain pod.containers
# k8s自带的文档,介绍对象字段
--dry-run=client # 空运行
-o yaml # 生成yaml
export out="--dry--run=client -o yaml"
kubectl run ngx --image=nginx:alpine $out
会生成一个绝对正确的YAML文件
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: ngx
name: ngx
spec:
containers:
- image: nginx:alpine
name: ngx
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
标签:kubectl,run,kubernetes,explain,yaml,使用,pod,ngx
From: https://www.cnblogs.com/zsjlovewm/p/16995422.html