官方文档中并没有说明K8S下的部署,只在docker下部署,所以官方的镜像不是通用的。直接从官方拉个镜像放在K8S上并不能运行。本例中用的镜像可能是原作者修改好的,直接拿来用就好了。
创建pv、pvc
apiVersion: v1
kind: PersistentVolume
metadata:
name: zentao
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: nfs-zentao
nfs:
path: /data/zentao
server: 10.61.150.16
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-zentao
namespace: servers
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: nfs-zentao
创建dp
apiVersion: apps/v1
kind: Deployment
metadata:
name: zentao-server
namespace: servers
labels:
app: zentao
spec:
selector:
matchLabels:
app: zentao
replicas: 1
template:
metadata:
labels:
app: zentao
spec:
containers:
- name: zentao
image: hub.ict.ac.cn/dev/zentao:12.3
imagePullPolicy: IfNotPresent
env:
- name: ADMINER_USER
value: 'root'
#mysql用户名
- name: ADMINER_PASSWD
value: '0ckrtsxmdfg_4z7uvR'
#mysql密码
- name: BIND_ADDRESS
value: 'true'
- name: SMTP_HOST
value: 'smtp.test.cn'
ports:
- name: zentao
containerPort: 80
- name: mysql
containerPort: 3306
volumeMounts:
- name: zentao-data
mountPath: /opt/zbox
volumes:
- name: zentao-data
persistentVolumeClaim:
claimName: pvc-zentao
创建svr
apiVersion: v1
kind: Service
metadata:
labels:
app: zentao
name: zentao
namespace: servers
spec:
ports:
- name: zentao
port: 80
protocol: TCP
targetPort: 80
nodePort: 30051
- name: mysql
port: 3306
protocol: TCP
targetPort: 3306
nodePort: 30052
selector:
app: zentao
测试
http://172.16.0.21:30051
admin 123456