1

For some reason, the postgres instance isn't being locked down with a password using the following kubernetes script.

apiVersion: v1
kind: ReplicationController
metadata:
    name: postgres
    labels:
        name: postgres
spec:
    replicas: 1
    template:
      metadata:
        labels:
          name: postgres
      spec:
        containers:
          - resources:
            image: postgres:9.4
            name: postgres
            env:
              - name: DB_PASS
                value: password
              - name: PGDATA
                value: /var/lib/postgresql/data/pgdata
            ports:
              - containerPort: 5432
                name: postgres
            volumeMounts:
              - mountPath: /var/lib/postgresql/data
                name: postgres-persistent-storage
        volumes:
          - name: postgres-persistent-storage
            gcePersistentDisk:
              pdName: postgres-disk
              fsType: ext4

Any ideas?

1 Answer 1

1

According to the docker hub documentation for the postgres image you should be using the environment variable POSTGRES_PASSWORD instead of DB_PASSWORD.

Sign up to request clarification or add additional context in comments.

4 Comments

I should have mentioned I actually tried this as well and it didn't work. I'm wondering if the format of my script is wrong?
I figured out the problem. You have to specify the POSTGRES_PASSWORD the first time. If you don't, you cannot add it later.
Can you explain? Did you try to change the yaml file and patch the object? If you changed the yaml you could also do a kubectl rolling update to apply your changes because it replaces the current pods with new pods with the updated configuration.
I had to delete the pod and the volume. If I left the volume, it wouldn't pick up the added password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.