kubernetes-使用yaml
查询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: {}
少壮不努力,老大徒伤悲