批量集群部署discuz,编写yam文件报错
[root@master11 soft]# cat discuz.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: discuz
namespace: discuz
spec:
selector:
matchLabels:
app: discuz
deploy: discuz
template:
metadata:
labels:
app: discuz
deploy: discuz
spec:
containers:
- name: discuz
image: 192.168.50.11:5000/discuz:x3.5
ports:
- containerPort: 80
volumeMounts:
- mountPath: /var/www/html
name: discuz-data
volumes:
- name: discuz-data
hostPath:
path: /data/share/discu
type: DirectoryOrCreate
#报错如下
Error from server (BadRequest): error when creating "discuz.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field Volume.spec.template.spec.volumes.hostPath of type
v1.HostPathVolumeSource
error: resource mapping not found for name: "discuz" namespace: "discuz" from "discuz.yaml": no matches for kind "Deployment" in version "v1"
Error from server (BadRequest): error when creating "discuz.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field Volume.spec.template.spec.volumes.hostPath of type
v1.HostPathVolumeSource
#修改yaml如下
apiVersion: apps/v1
kind: Deployment
metadata:
name: discuz
spec:
replicas: 3
selector:
matchLabels:
app: discuz
template:
metadata:
labels:
app: discuz
spec:
containers:
- name: discuz
image: 192.168.50.11:5000/discuz:x3.5
ports:
- containerPort: 80
volumeMounts:
- name: host-data
mountPath: /var/www/html
volumes:
- name: host-data
hostPath:
path: /data/share/discu
type: DirectoryOrCreate
查看
[root@master11 discuz]# kubectl get node,po,svc -A -owide|grep discuz
default pod/discuz-5b477fd776-nslvp 1/1 Running 0 52m 10.244.126.197 slave13 <none> <none>
default pod/discuz-5b477fd776-pd8js 1/1 Running 0 52m 10.244.199.8 slave12 <none> <none>
default pod/discuz-5b477fd776-zwq6b 1/1 Running 0 52m 10.244.199.7 slave12 <none> <none>