2.2 Exercise: Deploy PgAdmin
2.2 Exercise: Deploy PgAdmin
1. Secret
- Open pgadmin-secret.yaml
- Create a unique name for the secret and add it to the
metadatasection of the manifest. - In the
codesection, add your secret data. Format each entry askey: value. Renamekeyto something meaningful for the value it represents. - Remember that secrets must be base64 encoded. Use a Linux terminal or an online tool to encode your string, and replace
valuewith the encoded string. - Apply the secret to your cluster.
2. Deployment
- Open pgadmin-deployment.yaml
- 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.
- 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). - Add a name for the port assigned internally within the container.
3. Service
- Open pgadmin-service.yaml
- Create a unique name for the service and add it to the
metadatasection of the manifest. - 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.
- Apply the service to your cluster.
4. Access PgAdmin UI
- Use kubectl port-forward to forward the PgAdmin service port to your local machine. Example:
kubectl port-forward svc <service-name> 8080:<service-port> - Open your web browser and navigate to
http://localhost:8080(or the port you used in step 4a). - Log in using the email and password you set in the secret.
- Add a new server connection in PgAdmin to connect to your PostgreSQL instance. Use the service name of your PostgreSQL service as the host.