mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-19 12:59:24 +00:00
✨ Improve SCW startup scripts and doc
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,6 +10,8 @@ prepare-scw/.terraform*
|
||||
prepare-scw/terraform.*
|
||||
prepare-scw/stage2/*.tf
|
||||
prepare-scw/stage2/kubeconfig.*
|
||||
prepare-scw/stage2/.terraform*
|
||||
prepare-scw/stage2/terraform.*
|
||||
prepare-scw/stage2/wildcard_dns.*
|
||||
|
||||
slides/*.yml.html
|
||||
|
||||
@@ -7,9 +7,10 @@ To use it:
|
||||
```bash
|
||||
scw init
|
||||
terraform init
|
||||
export TF_VAR_how_many_clusters=5
|
||||
export TF_VAR_nodes_per_cluster=2
|
||||
terraform apply
|
||||
cd stage2
|
||||
terraform init
|
||||
terraform apply
|
||||
```
|
||||
|
||||
Edit `variables.tf` to change the number of clusters.
|
||||
|
||||
@@ -2,7 +2,7 @@ terraform {
|
||||
required_providers {
|
||||
scaleway = {
|
||||
source = "scaleway/scaleway"
|
||||
version = "2.0.0"
|
||||
version = "2.1.0"
|
||||
}
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
|
||||
@@ -30,7 +30,7 @@ variable "pool_size" {
|
||||
|
||||
variable "pool_min_size" {
|
||||
type = number
|
||||
default = 1
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "pool_max_size" {
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
module "kapsule_cluster" {
|
||||
count = var.how_many_clusters
|
||||
source = "./kapsule_cluster"
|
||||
cluster_name = format("tf-%03d", count.index + 101)
|
||||
count = var.how_many_clusters
|
||||
source = "./kapsule_cluster"
|
||||
cluster_name = format("tf-%s-%03d", random_string.tag.result, count.index + 101)
|
||||
pool_size = var.nodes_per_cluster
|
||||
pool_min_size = var.nodes_per_cluster
|
||||
}
|
||||
|
||||
output "kubectl_config" {
|
||||
value = format("scw k8s kubeconfig install %s", split("/", module.kapsule_cluster.0.cluster_id)[1])
|
||||
}
|
||||
|
||||
resource "random_string" "tag" {
|
||||
length = 5
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "local_file" "stage2" {
|
||||
filename = "${path.module}/stage2/main.tf"
|
||||
content = templatefile(
|
||||
|
||||
@@ -2,7 +2,7 @@ terraform {
|
||||
required_providers {
|
||||
scaleway = {
|
||||
source = "scaleway/scaleway"
|
||||
version = "2.0.0"
|
||||
version = "2.1.0"
|
||||
}
|
||||
}
|
||||
required_version = ">= 0.14"
|
||||
|
||||
3
prepare-scw/purge-clusters.sh
Executable file
3
prepare-scw/purge-clusters.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
scw k8s cluster list -o json |
|
||||
jq -r '.[] | select(.status=="'${STATE-creating}'") | .id' | xargs -n1 scw k8s cluster delete
|
||||
@@ -2,3 +2,8 @@ variable "how_many_clusters" {
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "nodes_per_cluster" {
|
||||
type = number
|
||||
default = 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user