Difference between revisions of "Deploy GKE cluster using Terraform"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
 
* https://github.com/hashicorp/learn-terraform-provision-gke-cluster
 
* https://github.com/hashicorp/learn-terraform-provision-gke-cluster
  
 +
Resources:
 +
+ resource "[[google_compute_network]]" "vpc" {
 +
+ resource "[[google_compute_subnetwork]]" "subnet" {
 +
+ resource "[[google_container_cluster]]" "primary" {
 +
+ resource "[[google_container_node_pool]]" "primary_nodes" {
 +
 +
== Execution ==
 
  [[git clone]] https://github.com/hashicorp/learn-terraform-provision-gke-cluster
 
  [[git clone]] https://github.com/hashicorp/learn-terraform-provision-gke-cluster
 
  cd learn-terraform-provision-gke-cluster
 
  cd learn-terraform-provision-gke-cluster

Revision as of 20:58, 4 December 2023

Resources:

+ resource "google_compute_network" "vpc" {
+ resource "google_compute_subnetwork" "subnet" {
+ resource "google_container_cluster" "primary" {
+ resource "google_container_node_pool" "primary_nodes" {

Execution

git clone https://github.com/hashicorp/learn-terraform-provision-gke-cluster
cd learn-terraform-provision-gke-cluster
terraform init

Change project_id in terraform.tfvar file with name of your cluster. (See: gcloud projects create)

Terraform plan (GKE)

terraform plan (GKE) (2022)
terraform plan (GKE) (2023)
terraform plan (GKE) Error: Error retrieving available container cluster versions
 terraform plan | grep -w resource
 + resource "google_compute_network" "vpc" {
 + resource "google_compute_subnetwork" "subnet" {
 + resource "google_container_cluster" "primary" {
 + resource "google_container_node_pool" "primary_nodes" {

Terraform apply =

terraform apply
.../... 
Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

Outputs: 

kubernetes_cluster_host = "22.27.74.22"
kubernetes_cluster_name = "your-project-gke"
project_id = "your-project"
region = "us-central1"

Configure credentials to connect:

gcloud container clusters get-credentials $(terraform output -raw kubernetes_cluster_name) --region $(terraform output -raw region)
kubectl get pod -A

Related

See als

Advertising: