Question

How to fix "DOBS Pod Owner" linter error in an existing kubernetes cluster

Posted April 14, 2021 148 views
KubernetesDigitalOcean Managed KubernetesDigitalOcean Volumes

I was hoping to upgrade my DigitalOcean kubernetes cluster, but have the following linting error: https://docs.digitalocean.com/products/kubernetes/resources/clusterlint-errors/#dobs-pod-owner

I followed a tutorial at the time which did NOT set up a StatefulSet for my PVC, which is why I am getting this error.

I have the following files:

# postgres-storage.yml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: postgres-pv-claim
  labels:
    app: postgres
spec:
  storageClassName: do-block-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

and

# postgres.yml

apiVersion: v1
kind: Service
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  ports:
   - port: 5432
  selector:
   app: postgres
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  selector:
    matchLabels:
      app: postgres
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:9.6
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: POSTGRES_USER
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: POSTGRES_PASSWORD
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgredb
              subPath: postgres
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim

I would like to upgrade my cluster, but am unsure how to fix this issue without breaking postgres.

The example (https://docs.digitalocean.com/products/kubernetes/how-to/add-volumes/) seems to add a StatefulSet with a busybox image, so should I just use my postgres image here instead?

I guess what I am a bit confused by is the example under Define the Pod looks like what I want in my postgres.yml, but then I don’t know how to set up the StatefulSet from above without all the busybox stuff (since I assume I no longer want my postgres there).

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!