devspace
devspace copied to clipboard
persistPaths mounting as empty with multiple containers
dev:
replacePods:
- labelSelector:
app.kubernetes.io/component: app
persistPaths:
- path: /srv/app/public
containerName: php-container
- path: /srv/app/public
containerName: caddy-container
readOnly: true
persistenceOptions:
name: php-public
"php-container" writes files to "php-public" and "caddy-container" should be able to read it, but it doesn't. It loads an empty volume. Why?
@johnnypea that's strange, could you send us the replaced pod yaml? It should actually work like this.
Here you go...
apiVersion: v1
kind: Pod
metadata:
annotations:
devspace.sh/config-hash: 88d0db5056e5cf793714860a186f87583ca2aa4860e5b0ae1570185dbc935d08
devspace.sh/container: php-container
devspace.sh/parent-hash: eb43c0f8ecca8e738d06407d45bb46e448fec3a2b872610d888f03251c0967bf
devspace.sh/parent-kind: StatefulSet
devspace.sh/parent-name: app
helm.sh/chart: component-chart-0.8.4
creationTimestamp: "2022-01-26T10:49:33Z"
generateName: app-0-
labels:
app.kubernetes.io/component: app
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: devspace-app
devspace.sh/replaced: "true"
name: app-0-px5h5
namespace: dev-intraspace
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: app-0
uid: e4d4f1fe-8942-449f-8db2-0c11e5f3f7d1
resourceVersion: "438410"
uid: 2fc5809c-fb8c-40db-98e4-60919e58ec21
spec:
containers:
- env:
- name: DATABASE_URL
value: postgresql://symfony:ChangeMe@database:5432/app?serverVersion=13
- name: MERCURE_JWT_SECRET
value: '!ChangeMe!'
- name: MERCURE_PUBLIC_URL
value: https://localhost/.well-known/mercure
- name: MERCURE_URL
value: http://caddy/.well-known/mercure
- name: APP_ENV
value: dev
- name: XDEBUG_MODE
value: debug
- name: PHP_IDE_CONFIG
value: serverName=symfony
image: php:nCsBMXu
imagePullPolicy: IfNotPresent
name: php-container
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/php
name: php-socket
- mountPath: /usr/local/etc/php/conf.d/symfony.ini
name: phpdevini-config
readOnly: true
subPath: symfony.ini
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-fg978
readOnly: true
- mountPath: /srv/app/public
name: devspace-persistence
subPath: path-0
- env:
- name: MERCURE_PUBLISHER_JWT_KEY
value: '!ChangeMe!'
- name: MERCURE_SUBSCRIBER_JWT_KEY
value: '!ChangeMe!'
- name: SERVER_NAME
value: localhost:8080, localhost:4443, caddy:80
image: caddy:UhRUDGC
imagePullPolicy: IfNotPresent
name: caddy-container
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/php
name: php-socket
readOnly: true
- mountPath: /data
name: caddy-data
- mountPath: /config
name: caddy-config
- mountPath: /etc/caddy/Caddyfile
name: caddyfile-config
readOnly: true
subPath: Caddyfile
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-fg978
readOnly: true
- mountPath: /srv/app/public
name: devspace-persistence
readOnly: true
subPath: path-1
dnsPolicy: ClusterFirst
enableServiceLinks: true
hostname: app-0
imagePullSecrets:
- name: devspace-auth-docker
initContainers:
- args:
- -c
- if [ ! -d "/devspace-persistence/.devspace/" ] && [ -d "/srv/app/public" ];
then cp -a /srv/app/public/. /devspace-persistence/ && mkdir /devspace-persistence/.devspace
; fi
command:
- sh
image: php:nCsBMXu
imagePullPolicy: IfNotPresent
name: path-0-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /devspace-persistence
name: devspace-persistence
subPath: path-0
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-fg978
readOnly: true
nodeName: minikube
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
subdomain: app-headless
terminationGracePeriodSeconds: 5
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: php-socket
persistentVolumeClaim:
claimName: php-socket-app-0
- name: caddy-data
persistentVolumeClaim:
claimName: caddy-data-app-0
- name: caddy-config
persistentVolumeClaim:
claimName: caddy-config-app-0
- configMap:
defaultMode: 420
name: caddyfile-config
name: caddyfile-config
- configMap:
defaultMode: 420
name: phpdevini-config
name: phpdevini-config
- name: kube-api-access-fg978
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
- name: devspace-persistence
persistentVolumeClaim:
claimName: php-public
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2022-01-26T10:49:36Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2022-01-26T10:49:37Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2022-01-26T10:49:37Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2022-01-26T10:49:33Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://eab478b3d75708064c88a0d62bc3c64dfef44ac2f516d6421838694666f47478
image: caddy:ClKaKmm
imageID: docker://sha256:c25593bf96e11f4a9b2b417afdae18824a4fe37466d1e9fd9910d79d7d995db1
lastState: {}
name: caddy-container
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2022-01-26T10:49:36Z"
- containerID: docker://866bf5ae45def70407c120edaf1f7b3f0c0cd67caa2c09e9174f2f52fc7c7a75
image: php:EkxRsyK
imageID: docker://sha256:b2bab11c2613f1370411ef1ae36350888667f55f2bd702748409b47b0b360953
lastState: {}
name: php-container
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2022-01-26T10:49:36Z"
hostIP: 192.168.49.2
initContainerStatuses:
- containerID: docker://2fc93bc2d9845c223450421f392ea17acdd2297946f3d3058f1b6db336cea041
image: php:EkxRsyK
imageID: docker://sha256:b2bab11c2613f1370411ef1ae36350888667f55f2bd702748409b47b0b360953
lastState: {}
name: path-0-init
ready: true
restartCount: 0
state:
terminated:
containerID: docker://2fc93bc2d9845c223450421f392ea17acdd2297946f3d3058f1b6db336cea041
exitCode: 0
finishedAt: "2022-01-26T10:49:35Z"
reason: Completed
startedAt: "2022-01-26T10:49:35Z"
phase: Running
podIP: 172.17.0.2
podIPs:
- ip: 172.17.0.2
qosClass: BestEffort
startTime: "2022-01-26T10:49:33Z"
@johnnypea thanks for the info, I see the problem now, your config needs to look like:
dev:
replacePods:
- labelSelector:
app.kubernetes.io/component: app
persistPaths:
- path: /srv/app/public
containerName: php-container
volumePath: php
- path: /srv/app/public
containerName: caddy-container
readOnly: true
volumePath: php
persistenceOptions:
name: php-public
The important bit is the volumePath
as this will tell DevSpace to use the same path within the volume for your mounts.
@FabianKramm I see, thank you. Can volumePath
be any acceptable path string?
@johnnypea yes it can, it's essentially the subPath on the persistent volume to use