2.2 Exercise: Deploy PgAdmin

2.2 Exercise: Deploy PgAdmin

PgAdmin Skeleton Files

1. Secret

  1. Open pgadmin-secret.yaml
  2. Create a unique name for the secret and add it to the metadata section of the manifest.
  3. In the code section, add your secret data. Format each entry as key: value. Rename key to something meaningful for the value it represents.
  4. Remember that secrets must be base64 encoded. Use a Linux terminal or an online tool to encode your string, and replace value with the encoded string.
  5. Apply the secret to your cluster.

2. Deployment

  1. Open pgadmin-deployment.yaml
  2. fsGroup specifies the group ID (GID) that will own the files and directories within volumes mounted by the pod. Find what PgAdmin needs it's policy set to and add that.
  3. Add an image for PgAdmin. You can find them on Dockerhub. Get a version that is more recent but not "latest" or "snapshot." It should look like dpage/pgadmin:x.x.x (note: the official Docker image is created by dpage).
  4. Add a name for the port assigned internally within the container.

3. Service

  1. Open pgadmin-service.yaml
  2. Create a unique name for the service and add it to the metadata section of the manifest.
  3. Create a name, a port number for the service. Recall what targetPort is by looking at the postgresql service. You can either use the port number itself or the name of the port that was created in 2c.
  4. Apply the service to your cluster.

4. Access PgAdmin UI

  1. Use kubectl port-forward to forward the PgAdmin service port to your local machine. Example: kubectl port-forward svc <service-name> 8080:<service-port>
  2. Open your web browser and navigate to http://localhost:8080 (or the port you used in step 4a).
  3. Log in using the email and password you set in the secret.
  4. Add a new server connection in PgAdmin to connect to your PostgreSQL instance. Use the service name of your PostgreSQL service as the host.