我正在尝试在kubernetes集群上部署docker映像。
我想在集群上实现的输出与我在本地运行该命令时实现的输出相同(输出将是一些生成的文件)
sudo docker run
--env ACCEPT_EULA="I_ACCEPT_THE_EULA"
--volume /my-folder:/opt/data
--volume /my-folder:/opt/g2
test/installer:3.0.0
我为kubernetes侧的部署创建的是:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
namespace: default
spec:
template:
metadata:
name: test
labels:
app: test
spec:
volumes:
- name: nfs-volume
nfs:
# URL for the NFS server
server: SERVER_HOSTNAME
path: PATH
containers:
- name: test-container
image: DOCKER_IMAGE
resources:
requests:
memory: "1Gi"
cpu: "1000m"
limits:
memory: "2Gi"
cpu: "2000m"
env:
- name: ACCEPT_EULA
value: "I_ACCEPT_THE_EULA"
volumeMounts:
- name: nfs-volume
mountPath: /var/nfs
replicas: 1
selector:
matchLabels:
app: test
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
我遇到的问题是,对于这两个参数,我无法理解如何在k8端执行相关操作。有什么建议吗?
--volume /my-folder:/opt/data
--volume /my-folder:/opt/g2
目前我得到的错误如下:cp:无法创建目录'/opt/test': Permission denied
try this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
namespace: default
spec:
template:
metadata:
name: test
labels:
app: test
spec:
volumes:
- name: my-folder
hostPath:
path: /my-folder
containers:
- name: test-container
image: test/installer:3.0.0
resources:
requests:
memory: "1Gi"
cpu: "1000m"
limits:
memory: "2Gi"
cpu: "2000m"
env:
- name: ACCEPT_EULA
value: "I_ACCEPT_THE_EULA"
volumeMounts:
- name: nfs-volume
mountPath: /var/nfs
- name: my-folder
mountPath: /opt/data
- name: my-folder
mountPath: /opt/g2
replicas: 1
selector:
matchLabels:
app: test
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0