1

I have the following YAML file for create a postgres server instance

kind: Deployment
apiVersion: apps/v1beta1
metadata: 
 name: spring-demo-db
 labels: 
  app: spring-demo-application
spec: 
 replicas: 1
 selector: 
  matchLabels: 
   app: spring-demo-db
 template: 
  metadata: 
   creationTimestamp: null
   labels: 
    app: spring-demo-db
  spec: 
   containers: 
    - name: spring-demo-db
      image: postgres:10.4
      ports: 
      - name: spring-demo-db
        containerPort: 5432
        protocol: TCP
      env: 
      - name: POSTGRES_PASSWORD
        value: "springdemo"
      - name: POSTGRES_USER
        value: "springdemo"
      - name: POSTGRES_DB
        value: "springdemo"
      volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-storage
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      imagePullPolicy: IfNotPresent
   volumes: 
    - name: "postgres-storage"
      persistentVolumeClaim: 
       claimName: spring-demo-pv-claim   
   restartPolicy: Always

But when ssh into the container user springdemo not created. I have been struggling all day.What could be the problem for this

Anyone who can help me?

1 Answer 1

2

You didn't mention what command you're running and what error you're getting, so I'm guessing here, but try this:

kind: Deployment
apiVersion: apps/v1beta1
metadata: 
 name: spring-demo-db
 labels: 
  app: spring-demo-application
spec: 
 replicas: 1
 selector: 
  matchLabels: 
   app: spring-demo-db
 template: 
  metadata: 
   creationTimestamp: null
   labels: 
    app: spring-demo-db
  spec: 
   containers: 
    - name: spring-demo-db
      image: postgres:10.4
      ports: 
      - name: spring-demo-db
        containerPort: 5432
        protocol: TCP
      env: 
      - name: POSTGRES_USER
        value: "springdemo"
      - name: POSTGRES_DB
        value: "springdemo"
      - name: POSTGRES_PASSWORD
        value: "springdemo"
      volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-storage
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      imagePullPolicy: IfNotPresent
   volumes: 
    - name: "postgres-storage"
      persistentVolumeClaim: 
       claimName: spring-demo-pv-claim   
   restartPolicy: Always

But if it doesn't work, just use the Helm chart, because, among other issues, you are passing the password in an insecure way, which is a bad idea.

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

4 Comments

Ok! Let me try.
Any luck @Navigator?
using Helm Chart Worked. Thanks
@Navigator could you please accept the answer..? Thanks!

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.