1. Answers
  2. Deploy The Zabbix/zabbix-db-mysql Docker Image On Google CloudRun With TypeScript.

Deploy the Zabbix/Zabbix-Db-Mysql Docker Image on Google CloudRun With TypeScript.

Introduction

In this guide, we will deploy the zabbix/zabbix-db-mysql Docker image on Google CloudRun using Pulumi with TypeScript. Google CloudRun is a managed compute platform that automatically scales your stateless containers. Pulumi allows us to define and manage our cloud resources using code.

Step-by-Step Explanation

Step 1: Set Up Pulumi and Google Cloud

  1. Ensure you have the Pulumi CLI installed. If not, follow the installation guide.
  2. Set up your Pulumi project using TypeScript:
    pulumi new typescript
    
  3. Configure your Google Cloud credentials. You can set the GOOGLE_CLOUD_PROJECT environment variable or use the gcloud CLI to authenticate.

Step 2: Define the CloudRun Service

  1. Install the Pulumi GCP package:
    npm install @pulumi/gcp
    
  2. Create a new file, index.ts, and define your CloudRun service:
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const location = "us-central1";
    const image = "zabbix/zabbix-db-mysql";
    
    const service = new gcp.cloudrun.Service("zabbix-db-mysql", {
        location: location,
        template: {
            spec: {
                containers: [{
                    image: image,
                    ports: [{ containerPort: 3306 }],
                    envs: [
                        { name: "MYSQL_ROOT_PASSWORD", value: "yourpassword" },
                        { name: "MYSQL_DATABASE", value: "zabbix" },
                        { name: "MYSQL_USER", value: "zabbix" },
                        { name: "MYSQL_PASSWORD", value: "zabbixpassword" },
                    ],
                }],
            },
        },
    });
    
    export const url = service.statuses.apply(statuses => statuses[0].url);
    

Step 3: Deploy the Service

  1. Run pulumi up to deploy your CloudRun service:
    pulumi up
    
  2. Confirm the deployment and note the URL of your new service.

Summary

In this guide, we deployed the zabbix/zabbix-db-mysql Docker image on Google CloudRun using Pulumi with TypeScript. We set up the Pulumi project, defined the CloudRun service, and deployed it. Pulumi makes it easy to manage cloud resources using code, and Google CloudRun provides a scalable platform for running containerized applications.

Full Code Example

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const location = "us-central1";
const image = "zabbix/zabbix-db-mysql";

const service = new gcp.cloudrun.Service("zabbix-db-mysql", {
    location: location,
    template: {
        spec: {
            containers: [{
                image: image,
                ports: [{ containerPort: 3306 }],
                envs: [
                    { name: "MYSQL_ROOT_PASSWORD", value: "yourpassword" },
                    { name: "MYSQL_DATABASE", value: "zabbix" },
                    { name: "MYSQL_USER", value: "zabbix" },
                    { name: "MYSQL_PASSWORD", value: "zabbixpassword" },
                ],
            }],
        },
    },
});

export const url = service.statuses.apply(statuses => statuses[0].url);

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up