Anton Andell
Anton Andell

Reputation: 93

Can't mount python code to local kubernetes pod

I'm trying to setup a local kubernetes development kluster with minikube and can't mount my python file to a pod.

I have a server.py file in my src directory that i mount onto the serverpod:

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: web
  name: serverpod
spec:
  containers:
    -
      imagePullPolicy: IfNotPresent
      image: flaskserver
      name: testserver
      ports:
        -
          containerPort: 8000
      volumeMounts:
        - name: src-config
          mountPath: /src

  volumes:
    - name: src-config
      hostPath:
        path: /home/user/project/src

Dockerfile

FROM python:3
EXPOSE 8000

RUN pip install flask
RUN mkdir /src

CMD [ "python", "src/server.py" ]

The pod does not seem to find the server.py file, not sure if i'm using this right.

Upvotes: 1

Views: 485

Answers (1)

joseph
joseph

Reputation: 1008

Looks like you have not mounted the host folder to the kubernetes volume. Follow this doc to mount a folder in your local to your cluster.

Upvotes: 2

Related Questions