Deploy the pi-hole helm chart on Google Kubernetes Engine (GKE)
TypeScriptTo deploy the Pi-hole Helm chart on Google Kubernetes Engine (GKE), you need to follow these steps:
-
Create a GKE cluster: You need to have a running GKE cluster where you'll be deploying your Pi-hole Helm chart. A GKE cluster consists of at least one control plane and multiple worker nodes.
-
Install Helm: Helm is a package manager for Kubernetes that allows you to manage Kubernetes applications. Helm charts help you define, install, and upgrade even the most complex Kubernetes applications.
-
Deploy Pi-hole Helm chart: Once you have Helm installed, you can then deploy the Pi-hole application onto your GKE cluster using the appropriate Helm chart.
Below is a Pulumi TypeScript program that sets up a GKE cluster and deploys Pi-hole using Helm:
import * as pulumi from "@pulumi/pulumi"; import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create the GKE cluster const cluster = new gcp.container.Cluster("pi-hole-cluster", { initialNodeCount: 2, minMasterVersion: "latest", nodeVersion: "latest", location: "us-central1-a", nodeConfig: { machineType: "n1-standard-1", oauthScopes: [ "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring", ], }, }); // Export the Cluster name export const clusterName = cluster.name; // Step 2: Configure K8s provider to use the GKE cluster const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: cluster.endpoint.apply(endpoint => { return cluster.name.apply(name => { return cluster.masterAuth.apply(masterAuth => { const context = `${gcp.config.project}_${gcp.config.zone}_${name}`; return `apiVersion: v1 clusters: - cluster: certificate-authority-data: ${masterAuth.clusterCaCertificate} server: https://${endpoint} name: ${context} contexts: - context: cluster: ${context} user: ${context} name: ${context} current-context: ${context} kind: Config preferences: {} users: - name: ${context} user: auth-provider: config: cmd-args: config config-helper --format=json cmd-path: gcloud expiry-key: '{.credential.token_expiry}' token-key: '{.credential.access_token}' name: gcp `; }); }); }), }); // Step 3: Create the Helm Release for Pi-hole const piHole = new k8s.helm.v3.Release("pi-hole", { chart: "pihole", version: "1.8.17", // Use the version of Pi-hole that you want to deploy namespace: "default", // Replace with the namespace where you want to install Pi-hole }, { provider: k8sProvider }); // Export the Pi-hole Helm chart release status export const piHoleStatus = piHole.status;
Explanation of the resources used:
-
gcp.container.Cluster
: This resource creates a GKE cluster. The parameters include the desired number of nodes (initialNodeCount
) and the machine type for each node (machineType
). Adjust themachineType
andinitialNodeCount
as needed. -
k8s.Provider
: This resource is used to interact with the newly created GKE cluster. It's configured withkubeconfig
which is derived from the cluster endpoint and authentication data. -
k8s.helm.v3.Release
: This resource represents a Helm chart deployment. It's used to deploy the Pi-hole application on the GKE cluster.
For more information on these resources, you can refer to the official Pulumi documentation for GCP and Kubernetes.
Keep in mind that the actual version of the
pihole
Helm chart and the namespace can change, so you should specify the appropriate version and namespace for your deployment. Additionally, this program assumes that you've already set up Pulumi, GCP credentials, and Helm locally. The actual deployment of the Pi-hole Helm chart may require additional configuration specific to Pi-hole, such as setting up a LoadBalancer with a static IP for the DNS service.-