<p>Below is the postgres service file that defines both service and deployment of postgres service.
However the postgres service keeps restarting every minute. Could anyone help me to understand why it keeps restaring? I'm running yaml file on Minikube (1.18)</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: postgresdb
  labels:
    app: postgresdb
spec:
  ports:
  - port: 5432
    name: tcp
  selector:
    app: postgresdb
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgresdb-v1
  labels:
    app: postgresdb
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgresdb
      version: v1
  template:
    metadata:
      labels:
        app: postgresdb
        version: v1
    spec:
      containers:
      - name: postgresdb
        image: postgres
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5432
        env:
          - name: POSTGRES_DB
            value: simple-service 
          - name: POSTGRES_USER
            value: user
          - name: POSTGRES_PASSWORD
            value: pass
        readinessProbe:
          exec:
            command: [&quot;psql&quot;, &quot;-P&quot;, &quot;pass&quot;, &quot;-U&quot;, &quot;user&quot;, &quot;-d&quot;, &quot;simple-service&quot;, &quot;-c&quot;, &quot;SELECT 1&quot;]
          initialDelaySeconds: 15
          timeoutSeconds: 2
        livenessProbe:
          exec:
            command: [&quot;psql&quot;, &quot;-P&quot;, &quot;pass&quot;, &quot;-U&quot;, &quot;user&quot;, &quot;-d&quot;, &quot;simple-service&quot;, &quot;-c&quot;, &quot;SELECT 1&quot;]
          initialDelaySeconds: 45
          timeoutSeconds: 2
                
---
</code></pre>

Sweta Sharma
<p>Your readiness probe is failing because of invalid flag in script. To pass the password via command line use -W or --password check doc <a href="https://www.postgresql.org/docs/8.3/app-psql.html" rel="nofollow noreferrer">here</a></p>
<p>So your probe should be as below (both readiness and liveliness probe)</p>
<pre><code>command: [&quot;psql&quot;, &quot;--password&quot;, &quot;pass&quot;, &quot;-U&quot;, &quot;user&quot;, &quot;-d&quot;, &quot;simple-service&quot;, &quot;-c&quot;, &quot;SELECT 1&quot;]
</code></pre>
