文章目录
db-deploy.yml
:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: demo-db-deploy
spec:
replicas: 1
template:
metadata:
labels:
app: demo-db-deploy
spec:
volumes:
- name: demo-db-volume
hostPath:
path: /usr/local/demo-sql
containers:
- name: demo-db-deploy
image: mysql:5.7
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
volumeMounts:
- name: demo-db-volume
mountPath: /docker-entrypoint-initdb.d
db-service.yml
:
apiVersion: v1
kind: Service
metadata:
name: demo-db-service
labels:
app: demo-db-service
spec:
selector:
app: demo-db-deploy
ports:
- port: 3310
targetPort: 3306
app-deploy.yml
:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: demo-app-deploy
spec:
replicas: 2
template:
metadata:
labels:
app: demo-app-deploy
spec:
volumes:
- name : beqin-app-volume
hostPath:
path: /usr/local/demo-dist
containers:
- name: demo-app-deploy
image: openjdk:8u222-jre
command: ["/bin/sh"]
args: ["-c","cd /usr/local/demo-dist;java -jar demo-app.jar"]
volumeMounts:
- name: beqin-app-volume
mountPath: /usr/local/demo-dist
app-service.yml
:
apiVersion: v1
kind: Service
metadata:
name: demo-app-service
labels:
app: demo-app-service
spec:
selector:
app: demo-app-deploy
ports:
- port: 80
targetPort: 80