From 254f7f4b33f26deea790e34aedf7a01964ab90ed Mon Sep 17 00:00:00 2001 From: Alexandre Nicolaie Date: Sat, 11 Nov 2023 14:11:29 +0100 Subject: [PATCH] Add an example of customized `kubeconfig` Fixes #144 --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index ff3fc7b..55e7429 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,47 @@ module "k3s" { | [tls](#provider\_tls) | 4.0.4 | +## Frequently Asked Questions + +### How to customise the generated `kubeconfig` + +It is sometimes necessary to modify the context or the cluster name to adapt `kubeconfig` to a third-party tool or to avoid conflicts with existing tools. Although this is not the role of this module, it can easily be done with its outputs : + +```hcl +module "k3s" { + ... +} + +local { + kubeconfig = yamlencode({ + apiVersion = "v1" + kind = "Config" + current-context = "my-context-name" + contexts = [{ + context = { + cluster = "my-cluster-name" + user : "my-user-name" + } + name = "my-context-name" + }] + clusters = [{ + cluster = { + certificate-authority-data = base64encode(module.k3s.kubernetes.cluster_ca_certificate) + server = module.k3s.kubernetes.api_endpoint + } + name = "my-cluster-name" + }] + users = [{ + user = { + client-certificate-data : base64encode(module.k3s.kubernetes.client_certificate) + client-key-data : base64encode(module.k3s.kubernetes.client_key) + } + name : "my-user-name" + }] + }) +} +``` + ## License `terraform-module-k3s` is released under the **MIT License**. See the bundled [LICENSE](LICENSE) file for details.