Provisioning a GKE Cluster Using Pulumi
Before you begin, make sure you have the following:
- Google Cloud Platform (GCP) account with appropriate permissions.
- Pulumi CLI installed. You can find installation instructions here.
- Go installed. You can find installation instructions here.
- Make sure to check Pulumi documentations
Google-Cloud-SDK
Then
1 | gcloud auth application-default login |
Pulumi Installation
New Project and stack name
- Create a new directory for your project: mkdir pulumi-gke-cluster
- Change into the project directory: cd pulumi-gke-cluster
- Initialize a new Pulumi project with Go: pulumi new gcp-go
- Select the desired project name and stack name when prompted.
This project name allows you to track your changes via the Pulumi Dashboard
In Pulumi, a stack name represents a unique identifier for a specific instance of your infrastructure. It helps you manage different configurations or variations of your infrastructure within a single Pulumi project.
When you create a new Pulumi stack, you provide a stack name to distinguish it from other stacks. The stack name can be any string that meets the naming requirements of your cloud provider.
For the first time, you will be promoted to enter your auth token which you can get by making a Pulumi account.
Commands
pulumi new <template>
- Description: Initializes a new Pulumi project from a template.
- Usage: pulumi new <template>
- Example: pulumi new gcp-go
pulumi stack select
- Description: Selects an existing Pulumi stack to work with.
- Usage: pulumi stack select <stack-name>
- Example: pulumi stack select dev-cluster
pulumi up
- Description: Deploys or updates the resources in the current Pulumi stack.
- Usage: pulumi up
- Example: pulumi up
pulumi destroy
- Description: Destroys all resources in the current stack.
- Usage: pulumi destroy
- Example: pulumi destroy
pulumi stack ls
- Description: Lists all the available stacks.
- Usage: pulumi stack ls
- Example: pulumi stack ls
pulumi config
- Description: Manages configuration values for the current stack.
- Usage:
pulumi config set <key> <value>
pulumi config get <key>
pulumi config rm <key> - Example:
pulumi config set gcpProject my-project-id
pulumi config get gcpProject
pulumi config rm gcpProject
pulumi stack export
- Description: Exports the current stack’s state to a file.
- Usage: pulumi stack export –file <filename>
- Example: pulumi stack export –file stack-state.json
pulumi stack import
- Description: Imports a stack’s state from a file.
- Usage: pulumi stack import –file <filename>
- Example: pulumi stack import –file stack-state.json
State Management
Pulumi state represents the current state of your infrastructure as managed by Pulumi. It includes resource information, configuration settings, and other relevant metadata.
Pulumi state is stored in a backend, which can be a local file, a cloud storage bucket (our case), or a remote state management service (e.g., Pulumi service, AWS S3, Azure Blob Storage, etc.).
Provisioning the Cluster
Voila! Our cluster
The NodePools
And the bucket
Pulumi Dashboard
Pulumi Dashboard helps you visualize your infrastructure and track changes over time. It also provides a convenient way to share your infrastructure with your team.
Code
Main.go
1 | package main |
Pulumi.yaml
1 | name: pcp8-390717 |
Pulumi.dev.yaml
1 | config: |
- Title: Provisioning a GKE Cluster Using Pulumi
- Author: ADM-MIDA0UI
- Created at: 2023-07-19 09:30:00
- Updated at: 2024-05-17 21:05:17
- Link: https://admida0ui.de/2023/07/19/pulumi/
- License: This work is licensed under CC BY-NC-SA 4.0.