Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add both kubeconfig path/file vars to tfvars.example files #173

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions recipes/upstream/aws/k3s/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
locals {
kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd
kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml"
kc_file_backup = "${local.kc_file}.backup"
kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd
kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml"
}

module "k3s_first" {
Expand Down Expand Up @@ -90,13 +89,13 @@ resource "ssh_resource" "retrieve_kubeconfig" {
}

resource "local_file" "kube_config_yaml" {
filename = local.kc_file
filename = pathexpand(local.kc_file)
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}

resource "local_file" "kube_config_yaml_backup" {
filename = local.kc_file_backup
filename = pathexpand("${local.kc_file}.backup")
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}
Expand Down
5 changes: 3 additions & 2 deletions recipes/upstream/aws/k3s/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ create_ssh_key_pair = true
# ssh_key_pair_path = "/path/to/private/key.pem"
#####

## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path
# kube_config_path = "~/.kube/rancher-terraform.yml"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"
1 change: 0 additions & 1 deletion recipes/upstream/aws/rke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module "rke" {
kube_config_path = var.kube_config_path
kube_config_filename = var.kube_config_filename
kubernetes_version = var.kubernetes_version

}

locals {
Expand Down
5 changes: 3 additions & 2 deletions recipes/upstream/aws/rke/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ create_ssh_key_pair = true
# ssh_key_pair_path = "/path/to/private/key.pem"
#####

## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path
# kube_config_path = "~/.kube/rancher-terraform.yml"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"
9 changes: 4 additions & 5 deletions recipes/upstream/aws/rke2/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
locals {
kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd
kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml"
kc_file_backup = "${local.kc_file}.backup"
kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd
kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml"
}

module "rke2_first" {
Expand Down Expand Up @@ -71,13 +70,13 @@ resource "ssh_resource" "retrieve_kubeconfig" {
}

resource "local_file" "kube_config_yaml" {
filename = local.kc_file
filename = pathexpand(local.kc_file)
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}

resource "local_file" "kube_config_yaml_backup" {
filename = local.kc_file_backup
filename = pathexpand("${local.kc_file}.backup")
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}
Expand Down
5 changes: 3 additions & 2 deletions recipes/upstream/aws/rke2/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ create_ssh_key_pair = true
# ssh_key_pair_path = "/path/to/private/key.pem"
#####

## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path
# kube_config_path = "~/.kube/rancher-terraform.yml"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"
5 changes: 3 additions & 2 deletions recipes/upstream/digitalocean/rke/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
# If 'create_ssh_key_pair' is set to false, give the name of an ssh key on DigitalOcean
# ssh_key_pair_name = "terraform"

# Filepath to the private ssh key to be uploaded or already existing on DigitalOcean
# ssh_key_pair_path = "~/.ssh/terraform"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"

# DigitalOcean authentication token
# do_token = ""
Expand Down
6 changes: 2 additions & 4 deletions recipes/upstream/google-cloud/k3s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,9 @@ resource "ssh_resource" "retrieve_kubeconfig" {
}

resource "local_file" "kube_config_yaml" {
depends_on = [ssh_resource.retrieve_kubeconfig]

filename = local.kc_file
file_permission = "0600"
filename = pathexpand(local.kc_file)
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}

provider "kubernetes" {
Expand Down
8 changes: 3 additions & 5 deletions recipes/upstream/google-cloud/k3s/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ ssh_username = "ubuntu"
## -- K3s custom config file
# k3s_config = "<K3s_CONFIG_FILE>"

## -- K3s KUBECONFIG file path
# kube_config_path = "<KUBE_CONFIG_PATH>"

## -- K3s KUBECONFIG file
# kube_config_filename = "<KUBE_CONFIG_FILENAME>"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"

## -- Bootstrap the Rancher installation
# bootstrap_rancher = false
Expand Down
6 changes: 2 additions & 4 deletions recipes/upstream/google-cloud/rke2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,9 @@ resource "ssh_resource" "retrieve_kubeconfig" {
}

resource "local_file" "kube_config_yaml" {
depends_on = [ssh_resource.retrieve_kubeconfig]

filename = local.kc_file
file_permission = "0600"
filename = pathexpand(local.kc_file)
content = ssh_resource.retrieve_kubeconfig.result
file_permission = "0600"
}

provider "kubernetes" {
Expand Down
8 changes: 3 additions & 5 deletions recipes/upstream/google-cloud/rke2/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ ssh_username = "ubuntu"
## -- RKE2 custom config file
# rke2_config = "<RKE2_CONFIG_FILE>"

## -- RKE2 KUBECONFIG file path
# kube_config_path = "<KUBE_CONFIG_PATH>"

## -- RKE2 KUBECONFIG file
# kube_config_filename = "<KUBE_CONFIG_FILENAME>"
## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename
# kube_config_path = "~/.kube"
# kube_config_filename = "rancher-terraform.yml"

## -- Bootstrap the Rancher installation
# bootstrap_rancher = false
Expand Down