k8s “discuz“ from “discuz.yaml“: no matches for kind “Deployment“ in version “v1“

批量集群部署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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值