PVC implementation

I am having issue with PVC implementation with my django nginx app deployment contains 4 replicas.
while running --> kubectl apply -f deployment.yaml
output: --> service/hello-python-service created
deployment.apps/hello-python created
persistentvolumeclaim/pv-claim created

But when i see pods status. I am getting “ContainerCreating” for 2 pods and rest 2 pods are “Running”.

My question is why is this behavior of 2 pods “Running” and 2 pods are with “ContainerCreating” status.
And also how can I make it full fledged working with PVC implementation.

code of deployment.yaml–>

apiVersion: v1

kind: Service

metadata:

name: hello-python-service

spec:

selector:

app: hello-python

ports:

  • protocol: “TCP”

    port: 80

    targetPort: 8000

type: LoadBalancer


apiVersion: apps/v1

kind: Deployment

metadata:

name: hello-python

spec:

selector:

matchLabels:

  app: hello-python

replicas: 4

template:

metadata:

  labels:

    app: hello-python

spec:

  containers:

  - name: hello-python

    image: gcr.io/kubernetes-application-2311/baseproject:v1

    command: ["python", "./manage.py", "runserver", "0.0.0.0:8000"]

    imagePullPolicy: Always

    ports:

    - containerPort: 8000

    volumeMounts:

    - mountPath: /storage/data-1

      name: storage

  volumes:

    - name: storage

      persistentVolumeClaim:

        claimName: pv-claim

apiVersion: v1

kind: PersistentVolumeClaim

metadata:

name: pv-claim

spec:

accessModes:

- ReadWriteOnce

resources:

requests:

  storage: 5Gi

please suggest.

Mahesh

Can you please give more details about the cluster environment - minikube, microk8s? The PV’s created that you laying claims on.

we are using GKE (google kubernetes engine) and application is deployed on google cloud platform.