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
- Ensure you have the Pulumi CLI installed. If not, follow the installation guide.
- Set up your Pulumi project using TypeScript:
pulumi new typescript
- Configure your Google Cloud credentials. You can set the
GOOGLE_CLOUD_PROJECT
environment variable or use thegcloud
CLI to authenticate.
Step 2: Define the CloudRun Service
- Install the Pulumi GCP package:
npm install @pulumi/gcp
- 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
- Run
pulumi up
to deploy your CloudRun service:pulumi up
- 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 upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.