<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by MrAsterisco on Medium]]></title>
        <description><![CDATA[Stories by MrAsterisco on Medium]]></description>
        <link>https://medium.com/@alessio.mm?source=rss-89ff2c03b8ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3s-ezHm0WiCJu6EW.jpg</url>
            <title>Stories by MrAsterisco on Medium</title>
            <link>https://medium.com/@alessio.mm?source=rss-89ff2c03b8ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 17:19:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alessio.mm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hey Google, run this Docker image]]></title>
            <link>https://awstip.com/hey-google-run-this-docker-image-a472331b130f?source=rss-89ff2c03b8ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/a472331b130f</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[MrAsterisco]]></dc:creator>
            <pubDate>Mon, 12 May 2025 19:33:22 GMT</pubDate>
            <atom:updated>2025-05-19T16:25:47.540Z</atom:updated>
            <content:encoded><![CDATA[<p>A lot of companies nowadays deploy their backend and frontend services on AWS, Google Cloud, or Microsoft Azure. Although <a href="https://european-alternatives.eu/category/cloud-computing-platforms">there are alternatives</a>, these are the most common and also the most feature-complete.</p><p>However, when it comes to choose the orchestrator, a lot of businesses tend to choose Kubernetes (in the form of EKS, GKE, or AKS) <em>because that’s what everybody does</em>.</p><p>While a lot has been done in recent years to make Kubernetes more accessible to the <em>average Joe</em>, it is still a difficult technology to comprehend and master. Even when using fully managed platforms <em>(like EKS on Auto Mode)</em>, the deployment and maintenance is often not a straight line.</p><p>Costs are also somewhat difficult to estimate: on AWS, for example, you’re paying a fee for running EKS clusters, but you’re also charged for hours of EC2 instances, as well as traffic. Most of these variables are hard to compute in advance, making it difficult to form a budget. It’s also <em>so easy</em> to spend more: all it takes is a <em>misconfigured</em> autoscale group.</p><h4>So, is Kubernetes bad?</h4><p>No! However, you should decide whether you actually need it. I know some will consider this a controversial statement, but I stand by it fully:</p><blockquote>If you’re asking yourself whether you need Kubernetes, then the answer is “no”.</blockquote><p>Don’t get me wrong: Kubernetes is an excellent piece of software. At my current company (<a href="https://www.linearity.io/">Linearity</a>), we run most of our services on EKS clusters and we’ve been enjoying the reliability, resilience and capacity to autoscale of K8s over the years.</p><p>EKS <em>(and other similar platforms)</em> are also very well established and provide advanced functionalities out-of-the-box, such as advanced networking, security, and more.</p><p>However, if you are in a position to ask yourself whether you need it or not, then the answer is already there. The level of complexity that Kubernetes adds to both the deployment, CI/CD structures, and maintenance is most of the times an overkill. While there are strategies to simplify CI/CD, such as <a href="https://argo-cd.readthedocs.io/en/stable/">ArgoCD</a>, they also require knowledge and maintenance.</p><p>Everybody in your team must have a basic level of knowledge of K8s and the tools around it <em>(</em><em>kubectl to name one)</em>. If you decide to use K8s, your hiring process should reflect that decision too: you should hire engineers that are comfortable messing around with EKS (<em>or any of the other platforms</em>) or you should consider dedicating a part of the budget to hiring an SRE.</p><h4>What’s the alternative, then?</h4><p>What if I told you that you could benefit of Kubernetes without having to even know that you’re running on it?</p><p>Fully-managed platforms are offerings available on most of the cloud providers nowadays. The one that we’ll be having a look at together today is <a href="https://cloud.google.com/run?hl=en">Google Cloud Run</a>.</p><blockquote>Cloud Run essentially allows you to take a Docker image and run it in the cloud.</blockquote><p>The main advantage of Cloud Run is that it abstracts <em>a lot</em> of the necessary infrastructure, including autoscaling, authentication, hardware requirements, and more.</p><p>Cloud Run can automatically determine how many instances of your services are required to handle the current traffic and upscale or downscale accordingly. Most importantly, Cloud Run can downscale to 0 instances: if your service is subject to burst of traffic and then <em>sleeps </em>for the rest of the day, this will allow you to save a lot of money!</p><p>Assuming your service is already <em>containerized </em>and can build a Docker image, deploying it to Cloud Run is as easy as:</p><ol><li>Signing up for a Google Cloud account <em>(if you don’t have one already)</em>,</li><li>Create an Artifact Registry repository to store your Docker images<em>,</em></li><li>Build and publish the image to the repository,</li><li>Configure a stage of your CI to use the gcloud command line tool or Terraform to deploy the Cloud Run service.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bCeihBkkq9aUbJh1cIxfw.png" /><figcaption>The Google Cloud dashboard of a running Cloud Run service.</figcaption></figure><h4>Create an Artifact Registry repository</h4><p><a href="https://cloud.google.com/artifact-registry/docs">Artifact Registry</a> is a universal package manager which can store build artifacts and dependencies. In this case, we are going to be using it to store our Docker images.</p><p><em>While you could also be publishing your image on a public repository, like Docker Hub, you should be aware that there are rate limits in place. For more information, please refer to </em><a href="https://cloud.google.com/run/docs/deploying#images"><em>the official documentation</em></a><em>.</em></p><p>You can create an Artifact Registry repository from the Google Cloud Dashboard, but <em>click-ops</em> is never fun. The following Terraform snippet creates a Docker repository:</p><pre>resource &quot;google_artifact_registry_repository&quot; &quot;my_service_repo&quot; {<br>  project = &quot;&lt;GPC_PROJECT&gt;&quot;<br>  location = &quot;&lt;GCP_REGION&gt;&quot;<br>  repository_id = &quot;&lt;SERVICE_NAME&gt;&quot;<br>  description = &quot;Repository for &lt;SERVICE_NAME&gt;&quot;<br>  format = &quot;DOCKER&quot;<br>  cleanup_policy_dry_run = false # Turn on to disable cleanup policy<br>  cleanup_policies {<br>    id     = &quot;Keep last 10 images&quot;<br>    action = &quot;KEEP&quot;<br>    most_recent_versions {<br>      keep_count = 10 # Change to hold more versions<br>    }<br>  }<br>}</pre><p><em>For more information, refer to </em><a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/artifact_registry_repository"><em>the official documentation</em></a><em>.</em></p><h4>Build and publish your image</h4><p>Building a Docker image is straightforward on all the most common CI platforms.</p><p>On GitHub, you can use the <a href="https://github.com/docker/build-push-action">docker/build-push-action</a>:</p><pre>- name: Build, tag and push container<br>  id: build-image<br>  uses: docker/build-push-action@v3<br>  with:<br>    context: .<br>    file: ./path/to/your/Dockerfile<br>    push: true<br>    tags: |<br>      &lt;GCP_REGION&gt;-docker.pkg.dev/&lt;GCP_PROJECT&gt;/&lt;REPO_NAME&gt;/&lt;SERVICE_NAME&gt;:${{ github.ref_name }}</pre><p>However, this won’t work on its own: the Artifact Registry repository is not public, so you will need to first authenticate your CI to be able to publish there.</p><h4>Workload Identity Federation</h4><p>Authenticating to Google Cloud in a CI environment is a problem that we used to solve using <a href="https://cloud.google.com/iam/docs/service-account-overview">Service Accounts</a>. However, the correct option today is to use <a href="https://cloud.google.com/iam/docs/workload-identity-federation">Workload Identity Federation</a>.</p><p>This technology allows a CI environment to exchange a known token (e.g. the GitHub Action token) for a Google Cloud token.</p><p>This allows a much more granular permission control and it does not require creating a Service Account for every single repository you are planning to deploy.</p><p>To configure this, you need a few key components, starting with a Workload Identity Pool that accepts token generated by GitHub. The following Terraform snippet creates one exactly as we need it:</p><pre># This is needed because a Workload Identity Pool<br># cannot be deleted once created, so if you happen to<br># deploy something incorrectly and find yourself having<br># to delete the pool, you won&#39;t be able to deploy this module<br># anymore unless you change its name manually.<br>resource &quot;random_id&quot; &quot;pool_id&quot; {<br>  byte_length = 3<br>}<br><br># This creates the Workload Identity Pool.<br>resource &quot;google_iam_workload_identity_pool&quot; &quot;github_wip&quot; {<br>  project                   = &quot;&lt;GCP_PROJECT&gt;&quot;<br>  workload_identity_pool_id = &quot;${random_id.pool_id.hex}-${var.pool_id}&quot;<br>  display_name              = &quot;My Workload Identity Pool&quot;<br>  description               = &quot;A Workload Identity Pool to authenticate from GitHub Actions&quot;<br>  disabled                  = false<br>}<br><br># This adds a provider to the WIP created above,<br># which accepts token issued by GitHub for GitHub Actions.<br>resource &quot;google_iam_workload_identity_pool_provider&quot; &quot;github_wip_provider&quot; {<br>  project = &quot;&lt;GCP_PROJECT&gt;&quot;<br>  provider = google<br>  workload_identity_pool_provider_id = &quot;github-provider&quot;<br>  workload_identity_pool_id = google_iam_workload_identity_pool.github_wip.workload_identity_pool_id<br>  oidc {<br>    issuer_uri = &quot;https://token.actions.githubusercontent.com&quot;<br>  }<br><br>  # This block maps attributes from the GitHub token<br>  # within Google Cloud. This allows to control permissions<br>  # more granularly, being able to identify the repository<br>  # and the actor that triggered the action.<br>  attribute_mapping = {<br>    &quot;google.subject&quot; = &quot;assertion.sub&quot;<br>    &quot;attribute.actor&quot; = &quot;assertion.actor&quot;<br>    &quot;attribute.repository&quot;       = &quot;assertion.repository&quot;<br>    &quot;attribute.repository_owner&quot; = &quot;assertion.repository_owner&quot;<br>  }<br>  <br>  # This allows to restrict tokens that are part<br>  # of a specific organization. It is recommended<br>  # to have at least one filter to prevent any GitHub Action<br>  # from authenticating to your Google Cloud organization.<br>  attribute_condition = &quot;attribute.repository_owner == &#39;&lt;YOUR_GITHUB_ORG&gt;&#39;&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgJbwFCAgL41FsEyGtXAuA.png" /><figcaption>A Workload Identity Pool deployed using the snippet above.</figcaption></figure><p>Workflows authenticated using this pool can be identified using a principalSet, which represent a group of identities. In simple words, it’s a URL-like string that contains a bunch of information about your Google project, the Workload Identity Pool name and details about the repository:</p><pre><br>principalSet://iam.googleapis.com/projects/&lt;GCP_PROJECT_NUMBER&gt;/locations/global/workloadIdentityPools/&lt;POOL_ID&gt;/attribute.repository/&lt;YOUR_GITHUB_ORG&gt;/&lt;YOUR_GITHUB_REPO&gt;</pre><p>You can retrieve the first part of the identifier in the “IAM Principal” field of the Workload Identity Pool on the Google Cloud dashboard. It will also be returned by Terraform when applying the snippet above.</p><p>You should then determine how you’d like to identify your tokens. In the example above, we’re using attribute.repository which will contain the full repository name in the form of YOUR_GITHUB_ORG/YOUR_GITHUB_REPO. It is important that whatever you decide to use here is also present in the attribute_mapping block of the Workload Identity Pool provider.</p><p>Once you have this set up, authenticating from GitHub action is straightforward. You should first set up some permissions for to the workflow and then add the corresponding action:</p><pre>permissions:<br>  id-token: write<br>  contents: read</pre><pre>- name: Authenticate with GCP<br>  uses: &quot;google-github-actions/auth@v2&quot;<br>  with:<br>    project_id: &quot;&lt;GCP_PROJECT&gt;&quot;<br>    workload_identity_provider: &quot;&lt;WORKLOAD_IDENTITY_POOL_PROVIDER_ID&gt;&quot;</pre><p>You can retrieve the WORKLOAD_IDENTITY_POOL_PROVIDER_ID within the Terraform outputs, or by navigating to the Google Cloud dashboard. It will look something like this:</p><pre>projects/&lt;GCP_PROJECT_NUMBER&gt;/locations/global/workloadIdentityPools/&lt;POOL_ID&gt;/providers/github-provider</pre><p>If you’ve done everything correctly, this action should succeed, <strong>but you still won’t be able to publish anything to the Artifact Registry</strong>! This is because, while the GitHub Action can authenticate to Google Cloud, it won’t have the necessary permissions to publish images to the repository.</p><h4>Assigning permissions to the principalSet</h4><p>The principalSet we’ve seen above is what we’ll be using to identify GitHub Actions and assign them the correct permissions.</p><p>I’d recommend you take a note of the formed principalSet, because you will need it multiple times.</p><p>This Terraform snippet adds a new IAM member to an Artifact Registry repository:</p><pre>resource &quot;google_artifact_registry_repository_iam_member&quot; &quot;github_action&quot; {<br>  role = &quot;roles/artifactregistry.writer&quot;<br>  member = &quot;&lt;YOUR_PRINCIPAL_SET&gt;&quot;<br><br>  project = &quot;&lt;GCP_PROJECT&gt;&quot;<br>  location = &quot;&lt;GCP_REGION&gt;&quot;<br><br>  # I am assuming that you&#39;re adding this to the same<br>  # file where the Artifact Registry repo is defined.<br>  # If you&#39;re defining this in another file, make sure<br>  # to use the correct reference here.<br>  repository = google_artifact_registry_repository.my_service_repo.repository_id<br>}</pre><p>With this configuration, GitHub Actions that are part of the principalSet will be granted permissions to write new images on the repository.</p><h4>Testing the setup</h4><p>Now that permissions are configured correctly, if you run your GitHub workflow, it should be able to build and publish the image to your Artifact Registry repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5StRWWx-5OIdtDAwfLP5CA.png" /><figcaption>The Google Cloud dashboard showing a published Docker image on an Artifact Registry repository.</figcaption></figure><h4>But wait, we need more permissions!</h4><p>The GitHub Action is now able to publish images to the Artifact Registry, however it won’t be able to deploy the image to Cloud Run.</p><p><em>While you could technically just deploy the service from the Google Cloud dashboard, I’d assume you’d like to automate this part as well.</em></p><p>To grant this permission, you will need to modify the IAM members of the project where you’re deploying the Cloud Run service:</p><pre>resource &quot;google_project_iam_member&quot; &quot;this&quot; {<br>  project = &quot;&lt;GCP_PROJECT&gt;&quot;<br>  role = &quot;roles/run.admin&quot;<br>  member = &quot;&lt;YOUR_PRINCIPAL_SET&gt;&quot;<br>}</pre><p><em>Note: </em><em>roles/run.admin might be too permissive and it might not be allowed in strict organizations. However, it is the only role that has all the required permissions to deploy an unauthenticated service to Cloud Run. If you’re okay deploying behind Google Cloud authentication, then you can use </em><em>roles/run.developer. See </em><a href="https://cloud.google.com/run/docs/reference/iam/roles#permissions-required-for-the-deploying-services-revisions"><em>the official documentation</em></a><em> for further information.</em></p><h4>Now… let’s run it!</h4><p>As we finally have our Docker image published somewhere that Google can reach, we can now ask Cloud Run to run it.</p><p>This can be done in two ways:</p><ol><li>Configure and run the gcloud CLI tool within GitHub Actions.</li><li>Define a Terraform configuration for the service using a variable to identify its version and run terraform apply in GitHub Actions.</li></ol><p>Both ways are perfectly valid and there are no disadvantages to either. If you or your team are used to define Infrastructure-as-Code, you might find the Terraform setup more familiar.</p><h4>Deploy with gcloud</h4><p>This GitHub Action workflow deploys the image tagged with the value passed in input:</p><pre>name: Deploy Release<br><br>on:<br>  workflow_dispatch:<br>    inputs:<br>      tag_name:<br>        description: &quot;Tag name of the image&quot;<br>        required: true<br>        type: string<br><br>permissions:<br>  id-token: write<br>  contents: read<br><br>jobs:<br>  deploy-service:<br>    runs-on: ubuntu-latest<br>    environment: ${{ github.event.inputs.environment }}<br>    steps:<br>      - name: Authenticate with GCP<br>        uses: &quot;google-github-actions/auth@v2&quot;<br>        with:<br>          project_id: &quot;&lt;GCP_PROJECT&gt;&quot;<br>          workload_identity_provider: &quot;&lt;WORKLOAD_IDENTITY_POOL_PROVIDER_ID&gt;&quot;      <br><br>      - name: &quot;Set up Cloud SDK&quot;<br>        uses: &quot;google-github-actions/setup-gcloud@v2&quot;<br>      <br>      - name: &quot;Deploy to Cloud Run&quot;<br>        run: |<br>          gcloud run deploy &quot;&lt;SERVICE_NAME&gt;-&lt;SERVICE_ENVIRONMENT&gt;&quot; \<br>            --image &quot;&lt;GCP_REGION&gt;-docker.pkg.dev/&lt;GCP_PROJECT&gt;/&lt;ARTIFACT_REGISTRY_REPO_NAME&gt;/&lt;IMAGE_NAME&gt;:${{ github.event.inputs.tag_name }}&quot; \<br>            --project &quot;&lt;GCP_PROJECT&gt;&quot; \<br>            --region &quot;&lt;GCP_REGION&gt;&quot; \<br>            --port=8080 \<br>            --cpu 1 \<br>            --memory 1Gi \<br>            --min-instances=0 \<br>            --max-instances=1 \<br>            --concurrency=80 \<br>            --use-http2<br>            --allow-unauthenticated</pre><p>The command above makes some assumptions with values that you should definitely review:</p><ul><li>The principalSet that the GitHub Action belongs to should have access to the GCP_PROJECT where you’re deploying the Cloud Run service. You should also have configured the proper permissions, which we did before.</li><li>The Cloud Run service will forward requests to the port 8080 of the Docker image. <em>Your image should listen on </em><em>$PORT instead of a specific port (</em><a href="https://cloud.google.com/run/docs/configuring/services/containers#configure-port"><em>more info</em></a><em>).</em></li><li>If your service requires access to other Google Cloud resources, you may need to create a Service Account, grant the required roles, and pass it with --service-account=”&lt;GCP_SERVICE_ACCOUNT_EMAIL&gt;&quot; .</li><li>Your service works with 1 virtual CPU and 1GB of RAM.</li><li>Your service startup time is short enough to support downscaling to 0 instances. <em>You should always ensure that your service can start within less than 10–15 seconds: while Cloud Run won’t timeout before 5 minutes, if you’re deploying an </em><a href="https://cloud.google.com/api-gateway/docs"><em>API Gateway</em></a><em> in front of it, you will be constrained. Also, clients may also timeout if your service takes too long. If you can’t guarantee a fast startup, you should set the minimum number of instances to 1.</em></li><li>Your service can handle 80 concurrent requests. You should adjust this number based on real data, also depending on the hardware resources that you assign.</li><li>If your service requires arguments, you can pass them with --args=&quot;ARG1, ARG2&quot;.</li><li>If you need to pass credentials to your service, you can use --set-secrets=”&lt;SECRET_ENVIRONMENT_VARIABLE&gt;=&lt;SECRET_KEY&gt;:latest”.</li><li>You’re okay for this service to be reachable by anybody without authentication. <em>If you aren’t, remove the </em><em>--allow-unauthenticated option.</em></li></ul><p><em>For more information, refer to </em><a href="https://cloud.google.com/sdk/gcloud/reference/run/deploy"><em>the documentation</em></a><em> of the gcloud CLI.</em></p><h4>Deploy with Terraform</h4><p>You can easily define a Cloud Run resource using Terraform, but you will still need to determine the version of the image to deploy from the GitHub Action input. Luckily, this is pretty straightforward to do using <a href="https://developer.hashicorp.com/terraform/language/values/variables">Terraform Input Variables</a>.</p><p>First, start by defining the GitHub workflow:</p><pre>name: Deploy<br><br>on:<br>  workflow_dispatch:<br>    inputs:<br>      version:<br>        type: string<br>        description: The version to deploy (`vX.X.X`)<br>        required: true<br><br>permissions:<br>  id-token: write<br>  contents: write<br><br># This avoids running multiple deployments<br># at the same time, in case the same workflow<br># is started concurrently.<br># `cancel` should be set to `false` to ensure<br># Terraform is not interrupted as it may cause<br># the state to become corrupted.<br>concurrency:<br>  group: ${{ github.workflow }}<br>  cancel-in-progress: false<br><br>jobs:<br>  deploy:<br>    name: Deploy<br>    runs-on: ubuntu-latest<br>    env:<br>      IMAGE: &lt;GCP_REGION&gt;-docker.pkg.dev/&lt;GCP_PROJECT&gt;/&lt;ARTIFACT_REGISTRY_REPO_NAME&gt;/&lt;IMAGE_NAME&gt;:${{ github.event.inputs.tag_name }}<br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@v4<br><br>      - name: Set up Terraform<br>        uses: hashicorp/setup-terraform@v3<br>        with:<br>          terraform_version: &quot;1.11.2&quot;<br><br>      - name: Authenticate with GCP<br>        uses: &quot;google-github-actions/auth@v2&quot;<br>        with:<br>          project_id: &quot;&lt;GCP_PROJECT&gt;&quot;<br>          workload_identity_provider: &quot;&lt;WORKLOAD_IDENTITY_POOL_PROVIDER_ID&gt;&quot;<br><br>      - name: Terraform Init &amp; Validate<br>        working-directory: ./path/to/your/terraform/module<br>        run: |<br>          terraform init<br>          terraform validate<br><br>      - name: Run Terraform apply<br>        working-directory: ./path/to/your/terraform/module<br>        env:<br>          # This passes the GitHub Action token to Terraform,<br>          # so that it can be used to authenticate with Google Cloud<br>          # using the Workload Identity Pool we configured above.<br>          GITHUB_TOKEN: ${{ github.token }}<br>        run: |<br>          terraform apply -input=false -auto-approve -var=&quot;image=$IMAGE&quot;</pre><p>Then, configure a Terraform module as follows:</p><pre>resource &quot;google_cloud_run_v2_service&quot; &quot;my-test-service&quot; {<br>  name     = &quot;&lt;SERVICE_NAME&gt;-&lt;SERVICE_ENVIRONMENT&gt;&quot;<br>  project  = &quot;&lt;GCP_PROJECT&quot;<br>  location = &quot;&lt;GCP_REGION&gt;&quot;<br><br>  deletion_protection = true<br><br>  scaling {<br>    min_instance_count = 0<br>  }<br><br>  template {<br>    max_instance_request_concurrency = 80<br><br>    scaling {<br>      max_instance_count = 1<br>    }<br><br>    containers {<br>      # This will be retrieved from the variable<br>      # passed to Terraform apply<br>      image = var.image<br><br>      ports {<br>        container_port = 8080<br>      }<br><br>      resources {<br>        limits = {<br>          cpu    = 1<br>          memory = &quot;1Gi&quot;<br>        }<br>      }<br>    }<br>  }<br>}<br><br># This retrieves the policy required to<br># expose this service without authentication.<br># Remove this block and the one below,<br># if you don&#39;t want to expose the service directly.<br>data &quot;google_iam_policy&quot; &quot;noauth&quot; {<br>  binding {<br>    role = &quot;roles/run.invoker&quot;<br>    members = [<br>      &quot;allUsers&quot;,<br>    ]<br>  }<br>}<br><br>resource &quot;google_cloud_run_service_iam_policy&quot; &quot;noauth&quot; {<br>  location    = google_cloud_run_service.default.location<br>  project     = google_cloud_run_service.default.project<br>  service     = google_cloud_run_service.default.name<br><br>  policy_data = data.google_iam_policy.noauth.policy_data<br>}</pre><p><em>You can specify many more options, same as the ones you can give via </em><em>gcloud. For more information, refer to </em><a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_service"><em>the official documentation</em></a><em>.</em></p><h4>Testing the service</h4><p>Regardless of the deployment method, once the CI finishes successfully, your service will be assigned a URL that you can invoke immediately!</p><p><em>If you chose to deploy the service behind IAM authentication, you will need to authenticate your request, otherwise you’ll get a </em><em>401. You can retrieve your ID token, assuming you have </em><em>gcloud configured locally or access to a Cloud Shell, by running </em><em>gcloud auth print-identity-token.</em></p><h3>Closing words</h3><p>In this guide we’ve configured and deployed a service running within a Docker container on Google managed platform “Cloud Run”.</p><p>With Cloud Run, you can very easily deploy and maintain your services without having to worry about the infrastructure and with (<em>somewhat</em>) predictable costs based on how much traffic you receive.</p><p>̶A̶l̶t̶h̶o̶u̶g̶h̶ ̶t̶h̶i̶s̶ ̶i̶s̶ ̶n̶o̶t̶ ̶o̶f̶f̶i̶c̶i̶a̶l̶l̶y̶ ̶d̶i̶s̶c̶l̶o̶s̶e̶d̶,̶ ̶C̶l̶o̶u̶d̶ ̶R̶u̶n̶ ̶r̶u̶n̶s̶ ̶o̶n̶ ̶G̶o̶o̶g̶l̶e̶ ̶K̶u̶b̶e̶r̶n̶e̶t̶e̶s̶ ̶E̶n̶g̶i̶n̶e̶,̶ ̶s̶o̶ ̶y̶o̶u̶’̶r̶e̶ ̶g̶e̶t̶t̶i̶n̶g̶ ̶a̶l̶l̶ ̶t̶h̶e̶ ̶a̶d̶v̶a̶n̶t̶a̶g̶e̶s̶ ̶a̶n̶d̶ ̶s̶t̶a̶b̶i̶l̶i̶t̶y̶ ̶o̶f̶ ̶t̶h̶e̶ ̶p̶l̶a̶t̶f̶o̶r̶m̶ ̶w̶i̶t̶h̶o̶u̶t̶ ̶h̶a̶v̶i̶n̶g̶ ̶t̶o̶ ̶w̶o̶r̶r̶y̶ ̶a̶b̶o̶u̶t̶ ̶i̶t̶.̶</p><p>As some readers pointed out, Cloud Run uses Google’s internal orchestration system called “Borg” and not Kubernetes! In any case, you’re getting a very solid platform which <a href="https://research.google/pubs/large-scale-cluster-management-at-google-with-borg/">Google uses to run their own services</a>.</p><p>Cloud Run automatically assigns a public URL to your service, you might want to explore how to protect it. If you’re deploying an API, Google offers <a href="https://cloud.google.com/api-gateway/docs">API Gateway</a>, which integrates pretty well with Cloud Run.</p><p><em>Would you like a guide on how to use API Gateway with Cloud Run? Let me know in the comments!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a472331b130f" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/hey-google-run-this-docker-image-a472331b130f">Hey Google, run this Docker image</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>