How to deploy a WordPress in Rancher

137 Views Asked by At

I read this link and this one to see how to deploy a simple WordPress application but I cannot.

With the first link I get error that PVC is not bound, and with the second link I get this error in the kubectl describe pod_name:

pod has unbound immediate PersistentVolumeClaims

I even tried manually to run kubectl apply -k . as per in k8s docs but it failed.

I run rancher on docker:

docker run -d -p80:80 -p443:443 --privileged rancher/rancher:latest

Do you please help me how to run a WordPress application to run?

I also tried other links and docs but none of them were a successful attempt.

1

There are 1 best solutions below

5
M SHANMUKHA NATH REDDY On
  1. Describe PVC and check events.

  2. It seems it's not able to create a volume. Cross check on what storage provisioner your using.

  3. If you haven't got any storage provisioned like portworx or csi, try to create volumes using EmptyDir

    1. Create a YAML file for the emptyDir PV; let's call it emptydir-pv.yaml:

      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: my-emptydir-pv
      spec:
        capacity:
          storage: 1Gi
        volumeMode: Filesystem
        accessModes:
          - ReadWriteOnce
        persistentVolumeReclaimPolicy: Retain
        storageClassName: ""
        hostPath:
          path: /data/my-emptydir
      

      This YAML file defines an emptyDir PV named my-emptydir-pv with a capacity of 1Gi and a hostPath that specifies the directory on the node where the data will be stored.

    2. Apply the PV definition to your cluster:

      kubectl apply -f emptydir-pv.yaml
      
    3. Create a Pod that uses the emptyDir PV. Here's an example Pod YAML; let's call it my-pod.yaml:

      apiVersion: v1
      kind: Pod
      metadata:
        name: my-pod
      spec:
        volumes:
          - name: my-emptydir-volume
            persistentVolumeClaim:
              claimName: my-emptydir-pv
        containers:
          - name: my-container
            image: nginx
            volumeMounts:
              - name: my-emptydir-volume
                mountPath: /data
      

    This Pod definition references the previously created emptyDir PV and mounts it to the /data directory in the Pod container.

    1. Apply the Pod definition to your cluster
      kubectl apply -f my-pod.yaml
      

Please note that this approach is suitable for scenarios where you need temporary storage or shared storage among containers within the same node. The data in the emptyDir volume is not persistent, and it will be lost if the Pod is deleted or rescheduled to a different node.