我正在尝试在部署过程中将hostPath
卷安装到Pod上,但是得到
“您是否正在尝试将目录挂载到文件上(反之亦然)? 检查指定的主机路径是否存在,并且是否为预期的类型。
这些是我的清单文件:
服务
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert --volumes hostPath
kompose.version: 1.17.0 (a74acad)
creationTimestamp: null
labels:
io.kompose.service: decs-zc1
name: decs-zc1
spec:
ports:
- name: "2201"
port: 2201
targetPort: 22
selector:
io.kompose.service: decs-zc1
status:
loadBalancer: {}
PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: decs-zc1-0
spec:
hostPath:
path: '/home/ubuntu/docker-compose/usr/local/ihi/pilot/zc1'
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: decs-zc1-0
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: decs-zc1-1
spec:
hostPath:
path: '/home/ubuntu/docker-compose/usr/local/ihi/pilot/zc1/runtime/'
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: decs-zc1-1
---
uapiVersion: v1
kind: PersistentVolume
metadata:
name: decs-zc1-2
spec:
hostPath:
path: '/home/ubuntu/docker-compose/etc/localtime/'
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: decs-zc1-2
PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: decs-zc1-claim0
name: decs-zc1-claim0
spec:
storageClassName: decs-zc1-0
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: decs-zc1-claim1
name: decs-zc1-claim1
spec:
storageClassName: decs-zc1-1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: decs-zc1-claim2
name: decs-zc1-claim2
spec:
storageClassName: decs-zc1-2
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
部署
apiVersion: apps/v1beta2
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose --file docker-compose.yml convert
kompose.version: 1.17.0 (a74acad)
creationTimestamp: null
labels:
io.kompose.service: decs-zc1
name: decs-zc1
spec:
replicas: 1
selector:
matchLabels:
app: decs-zc1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: decs-zc1
spec:
containers:
- args:
- sh
- /home/decs/ihi_run_zc.sh
image: 460093719278.dkr.ecr.us-east-1.amazonaws.com/pilot-zc:latest
name: decs-zc1
ports:
- containerPort: 22
resources: {}
volumeMounts:
- mountPath: /usr/local/ihi-decs
name: decs-zc1-claim0
- mountPath: /tmp
name: decs-zc1-claim1
- mountPath: /etc/localtime
name: decs-zc1-claim2
restartPolicy: Always
volumes:
- name: decs-zc1-claim0
persistentVolumeClaim:
claimName: decs-zc1-claim0
- name: decs-zc1-claim1
persistentVolumeClaim:
claimName: decs-zc1-claim1
- name: decs-zc1-claim2
persistentVolumeClaim:
claimName: decs-zc1-claim2
status: {}
该Pod能够装入卷并启动的预期结果。