K8s
Script provisions a Google Kubernetes Engine (GKE) cluster, sets up the Kubernetes configuration, and deploys the Cert Manager using Helm.
-
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.
-
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.
- A
-
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.
- Another
-
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.