-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: data source -> resource
talos_cluster_kubeconfig
Move `talos_cluster_kubeconfig` data source to a resource so that kubernetes client certs can be regenerated when nearing expiry. Fixes: #155 Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
Showing
12 changed files
with
812 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
page_title: "talos_cluster_kubeconfig Resource - talos" | ||
subcategory: "" | ||
description: |- | ||
Retrieves the kubeconfig for a Talos cluster | ||
--- | ||
|
||
# talos_cluster_kubeconfig (Resource) | ||
|
||
Retrieves the kubeconfig for a Talos cluster | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "talos_machine_secrets" "this" {} | ||
data "talos_machine_configuration" "this" { | ||
cluster_name = "example-cluster" | ||
machine_type = "controlplane" | ||
cluster_endpoint = "https://cluster.local:6443" | ||
machine_secrets = talos_machine_secrets.this.machine_secrets | ||
} | ||
data "talos_client_configuration" "this" { | ||
cluster_name = "example-cluster" | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
nodes = ["10.5.0.2"] | ||
} | ||
resource "talos_machine_configuration_apply" "this" { | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
machine_configuration_input = data.talos_machine_configuration.this.machine_configuration | ||
node = "10.5.0.2" | ||
config_patches = [ | ||
yamlencode({ | ||
machine = { | ||
install = { | ||
disk = "/dev/sdd" | ||
} | ||
} | ||
}) | ||
] | ||
} | ||
resource "talos_machine_bootstrap" "this" { | ||
depends_on = [ | ||
talos_machine_configuration_apply.this | ||
] | ||
node = "10.5.0.2" | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
} | ||
resource "talos_cluster_kubeconfig" "this" { | ||
depends_on = [ | ||
talos_machine_bootstrap.this | ||
] | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
node = "10.5.0.2" | ||
} | ||
``` | ||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `client_configuration` (Attributes) The client configuration data (see [below for nested schema](#nestedatt--client_configuration)) | ||
- `node` (String) controlplane node to retrieve the kubeconfig from | ||
|
||
### Optional | ||
|
||
- `endpoint` (String) endpoint to use for the talosclient. If not set, the node value will be used | ||
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `kubeconfig_raw` (String, Sensitive) The raw kubeconfig | ||
- `kubernetes_client_configuration` (Attributes) The kubernetes client configuration (see [below for nested schema](#nestedatt--kubernetes_client_configuration)) | ||
|
||
<a id="nestedatt--client_configuration"></a> | ||
### Nested Schema for `client_configuration` | ||
|
||
Required: | ||
|
||
- `ca_certificate` (String) The client CA certificate | ||
- `client_certificate` (String) The client certificate | ||
- `client_key` (String, Sensitive) The client key | ||
|
||
|
||
<a id="nestedatt--timeouts"></a> | ||
### Nested Schema for `timeouts` | ||
|
||
Optional: | ||
|
||
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). | ||
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). | ||
|
||
|
||
<a id="nestedatt--kubernetes_client_configuration"></a> | ||
### Nested Schema for `kubernetes_client_configuration` | ||
|
||
Read-Only: | ||
|
||
- `ca_certificate` (String) The kubernetes CA certificate | ||
- `client_certificate` (String) The kubernetes client certificate | ||
- `client_key` (String, Sensitive) The kubernetes client key | ||
- `host` (String) The kubernetes host | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
resource "talos_machine_secrets" "this" {} | ||
|
||
data "talos_machine_configuration" "this" { | ||
cluster_name = "example-cluster" | ||
machine_type = "controlplane" | ||
cluster_endpoint = "https://cluster.local:6443" | ||
machine_secrets = talos_machine_secrets.this.machine_secrets | ||
} | ||
|
||
data "talos_client_configuration" "this" { | ||
cluster_name = "example-cluster" | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
nodes = ["10.5.0.2"] | ||
} | ||
|
||
resource "talos_machine_configuration_apply" "this" { | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
machine_configuration_input = data.talos_machine_configuration.this.machine_configuration | ||
node = "10.5.0.2" | ||
config_patches = [ | ||
yamlencode({ | ||
machine = { | ||
install = { | ||
disk = "/dev/sdd" | ||
} | ||
} | ||
}) | ||
] | ||
} | ||
|
||
resource "talos_machine_bootstrap" "this" { | ||
depends_on = [ | ||
talos_machine_configuration_apply.this | ||
] | ||
node = "10.5.0.2" | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
} | ||
|
||
|
||
resource "talos_cluster_kubeconfig" "this" { | ||
depends_on = [ | ||
talos_machine_bootstrap.this | ||
] | ||
client_configuration = talos_machine_secrets.this.client_configuration | ||
node = "10.5.0.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.