Skip to content

Commit

Permalink
Add an example of customized kubeconfig
Browse files Browse the repository at this point in the history
Fixes #144
  • Loading branch information
xunleii committed Nov 11, 2023
1 parent ab545ba commit 254f7f4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,47 @@ module "k3s" {
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |
<!-- END_TF_DOCS -->

## 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.

Expand Down

0 comments on commit 254f7f4

Please sign in to comment.