tofu fmt, fixes in the readme
This commit is contained in:
parent
524c8d217f
commit
b19f7f7cbc
37
README.md
37
README.md
|
@ -1,33 +1,38 @@
|
|||
# How to use
|
||||
# How to use repo
|
||||
|
||||
1. Create *.tfvars file with a few variables
|
||||
```
|
||||
1. Create `terraform.tfvars` file with a few variables
|
||||
```bash
|
||||
project = "gcp-project"
|
||||
region = "europe-west1"
|
||||
environment_name = "demo"
|
||||
```
|
||||
|
||||
2. Create cluster
|
||||
```
|
||||
terraform init
|
||||
terraform apply
|
||||
All commands will be applied via Terraform 1.7.0 and via OpenTofu, the same version.
|
||||
|
||||
Here are OpenTofu commands.
|
||||
```bash
|
||||
tofu init
|
||||
tofu apply
|
||||
```
|
||||
|
||||
3. Configure kubeconfig for new cluster
|
||||
3. Get the credentials for the new cluster (configure kubeconfig)
|
||||
|
||||
You can see all useful commands and links in the output:
|
||||
```bash
|
||||
tofu output
|
||||
```
|
||||
gcloud container clusters get-credentials $(terraform output -raw kubernetes_cluster_name) --region $(terraform output -raw region) --project $(terraform output -raw project)
|
||||
|
||||
There is a manual command:
|
||||
```bash
|
||||
gcloud container clusters get-credentials $(tofu output -raw kubernetes_cluster_name) --region $(tofu output -raw region) --project $(tofu output -raw project)
|
||||
```
|
||||
|
||||
4. Destroy all resources
|
||||
```
|
||||
terraform destroy -target 'kubernetes_namespace.flux-system'
|
||||
terraform destroy -target 'google_container_node_pool.primary_nodes'
|
||||
terraform destroy -target 'google_container_cluster.primary'
|
||||
terraform destroy -target 'google_compute_subnetwork.subnet'
|
||||
terraform destroy -target 'google_compute_network.vpc'
|
||||
terraform destroy -target 'data.google_client_config.primary'
|
||||
```
|
||||
|
||||
```bash
|
||||
tofu destroy
|
||||
```
|
||||
|
||||
<!-- BEGIN_TF_DOCS -->
|
||||
## Requirements
|
||||
|
|
8
gke.tf
8
gke.tf
|
@ -9,8 +9,10 @@ resource "google_container_cluster" "primary" {
|
|||
remove_default_node_pool = true
|
||||
initial_node_count = 1
|
||||
|
||||
network = google_compute_network.vpc.name
|
||||
subnetwork = google_compute_subnetwork.subnet.name
|
||||
network = google_compute_network.vpc.name
|
||||
subnetwork = google_compute_subnetwork.subnet.name
|
||||
deletion_protection = false # Use this only for study purposess
|
||||
depends_on = [google_compute_network.vpc, google_compute_subnetwork.subnet]
|
||||
# min_master_version = "1.26.5-gke.1200"
|
||||
}
|
||||
|
||||
|
@ -38,4 +40,6 @@ resource "google_container_node_pool" "primary_nodes" {
|
|||
disable-legacy-endpoints = "true"
|
||||
}
|
||||
}
|
||||
|
||||
depends_on = [google_container_cluster.primary]
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@ output "kubernetes_cluster_host" {
|
|||
|
||||
output "gcloud_gke_get_creds" {
|
||||
description = "Command to get GKE credentials"
|
||||
value = "gcloud container clusters get-credentials ${google_container_cluster.primary.name} --region ${var.region} --project ${var.project}"
|
||||
value = "gcloud container clusters get-credentials ${google_container_cluster.primary.name} --region ${var.region} --project ${var.project}"
|
||||
}
|
||||
|
||||
output "gcloud_vpc_link" {
|
||||
description = "VPC web ui link"
|
||||
value = "https://console.cloud.google.com/networking/networks/list?project=${var.project}"
|
||||
value = "https://console.cloud.google.com/networking/networks/list?project=${var.project}"
|
||||
}
|
||||
|
||||
output "gcloud_gke_link" {
|
||||
description = "GKE web ui link"
|
||||
value = "https://console.cloud.google.com/kubernetes/clusters/details/${var.region}/${var.project}-gke/details?project=${var.project}"
|
||||
value = "https://console.cloud.google.com/kubernetes/clusters/details/${var.region}/${var.project}-gke/details?project=${var.project}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue