4

So i have a monorepo project that i want to use with skaffold this is the file structure:

- apps
  - server
      ...
- packages
  - common
      ...
- k8s
  - server-deployment.yaml

i want to use skaffold to deploy the server and link the common package into it using volume. with docker-compose its easy:

volumes:
  - ./apps/server:/app/
  - ./node_modules:/app/node_modules
  - ./packages/common:/usr/src/app/node_modules/common

but im trying to do that with skaffold without any success. this is the k8s/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f docker-compose.yml
    kompose.version: 1.26.1 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: server
  name: server
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: server
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f docker-compose.yml
        kompose.version: 1.26.1 (HEAD)
      creationTimestamp: null
      labels:
        io.kompose.network/default: "true"
        io.kompose.service: server
    spec:
      containers:
        - image: server
          name: server
          ports:
            - containerPort: 8080
            - containerPort: 9229
          resources: {}
          volumeMounts:
            - mountPath: /app/node_modules/common
              name: server-claim
      restartPolicy: Always
      volumes:
        - name: server-claim
          hostPath:
            path: ../../packages/common
            type: Directory
status: {}

i also tried to use PersistentVolume and PersistentVolumeClaim but without any success.

how can i do such thing? thanks.

Nir Berko
  • 1,368
  • 1
  • 13
  • 33

1 Answers1

0

What cluster are you using?

You need to mount the host path in the cluster. This is something that every cluster handles differently.

Refer to Minikube and Rancher Desktop docs for how they support it.

Joe Bowbeer
  • 3,574
  • 3
  • 36
  • 47