@zhangyy
2020-07-01T02:57:55.000000Z
字数 2009
阅读 441
kubernetes系列
- 一: kubernetes yaml 配置文件
YAML 是一种简洁的非标记语言。语法格式:• 缩进表示层级关系• 不支持制表符“tab”缩进,使用空格缩进• 通常开头缩进 2 个空格• 字符后缩进 1 个空格,如冒号、逗号等• “---” 表示YAML格式,一个文件的开始• “#”注释
nignx Demo 配置vim nginx-deployment.yaml---apiVersion: apps/v1kind: Deploymentmetadata:name: nginx-deploymentlabels:app: nginxspec:replicas: 3selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.15.4ports:- containerPort: 80---apiVersion: v1kind: Servicemetadata:name: nginx-servicelabels:app: nginxspec:type: NodePortports:- port: 80targetPort: 80selector:app: nginx----
kubectl create -f nginx-deployment.yaml





• 用run命令生成kubectl run --image=nginx my-deploy -o yaml --dry-run > my-deploy.yaml• 用get命令导出kubectl get my-deploy/nginx -o=yaml --export > my-deploy.yaml• Pod容器的字段拼写忘记了kubectl explain pods.spec.containers
kubectl run --image=nginx my-deploy -o yaml --dry-run > my-deploy.yaml

apiVersion: apps/v1kind: Deploymentmetadata:creationTimestamp: nulllabels:run: my-deployname: my-deployspec:replicas: 1selector:matchLabels:run: my-deploystrategy: {}template:metadata:creationTimestamp: nulllabels:run: my-deployspec:containers:- image: nginxname: my-deployresources: {}status: {}---

kubectl get deploy/nginx -o=yaml --export > my-deploy.yaml

apiVersion: extensions/v1beta1kind: Deploymentmetadata:annotations:deployment.kubernetes.io/revision: "1"creationTimestamp: nullgeneration: 1labels:run: nginxname: nginxselfLink: /apis/extensions/v1beta1/namespaces/default/deployments/nginxspec:progressDeadlineSeconds: 600replicas: 3revisionHistoryLimit: 10selector:matchLabels:run: nginxstrategy:rollingUpdate:maxSurge: 25%maxUnavailable: 25%type: RollingUpdatetemplate:metadata:creationTimestamp: nulllabels:run: nginxspec:containers:- image: nginx:1.14imagePullPolicy: IfNotPresentname: nginxports:- containerPort: 80protocol: TCPresources: {}terminationMessagePath: /dev/termination-logterminationMessagePolicy: FilednsPolicy: ClusterFirstrestartPolicy: AlwaysschedulerName: default-schedulersecurityContext: {}terminationGracePeriodSeconds: 30status: {}
