Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Updated Readmes with instructions for cloud shell users #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions README-QWIKLABS.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,40 @@ container and creates the credentials file
containing credentials and connection string for the Cloud SQL instance
6. pgadmin_deployment.sh - creates the pgAdmin4 pod

Once **create.sh** is complete you need to run ```make expose``` to connect to
the running pgAdmin pod. ```make expose``` will port-forward to the running pod.
You can [connect to the port-forwarded pgAdmin in your
browser](http://127.0.0.1:8080/login). Use the ```<PGADMIN_USERNAME>``` in the "Email
Address" field and ```<PG_ADMIN_CONSOLE_PASSWORD>``` you defined earlier to login to the console.
From there you can click "Add New Server" and use the ```<DATABASE_USER_NAME>``` and
```<USER_PASSWORD>``` you created earlier to connect to 127.0.0.1:5432.

If you're running the demo within a cloud shell or any web apps using iframes,
note that port-forwarding might not work.

Hence, we need to use load balancer to expose the pod to connect to the instance.
We also need to delete the services in the end to avoid unauthorized access.

On the cloud shell:
Get the Pod ID:
POD_ID=$(kubectl --namespace default get pods -o name | cut -d '/' -f 2)

Expose the pod via load balancer:
kubectl expose pod $POD_ID --port=80 --type=LoadBalancer

Get the service IP address:
kubectl get svc

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP <CLUSTER_IP> <none> 443/TCP 96m
pgadmin4-deployment-6769d76d4c-97kn8 LoadBalancer <CLUSTER_IP> <SVC_IP> 80:31789/TCP 45m

You can connect to the pgAdmin in your browser, using <SVC_IP>.

http://<SVC_IP>

Use the <PGADMIN_USERNAME> in the "Email Address" field and <PG_ADMIN_CONSOLE_PASSWORD> you defined earlier to login to the console. From there you can click "Add New Server" and use the <DATABASE_USER_NAME> and <USER_PASSWORD> you created earlier to connect to 127.0.0.1:5432.

After successful connection, delete the services to avoid unauthorized access:

On the cloud shell, run:

kubectl delete svc <SVC_NAME>



## Validation

Expand Down
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,49 @@ container and creates the credentials file
containing credentials and connection string for the Cloud SQL instance
6. pgadmin_deployment.sh - creates the pgAdmin4 pod


Once **create.sh** is complete you need to expose the pod to connect to
the running pgAdmin instance. Depending on whether you're running the demo on
Cloud shell or not, follow the below steps:


### Cloud Shell Users

If you're running the demo within a cloud shell or any web apps using iframes,
note that port-forwarding might not work.

Hence, we need to use load balancer to expose the pod to connect to the instance.
We also need to delete the services in the end to avoid unauthorized access.

On the cloud shell:
Get the Pod ID:
POD_ID=$(kubectl --namespace default get pods -o name | cut -d '/' -f 2)

Expose the pod via load balancer:
kubectl expose pod $POD_ID --port=80 --type=LoadBalancer

Get the service IP address:
kubectl get svc

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP <CLUSTER_IP> <none> 443/TCP 96m
pgadmin4-deployment-6769d76d4c-97kn8 LoadBalancer <CLUSTER_IP> <SVC_IP> 80:31789/TCP 45m

You can connect to the pgAdmin in your browser, using <SVC_IP>.

http://<SVC_IP>

Use the <PGADMIN_USERNAME> in the "Email Address" field and <PG_ADMIN_CONSOLE_PASSWORD> you defined earlier to login to the console. From there you can click "Add New Server" and use the <DATABASE_USER_NAME> and <USER_PASSWORD> you created earlier to connect to 127.0.0.1:5432.

After successful connection, delete the services to avoid unauthorized access:

On the cloud shell, run:

kubectl delete svc <SVC_NAME>


### Cloud SDK users (or non cloud shell users)

Once **create.sh** is complete you need to run ```make expose``` to connect to
the running pgAdmin pod. ```make expose``` will port-forward to the running pod.
You can [connect to the port-forwarded pgAdmin in your
Expand Down Expand Up @@ -218,7 +261,7 @@ It will run **teardown.sh** which will destroy all of the resources created for
The script takes the following parameters, in order:
* INSTANCE_NAME - the name of the existing Cloud SQL instance

**teardown.sh** will run the following scripts:
**teardown.sh** will run the following scripts
1. delete_resources.sh - deletes everything but the Cloud SQL instance
2. delete_instance.sh - deletes the Cloud SQL instance

Expand Down