Install Portainer on Cloud Run | Google Cloud(GCP)
Updated: Jan 28
Prerequisites:
You will need the following items to complete this tutorial.
A Portainer image in Google Container Registry.
A Domain (Registered in any hosting provider)
Step - 1. Add the Portainer image to Container Registry.
Select or create a Google Cloud project from the project selection page in the Google Cloud Console.
Make sure your Cloud project's billing is turned on.
Allow the Container Registry API to be used.
Navigate to the container registry in the Google cloud console and open cloud shell access to pull the portainer community editions from the docker. Lastly, push the portainer image to the container registry using the following commands.
Syntax:
docker pull portainer/portainer-ce
docker tag portainer/portainer-ce gcr.io/<project-id>/portainer-community-edition
docker push gcr.io/<project-id>/portainer-community-edition
Example:
docker pull portainer/portainer-ce
docker tag portainer/portainer-ce gcr.io/elegant-canto-331917/portainer-community-edition
docker push gcr.io/elegant-canto-331917/portainer-community-edition

To learn more about container registry pulling and pushing images. Visit the link here.
To learn more about deleting an image from the container registry, visit the link.
Step - 2. Install Portainer on Cloud Run.
Navigate to the Cloud Run interface in the Google cloud console and click on the "Create Service" option to deploy the portainer.
Choose the "Deploy one revision from an existing container image" option in the create service interface and select the portainer image from the container registry.

Then, type the service name and choose the region.
Next, specify the CPU allocation, pricing and auto-scaling options. Also, select the "Allow all traffic" option in the ingress and select the "Allow unauthenticated invocations" in the Authentication.
Lastly, Expand the "Container, Variables & Secrets, Connections, Security" option and type "9000" in the container port under the container tab.
Finally, click on the "create" option to deploy the portainer.

For portainer initial setup, click on the URL at the top of the deployment.
To learn more about portainer basic setup. Visit the link here.
Step - 3. Setting up a custom domain.
Navigate to the Cloud Run interface and click on the "Manage Custom Domains" option,
Click on the "Add Mapping" option in the Manage Custom Domains interface to point to your custom domain.

Select the service to which you're mapping the custom domain from the Add Mapping interface.
Enter your domain name and click on continue to verify ownership of the domain.
Unless you bought your domain from Google, you must prove ownership before using it.
In case, If you have already verified the ownership of the domain, choose the domain from the "Select a verified domain" drop-down list and type the subdomain name in the "Specify Subdomain" field or leave it to a blank to point to the root domain.
Then, click on the "continue" option to update your DNS record at your domain registrar.

In this tutorial, I will use a domain name registered at GoDaddy. In case, If your domain registered with another hosting provider. Update the DNS record as per your hosting provider guidelines.

Lastly, add a CNAME record in your domain DNS points to "ghs.googlehosted.com."
Finally, Click on the "Done" option in the add mapping interface.

Conclusion
Here are some recommended tips and tricks.
To install Portainer BE via NodePort or Ingress. Kindly visit the link below and refer to the offical documentation.
https://docs.portainer.io/v/be-2.10/start/install/server/kubernetes/baremetal
To Install Portainer on Compute Engine with Docker | Ubuntu.
https://www.incapio.com/post/install-portainer-on-compute-engine-with-docker-ubuntu-gcp
To Install Portainer on Google Kubernetes Engine.
https://www.incapio.com/post/install-portainer-on-google-kubernetes-engine-gcp