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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕 [REQUEST] - output kubeconfig file for use #6

Closed
johncosta opened this issue Dec 1, 2023 · 1 comment
Closed

馃挕 [REQUEST] - output kubeconfig file for use #6

johncosta opened this issue Dec 1, 2023 · 1 comment
Labels
question Further information is requested

Comments

@johncosta
Copy link
Owner

johncosta commented Dec 1, 2023

Summary

Limitation
In version 0.0.3, if a user of the module wants to access the kubeconfig, there's some overhead they will need.

First, they'll need to create a local sensitive file.

resource "local_sensitive_file" "kubeconfig" {
  content  = module.k8s.cluster_kube_config.0.raw_config
  filename = "/full/path/to/.kube/${module.k8s.cluster_name}-config.yml"
}

Second, they'll need to output the values for use.

output "cluster_kubeconfig_path" {
  value = local_sensitive_file.kubeconfig.filename
}

output "cluster_kubeconfig_path_export" {
  value = "export KUBECONFIG=${local_sensitive_file.kubeconfig.filename}"
}

Value Statement
As a developer, I would like the kubeconfig file written to a specified directory and a convenience value for setting the KUBECONFIG environment variable.

Basic Example

module "k8s" {
  source  = "johncosta/kubernetes/digitalocean"
  version = "0.0.3"

  # cluster configuration
  cluster_name_prefix          = local.cluster_name_prefix
  cluster_region               = "nyc1"

  # convenience configuration
  path_to_kubeconfig      = "/Users/jcosta/.kube/"               # <--- new variable
  kubeconfig_filename    = "custom-name-of-config.yml" # <--- new variable
}
  1. a value of null (or unset) or "" will not write out the kubeconfig file
  2. setting the value will result in two additional outputs becoming available, cluster_kubeconfig_path which will be the full path to the kubeconfig file that includes the output filename, and cluster_kubeconfig_path_export which is a string value that can be cut and paste into one's environment to inform kubectl of the location.

Drawbacks

This is an initial representation of these values so there might be conditions that are unforseen.

Unresolved questions

No response

@johncosta johncosta added the question Further information is requested label Dec 1, 2023
johncosta added a commit that referenced this issue Dec 8, 2023
johncosta added a commit that referenced this issue Dec 9, 2023
@johncosta
Copy link
Owner Author

closed with: #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant