关键字 |
---|
alpine、scratch、curl、镜像、最小 |
1、Deployment样例
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: my-app-v6 # deployment的标签
name: my-app-v6 # deployment的名字(name跟labels平级,注意空格)
spec:
replicas: 5
selector:
matchLabels:
run: my-app-v6 # replicasets的标签
template:
metadata:
labels:
run: my-app-v6 # template 的标签
app: my-app # template 的标签
spec: # 定义 template
initContainers:
- image: ur-img-url
name: app-v6
command: ["cp", "-a", "/ur-app-name", "/app/"]
volumeMounts:
- mountPath: /app
name: app-volume
containers:
- image: ur-img-url
name: base-v6
command: ["/app/ur-app-name"]
volumeMounts:
- mountPath: /app
name: app-volume
ports:
- containerPort: 80
volumes:
- name: app-volume
emptyDir: {}
restartPolicy: Always
2、Service样例
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/alicloud-loadbalancer-id: "slb-id"
service.beta.kubernetes.io/alicloud-loadbalancer-force-override-listeners: "true"
service.beta.kubernetes.io/alicloud-loadbalancer-cert-id: "https证书ID"
service.beta.kubernetes.io/alicloud-loadbalancer-protocol-port: "https:443"
labels:
app: my-app-svc # service的标签
name: my-app-slb # service的名称
namespace: default
spec:
ports:
- port: 443
protocol: TCP
targetPort: 80
selector:
app: my-app # service的pod选择器
sessionAffinity: None
type: LoadBalancer