How to connect to GCP Cloud SQL using CLoud IAM user - postgresql

The first answer here is a guide on how to connect to your Cloud SQL database using a Cloud SQL IAM User.
Follow these steps to create a user first.

Install Google Cloud SDK for your local machine.
https://cloud.google.com/sdk/docs/install
Run gcloud in any terminal to authenticate your Google Cloud Platform User on your system.
gcloud init
Download Google Cloud SQL Auth Proxy for your operating system. https://cloud.google.com/sql/docs/postgres/sql-proxy
Windows: Just Download
MacOS: curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64
MacOS: chmod +x cloud_sql_proxy
Run the proxy from the downloaded directory to start. Keep it running for the duration you want to be connected. Choose a TCP port that is unused on your system. the -instances field is your instance connection name, on the instance overview page
Windows: .\cloud_sql_proxy.exe -instances="project:region:db-instance"=tcp:5432 -enable_iam_login
MacOS Silicon: softwareupdate --install-rosetta - needed to run software for older cpus
MacOS Silicon: arch -x86_64 zsh - opens up a terminal which can run the software
MacOS & MacOS Silicon: ./cloud_sql_proxy -instances="project:region:db-instance"=tcp:5432 -enable_iam_login
The service is now running and allows connection to the database. This includes any coded packages and modules from your favourite language, also applications like PgAdmin, DataGrip, Jetbrains Database Navigator and Chrome Database explorers to connect. Set connection settings to
Host: localhost or 127.0.0.1
User: username#email.com
Pasword: yourGCPpassword
Other Resources
Quickstart for using the Cloud SQL Auth proxy
MacOS running arch64 processes
Debugging Connection Issues

Related

GCloud auth login: Ports 8085 and 8184 possible blocked

I have installed and uninstalled and reinstalled GCloud on MACOS Monterey (Chipset M1) and I'm facing the next situation: When I run in Terminal gcloud auth login, it displays the next message:
WARNING: Failed to start a local webserver listening on any port between 8085 and 8184. Please check your firewall settings or locally running programs that may be blocking or using those ports.
WARNING: Defaulting to --no-browser mode.
You are authorizing gcloud CLI without access to a web browser. Please run the following command on a machine with a web browser and copy its output back here. Make sure the installed gcloud version is 372.0.0 or newer.
I have tried in many ways to install: The last one was this:
curl https://sdk.cloud.google.com | bash
exec -l $SHELL #restart shell
But I still facing that message.
Anybody couls help me with this?
This happens because my Internet provider has blocked these ports. There will be to make some fixes to the router.
Patch solution for this:
gcloud auth login --no-launch-browser
Follow the instructions given on Terminal

I have installed cloudctl but when I try to login in command prompt getting 'cloudctl' not recognized error

enter image description here
Any help is much appreciated.
There are multiple platform versions (Windows™, Linux®, or macOS )of the CloudCtl [Ref1], and install the appropriate CLI
you can list the files using curl
curl -kL https://--masterNodeIpAddress--:8443/api/cli
"cloudctl-darwin-amd64"
"cloudctl-linux-amd64"
"cloudctl-linux-ppc64le"
"cloudctl-linux-s390x"
"cloudctl-win-amd64.exe"
replace the --masterNodeIPAddress- for your cluster
##for linux x86
use the curl to download
curl -kLo /tmp/cloudctl-linux-amd64 https://--masterNodeIpAddress--:8443/api/cli/cloudctl-linux-amd64
Change permission to execute and copy to local path
chmod +x /tmp/cloudctl-linux-amd64
cp /tmp/cloudctl-linux-amd64 /usr/local/bin/cloudctl
Login to the cluster
cloudctl login -a https://--masterNodeIpAddress--:8443
-- replace masteNodeIPaddress with masternode IP address or haproxy, or load balancer used for the High availability master node
Customized Instructions to install clients from ICP console
You can also find the customized instructions for downloading and installing all the clients.
Log-in in to your IBM Cloud Private cluster management console from a web browser.
Connect to the URL https://masterORloadBalenacer:8443 and use the appropriate credentials.
Menu ( left BurgerIcon) left navigation -> CommandLine tools
Direct link https://masterORloadBalancerHostname:8443/console/tools/cli
Ref-1: Installing the IBM® Cloud Private CLI
https://www.ibm.com/docs/en/cloud-private/3.2.0?topic=cloudctl-installing-cloud-private-cli

How to connect to the database in ddev?

I installed successfully ddev for TYPO3 and now want to connect to the mariadb database. But what are the credentials? If I ssh into the container and want to connect I got a password prompt.
Access via external tools is described in Using Developer Tools with ddev.
Specifically you need to execute the following command to get the necessary credentials:
ddev describe
When upgrading my ddev and deleting all the containers, everything stayed the same except my new port number incremented up by one.
mariadb
Host: localhost:portNumberIncrementedByOne
User/Pass: 'db/db'

Why google cloud shell auto disconnect after 1 hours

I use Google Cloud Shell to run Jupyter Notebook on instance , but after 1 hours,the connection is disconnect.
And I reconnect to instance, there is nothing, is same as reset instance.
So, please tell me how to set up ,make the connection of cloud shell
keep connect.
Thanks!
Google Cloud Shell auto disconnect because you didn't do anything in the Cloudshell's terminal! So to keep the cloudshell session alive, you can enter the following javascript code to the browser's javascript console
setInterval(function() {document.elementFromPoint(500, 500).click();}, 30000);
That's the trick!
P/S: If you want to use Jupyter Notebook, why you don't use Google Colab instead? It has a pre-installed Jupyter Notebook as well as more CPU and ram. You can use the same js for Colab!
UPDATE: you can try Cloud Shell SDK, then connect to Google Cloud Shell by gcloud cloud-shell ssh, which is much faster than the web interface, allow port forwarding (based on ssh), and have a longer time limit.
You can even connect to it using VSCode.
The virtual machine instance that backs your Cloud Shell session is
not permanently allocated to a Cloud Shell session and terminates if
the session is inactive for an hour.
https://cloud.google.com/shell/docs/limitations
I am late to answer this but try this if not already. Open the sysctl.conf and add below lines.
grep keep /etc/sysctl.conf
sudo vi /etc/sysctl.conf
net.ipv4.tcp_keepalive_time=60
net.ipv4.tcp_keepalive_intvl=60
net.ipv4.tcp_keepalive_probes=5
stop and start your instance.
Answer from a year later
You can use gcloud cli. Just install it, open a terminal and run gcloud cloud-shell ssh --authorize-session, then you can use the terminal.
You can also ssh from VSCode to Google Cloud Shell. Just set the key file to .ssh/google_compute_engine, get the ip of CloudShell machine by curl -L ipconfig.me, and then ssh to that ip with port 6000.

How to display monitoring windows of Hawkular?

I am a beginner to Hawkular and struggling to display the Hawkular web ui. My OS is Windows 10 and Cassandra datastax-ddc-64bit-3.7.0 is installed successfully.
Both Wildfly 10 and hawkular-services-dist-0.23.0.Final are unzip in c driver.
This is my Hawkular installation process.
add user in Hawkular home folder <hawkular-services-dist-0.23.0.Final\bin>
add-user.bat -a -u username -p password -g read-write,read-only
execute standalone.bat in hawkular home folder <hawkular-services-dist-0.23.0.Final\bin>
standalone.bat
I download hawkular-wildfly-agent-installer file from Wildfly agent Installer link of welcome windows, localhost:8080
I execute jar command like below
java -jar hawkular-wildfly-agent-installer.jar —target-location=c:\wildfly-10.0.0.Final --username username —password password
And I start wildfly 10 with the following option in wildfly_home folder <c:\wildfly-10.0.0.Final\bin>
standalone.bat –Djboss.socket.binding.port-offset=100
These steps throw no exceptions. However I can not see any monitoring option display, only welcome window.
How can I display the Hawkular monitoring window?
There is no built-in GUI for showing metrics in Hawkular services. Hawkular exposes REST endpoints to fetch data, that you can directly use within an application of your own (they are detailed here: for Metrics, for Alerts). But there's also a couple of available tools to display metrics:
You can use Grafana with the Hawkular datasource plugin.
There's also HawkFX, a jruby client, but I'm not sure if it has been tested on windows.
And an Android client, though I never used it myself