k8s deployment文件 service文件
k8s中deployment与service相关文件的编写
·
1、deployment文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
namespace: demo
spec:
selector:
matchLabels:
app: demo-app
replicas: 1
template:
metadata:
labels:
app: demo-app
spec:
imagePullSecrets:
- name: regcred
containers:
- name: demo-app
image: harbor.cloud.com/test/demo-app:test
imagePullPolicy: Always
env:
- name: HOSTNAME
value: "demo-app"
- name: SPRING_PROFILES_ACTIVE
value: "dev"
- name: SERVER_PORT
value: 8014
- name: NACOS_ADDRESS
value: "192.168.7.1"
- name: NACOS_PORT
value: 8848
- name: NACOS_GROUP
value: "demo"
ports:
- containerPort: 8014
hostNetwork: true
2、service文件
apiVersion: v1
kind: Service
metadata:
name: demo-app
namespace: demo
spec:
selector:
app: demo-app
ports:
- port: 8014
targetPort: 8014
3、deployment+service文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
namespace: demo
spec:
selector:
matchLabels:
app: demo-app
replicas: 1
template:
metadata:
labels:
app: demo-app
spec:
imagePullSecrets:
- name: regcred
containers:
- name: demo-app
image: harbor.cloud.com/test/demo-app:test
imagePullPolicy: Always
env:
- name: HOSTNAME
value: "demo-app"
- name: SPRING_PROFILES_ACTIVE
value: "dev"
- name: SERVER_PORT
value: 8014
- name: NACOS_ADDRESS
value: "192.168.7.1"
- name: NACOS_PORT
value: 8848
- name: NACOS_GROUP
value: "demo"
ports:
- containerPort: 8014
hostNetwork: true
---
apiVersion: v1
kind: Service
metadata:
name: demo-app
namespace: demo
spec:
selector:
app: demo-app
ports:
- port: 8014
targetPort: 8014
更多推荐
已为社区贡献1条内容
所有评论(0)