【Kubernetes】Yaml
Three Parts
- 查看deployment的status信息
kubectl get deployment whoami-deployment -o yaml
Format
Yaml文件格式校验工具:https://codebeautify.org/yaml-validator
Template
Labels & Selector
Demo
- deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: springboot-demo
labels:
app: springboot-demo
spec:
replicas: 1
selector:
# 选择labels是app:springboot-demo的pod
matchLabels:
app: springboot-demo
template:
metadata:
name: springboot-demo
labels:
app: springboot-demo
spec:
containers:
- name: springboot-demo
image: registry.cn-hangzhou.aliyuncs.com/djflying/springboot-demo:main
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
- service
apiVersion: v1
kind: Service
metadata:
name: springboot-demo
spec:
selector:
# 先择labels是app:springboot-demo的deployment和pod
app: springboot-demo
ports:
- port: 80
protocol: TCP
targetPort: 8080
type: ClusterIP
- pod
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
评论区