Skip to main content

K8s

Script provisions a Google Kubernetes Engine (GKE) cluster, sets up the Kubernetes configuration, and deploys the Cert Manager using Helm.

  1. Google Kubernetes Engine Cluster:

    • Name: Defines the name of the GKE cluster as "care-gke".
    • Location: Specifies the location of the GKE cluster in the "asia-south1-c" zone.
    • Network: Specifies the VPC network named "care-vpc" for the cluster.
    • Subnetwork: Specifies the subnet for the cluster.
    • Initial Node Count: Sets the initial number of nodes to 2.
    • Deletion Protection: Disables deletion protection for the cluster.
    • Private Cluster Configuration: Disables private nodes and private endpoint for the cluster.
    • Node Configuration: Defines the machine type, disk size, disk type, and tags for the cluster nodes.
    • Lifecycle: Ignores changes to deletion protection.
  2. Setting Kubernetes Configuration:

    • A null_resource named "set_kubeconfig" is used to execute a local command to set up the Kubernetes configuration.
    • The gcloud container clusters get-credentials command is executed to fetch the credentials for the GKE cluster and update the Kubernetes configuration.
  3. Switching Kubernetes Context:

    • Another null_resource named "switch_kube_context" is used to execute a local command to switch the Kubernetes context.
    • The kubectl config use-context command is executed to set the current Kubernetes context to the GKE cluster context.
    • The KUBECONFIG environment variable is set to the path of the Kubernetes configuration file.
  4. Deploying Cert Manager with Helm:

    • A Helm chart named "cert-manager" is deployed into the "cert-manager" namespace.
    • The Helm repository URL is specified as "https://charts.jetstack.io".
    • The Helm release is configured to create the namespace if it does not exist.
    • Additional settings are applied to install Custom Resource Definitions (CRDs) for Cert Manager.
    • This deployment depends on the completion of switching the Kubernetes context to ensure that the correct context is used for Helm installation.

The script automates the setup of a GKE cluster, configures the Kubernetes context, and deploys Cert Manager for managing TLS certificates within the Kubernetes cluster.