Setting up GCP and GKE using OpenTofu
This guide walks you through configuring Google Cloud Platform (GCP) and Google Kubernetes Engine (GKE) in nullplatform using OpenTofu/Terraform®.
Prerequisites
Before you begin, ensure you have:
- OpenTofu or Terraform® installed
- access to a Google Cloud Platform account
- Istio installed on your GKE cluster
- nullplatform API key for our custom provider
Configuration
Create a file named nullplatform_gcp_gke_config.tf
with the following content:
# Configure the nullplatform provider
terraform {
required_providers {
nullplatform = {
source = "nullplatform/nullplatform"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.5.0"
}
}
}
provider "nullplatform" {
api_key = "your-api-key"
}
# Install nullplatform Helm chart
resource "helm_release" "nullplatform_gke_release" {
name = "nullplatform-release"
repository = "https://nullplatform.github.io/helm-charts/charts"
chart = "nullplatform-chart"
set {
name = "global.provider"
value = "gke"
}
set {
name = "tls.secretName"
value = "www-tls"
}
set {
name = "metrics-server.enabled"
value = "false"
}
set {
name = "imagePullSecrets.enabled"
value = "true"
}
set {
name = "imagePullSecrets.name"
value = "image-pull-secret-nullplatform"
}
set {
name = "imagePullSecrets.registry"
value = "your-registry-url"
}
set {
name = "imagePullSecrets.username"
value = "your-username"
}
set {
name = "imagePullSecrets.password"
value = "your-password"
}
# Add any other necessary configurations here
}
# Configure Google Cloud Platform (GCP)
resource "nullplatform_provider_config" "gcp-configuration" {
account = "example-account"
type = "gcp-configuration"
dimensions = { environment = "example-environment" }
attributes = jsonencode({
"project": {
"id": "my-gcp-project"
},
"networking": {
"domain_name": "example.com",
"public_dns_zone_name": "example-com",
"private_dns_zone_name": "internal-example"
},
"authentication": {
"credential_base_64": "eyAi... (base64 string) ...IiB9"
}
})
depends_on = [helm_release.nullplatform_gke_release]
}
# Configure Google Kubernetes Engine (GKE)
resource "nullplatform_provider_config" "gke-configuration" {
account = "example-account"
type = "gke-configuration"
dimensions = {
environment = "example-environment"
}
attributes = jsonencode({
"cluster": {
"id": "my-gke-cluster",
"location": "us-central1",
"namespace": "my-namespace"
},
"gateway": {
"namespace": "my-namespace",
"public_name": "public-gateway",
"private_name": "private-gateway"
}
})
depends_on = [nullplatform_provider_config.gcp-configuration]
}
Deployment steps
-
Replace all placeholder values in the configuration file with your actual details
-
Initialize OpenTofu/Terraform:
- OpenTofu
- Terraform
tofu init
terraform init
-
If you're importing existing resources, use the import command:
- OpenTofu
- Terraform
tofu import nullplatform_provider_config.gcp-configuration <existing-resource-id>
tofu import nullplatform_provider_config.gke-configuration <existing-resource-id>terraform import nullplatform_provider_config.gcp-configuration <existing-resource-id>
terraform import nullplatform_provider_config.gke-configuration <existing-resource-id>Replace
<existing-resource-id>
with the actual resource IDs from your nullplatform account. -
Review the planned changes:
- OpenTofu
- Terraform
tofu plan
terraform plan
-
Apply the configuration:
- OpenTofu
- Terraform
tofu apply
terraform apply
-
Confirm the changes by typing
yes
when prompted
Conclusion
You have now set up your Google Cloud Platform and Google Kubernetes Engine configurations in nullplatform using OpenTofu/Terraform. This process includes:
- installing the nullplatform Helm chart with image pull secrets configuration
- configuring the GCP provider
- configuring the GKE provider
Remember to keep your nullplatform_gcp_gke_config.tf
file secure, as it contains sensitive information.
Terraform® is a registered trademark of HashiCorp, Inc.