rc and volumes

I am deploying postgresql on Linode LKE. I dont really want to configure any crazy replication or anything like that. I was trying to us a ReplicationController to spin up another pod in case of a LKE host failure. The isue is the PV. The PV wont ever mount on the new pod after the LKE host fails. Below is my yaml.

apiVersion: v1
kind: ReplicationController
metadata:
 name: postgresql-rc
spec:
 replicas: 1
 selector:
   name: postgresql
 template:
   metadata:
     name: howdfamily-postgresql
     labels:
       name: postgresql
   spec:
     containers:
       - name: howdfamily-postgresql
         image: postgres:latest
         ports:
           - containerPort: 8080
             name: postgresql
         env:
           - name: POSTGRES_PASSWORD
             value: "REDACTED"
           - name: PGDATA
             value: "/var/lib/postgresql/data/pgdata"
         volumeMounts:
           - mountPath: "/var/lib/postgresql/data"
             name: howdfamily-postgresql
     volumes:
       - name: howdfamily-postgresql
         persistentVolumeClaim:
           claimName: howdfamily-postgresql

So I decided to try a deployment instead.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgresql-deployment
  labels:
    app: postgresql
spec:
 replicas: 1
 selector:
   matchLabels:
     app: postgresql
 template:
   metadata:
     labels:
       app: postgresql
   spec:
     containers:
       - name: howdfamily-postgresql
         image: postgres:latest
         ports:
           - containerPort: 8080
             name: postgresql
         env:
           - name: POSTGRES_PASSWORD
             value: "REDACTED"
           - name: PGDATA
             value: "/var/lib/postgresql/data/pgdata"
         volumeMounts:
           - mountPath: "/var/lib/postgresql/data"
             name: howdfamily-postgresql
     volumes:
       - name: howdfamily-postgresql
         persistentVolumeClaim:
           claimName: howdfamily-postgresql

This is the error. The host is shutdown to simulate an outage.

Multi-Attach error for volume "pvc-b50512d35e9b46e8" Volume is already exclusively attached to one node and can't be attached to another...

1 Reply

Linode Staff

I've come across error messages like this in the past from customers who encountered this same issues and I'd be happy to provide some assistance here.

The error message you are seeing is expected. This is because you can only connect a Persistent Volume Claim to one node at a time. This is mentioned in the Create a Persistent Volume Claim section of our Deploy Persistent Volume Claims with the Linode Block Storage CSI Driver guide:

"Currently the only mode supported by the Linode Block Storage CSI driver is ReadWriteOnce, meaning that it can only be connected to one Kubernetes node at a time."

If you would like to attach a PVC to multiple nodes, you will need to create multiple PVCs.

I hope this answers your question. If you have any other questions or comments, feel free to reach out.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct