title: Deploying Postgresql with Golang on Kubernetes
body: <p>I'm dealing with Kubernetes. It is not possible to connect the server and the database. Tell me what I'm doing wrong and what else I need to do.</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: testdb
  spec:
    replicas: 1
    selector:
      matchLabels:
        tier: testdb
        app: testapp
    template:
      metadata:
        labels:
          app: testdb
      spec:
        containers:
          - name: testdb
            image: pryby/testdbcon
            env:
              - name: POSTGRES_USER
                value: postgres
              - name: POSTGRES_PASSWORD
                value: root
              - name: POSTGRES_DB
                value: postgres
            ports:
              - containerPort: 5432
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: server
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: server
    template:
      metadata:
        labels:
          app: server
      spec:
        containers:
          - name: server
            image: pryby/testdocker
            env:
              - name: LISTEN
                value: 0.0.0.0:8080
              - name: DB_HOST
                value: testdb
              - name: DB_PORT
                value: &quot;5432&quot;
              - name: DB_USER
                value: postgres
              - name: DB_DBNAME
                value: postgres
              - name: DB_PASSWORD
                value: root
              - name: DB_SSL
                value: disable
            ports:
              - containerPort: 8080
  </code></pre>
  <p>What and where do I need to specify in order to get access to the database?
  If possible, give an example for working with the database and api, I climbed everywhere where I can, I didn't find anything like that. Maybe I didn't search well.</p>