|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "k3d_cluster_create Resource - terraform-provider-k3d" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +# k3d_cluster_create (Resource) |
| 10 | +Creates a k3d cluster with all below passed configuration by leveraging k3d golang [code](github.com/k3d-io/k3d/v5). |
| 11 | +The below attributes are terraform translated k3d [config.yaml](https://k3d.io/v5.4.7/usage/configfile/) which would used while creating cluster via cli `k3d cluster create --config /path/to/cluster-config.yaml`. |
| 12 | + |
| 13 | +```terraform |
| 14 | +resource "k3d_cluster_create" "sample_cluster" { |
| 15 | + name = "default" |
| 16 | + servers_count = 1 |
| 17 | + agents_count = 2 |
| 18 | + // image = "rancher/k3s:v1.24.4-k3s1" |
| 19 | + kube_api { |
| 20 | + host_ip = "0.0.0.0" |
| 21 | + host_port = 6445 |
| 22 | + } |
| 23 | + // |
| 24 | + // ports { |
| 25 | + // host_port = 8080 |
| 26 | + // container_port = 80 |
| 27 | + // node_filters = [ |
| 28 | + // "loadbalancer", |
| 29 | + // ] |
| 30 | + // } |
| 31 | +
|
| 32 | + k3d_options { |
| 33 | + no_loadbalancer = false |
| 34 | + no_image_volume = false |
| 35 | + } |
| 36 | +
|
| 37 | + kube_config { |
| 38 | + update_default = true |
| 39 | + switch_context = true |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +<!-- schema generated by tfplugindocs --> |
| 47 | +## Schema |
| 48 | + |
| 49 | +### Optional |
| 50 | + |
| 51 | +- `agents_count` (Number) Count of agents in the cluster |
| 52 | +- `cluster_token` (String, Sensitive) superSecretToken to be used |
| 53 | +- `config_yaml` (String) |
| 54 | +- `env` (Block Set) Environment variables to be added nodes. (see [below for nested schema](#nestedblock--env)) |
| 55 | +- `host_aliases` (Block Set) /etc/hosts style entries to be injected into /etc/hosts in the node containers and in the NodeHosts section in CoreDNS. (see [below for nested schema](#nestedblock--host_aliases)) |
| 56 | +- `image` (String) Image name to be used for creation of cluster, it would be used along with kubernetes_version |
| 57 | +- `k3d_options` (Block Set) k3d runtime settings (see [below for nested schema](#nestedblock--k3d_options)) |
| 58 | +- `k3s_options` (Block Set) Options passed on to K3s itself (see [below for nested schema](#nestedblock--k3s_options)) |
| 59 | +- `kube_api` (Block Set, Max: 1) same as `--api-port myhost.my.domain:6445` (where the name would resolve to 127.0.0.1) (see [below for nested schema](#nestedblock--kube_api)) |
| 60 | +- `kube_config` (Block Set) Way to manage the kubeconfig generated after creating k3d clusters. (see [below for nested schema](#nestedblock--kube_config)) |
| 61 | +- `name` (String) Name of the Cluster to be created |
| 62 | +- `network` (String) Network to be associated with the cluster |
| 63 | +- `ports` (Block Set) Map ports from the node containers (via the serverlb) to the host (Format: [HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]) (see [below for nested schema](#nestedblock--ports)) |
| 64 | +- `registries` (Block Set) Define how registries should be created or used (see [below for nested schema](#nestedblock--registries)) |
| 65 | +- `runtime` (Block Set, Max: 1) Runtime options for k3d (see [below for nested schema](#nestedblock--runtime)) |
| 66 | +- `servers_count` (Number) Count of servers |
| 67 | +- `subnetwork` (String) Define a subnet for the newly created container network |
| 68 | +- `volumes` (Block Set) Mount volumes into the nodes (Format: [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]] (see [below for nested schema](#nestedblock--volumes)) |
| 69 | + |
| 70 | +### Read-Only |
| 71 | + |
| 72 | +- `id` (String) The ID of this resource. |
| 73 | + |
| 74 | +<a id="nestedblock--env"></a> |
| 75 | +### Nested Schema for `env` |
| 76 | + |
| 77 | +Optional: |
| 78 | + |
| 79 | +- `extra_args` (String) |
| 80 | +- `key` (String) key of key-value pair |
| 81 | +- `node_filters` (List of String) |
| 82 | +- `value` (String) value of key-value pair |
| 83 | + |
| 84 | + |
| 85 | +<a id="nestedblock--host_aliases"></a> |
| 86 | +### Nested Schema for `host_aliases` |
| 87 | + |
| 88 | +Optional: |
| 89 | + |
| 90 | +- `hostnames` (List of String) list of hosts names mapped to an IP |
| 91 | +- `ip` (String) ip address to which the list of hostnames to be mapped |
| 92 | + |
| 93 | + |
| 94 | +<a id="nestedblock--k3d_options"></a> |
| 95 | +### Nested Schema for `k3d_options` |
| 96 | + |
| 97 | +Optional: |
| 98 | + |
| 99 | +- `loadbalancer_config_overrides` (List of String) Use dotted YAML path syntax to override nginx loadbalancer settings |
| 100 | +- `no_image_volume` (Boolean) Disable the creation of a volume for importing images. |
| 101 | +- `no_loadbalancer` (Boolean) Disable the creation of a LoadBalancer in front of the server nodes. |
| 102 | +- `no_rollback` (Boolean) Disable the automatic rollback actions, if anything goes wrong. |
| 103 | +- `timeout` (String) Rollback changes if cluster couldn't be created in specified duration. |
| 104 | +- `wait` (Boolean) Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever. (default true). |
| 105 | + |
| 106 | + |
| 107 | +<a id="nestedblock--k3s_options"></a> |
| 108 | +### Nested Schema for `k3s_options` |
| 109 | + |
| 110 | +Optional: |
| 111 | + |
| 112 | +- `extra_args` (Block List) additional arguments passed to the `k3s server|agent` command; same as `--k3s-arg` (see [below for nested schema](#nestedblock--k3s_options--extra_args)) |
| 113 | +- `node_labels` (Block List) same as `--k3s-node-label 'foo=bar@agent:1'` -> this results in a Kubernetes node label (see [below for nested schema](#nestedblock--k3s_options--node_labels)) |
| 114 | + |
| 115 | +<a id="nestedblock--k3s_options--extra_args"></a> |
| 116 | +### Nested Schema for `k3s_options.extra_args` |
| 117 | + |
| 118 | +Optional: |
| 119 | + |
| 120 | +- `extra_args` (String) |
| 121 | +- `key` (String) key of key-value pair |
| 122 | +- `node_filters` (List of String) |
| 123 | +- `value` (String) value of key-value pair |
| 124 | + |
| 125 | + |
| 126 | +<a id="nestedblock--k3s_options--node_labels"></a> |
| 127 | +### Nested Schema for `k3s_options.node_labels` |
| 128 | + |
| 129 | +Optional: |
| 130 | + |
| 131 | +- `extra_args` (String) |
| 132 | +- `key` (String) key of key-value pair |
| 133 | +- `node_filters` (List of String) |
| 134 | +- `value` (String) value of key-value pair |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | +<a id="nestedblock--kube_api"></a> |
| 139 | +### Nested Schema for `kube_api` |
| 140 | + |
| 141 | +Optional: |
| 142 | + |
| 143 | +- `host` (String) Important for the `server` setting in the kubeconfig. |
| 144 | +- `host_ip` (String) Where the Kubernetes API will be listening on. |
| 145 | +- `host_port` (Number) Specify the Kubernetes API server port exposed on the LoadBalancer. |
| 146 | + |
| 147 | + |
| 148 | +<a id="nestedblock--kube_config"></a> |
| 149 | +### Nested Schema for `kube_config` |
| 150 | + |
| 151 | +Optional: |
| 152 | + |
| 153 | +- `switch_context` (Boolean) Directly switch the default kubeconfig's current-context to the new cluster's context |
| 154 | +- `update_default` (Boolean) Directly update the default kubeconfig with the new cluster's context. |
| 155 | + |
| 156 | + |
| 157 | +<a id="nestedblock--ports"></a> |
| 158 | +### Nested Schema for `ports` |
| 159 | + |
| 160 | +Required: |
| 161 | + |
| 162 | +- `container_port` (Number) |
| 163 | + |
| 164 | +Optional: |
| 165 | + |
| 166 | +- `host` (String) |
| 167 | +- `host_port` (Number) |
| 168 | +- `node_filters` (List of String) |
| 169 | +- `protocol` (String) |
| 170 | + |
| 171 | + |
| 172 | +<a id="nestedblock--registries"></a> |
| 173 | +### Nested Schema for `registries` |
| 174 | + |
| 175 | +Optional: |
| 176 | + |
| 177 | +- `config` (String) define contents of the `registries.yaml` file (or reference a file); same as `--registry-config /path/to/config.yaml` |
| 178 | +- `create` (Boolean) creates a default registry to be used with the cluster |
| 179 | +- `use` (List of String) some other k3d-managed registry |
| 180 | + |
| 181 | + |
| 182 | +<a id="nestedblock--runtime"></a> |
| 183 | +### Nested Schema for `runtime` |
| 184 | + |
| 185 | +Optional: |
| 186 | + |
| 187 | +- `agents_memory` (String) Memory limit imposed on the agents nodes [From docker] |
| 188 | +- `gpu_request` (String) GPU devices to add to the cluster node containers ('all' to pass all GPUs) [From docker]. |
| 189 | +- `host_pid_mode` (Boolean) Enable host pid mode of server(s) and agent(s) |
| 190 | +- `labels` (Block List) Labels to be added node container. (see [below for nested schema](#nestedblock--runtime--labels)) |
| 191 | +- `servers_memory` (String) Memory limit imposed on the server nodes [From docker] |
| 192 | + |
| 193 | +<a id="nestedblock--runtime--labels"></a> |
| 194 | +### Nested Schema for `runtime.labels` |
| 195 | + |
| 196 | +Optional: |
| 197 | + |
| 198 | +- `extra_args` (String) |
| 199 | +- `key` (String) key of key-value pair |
| 200 | +- `node_filters` (List of String) |
| 201 | +- `value` (String) value of key-value pair |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | +<a id="nestedblock--volumes"></a> |
| 206 | +### Nested Schema for `volumes` |
| 207 | + |
| 208 | +Required: |
| 209 | + |
| 210 | +- `destination` (String) Destination path for the volume |
| 211 | + |
| 212 | +Optional: |
| 213 | + |
| 214 | +- `node_filters` (List of String) |
| 215 | +- `source` (String) Source path of volume mount |
| 216 | + |
| 217 | + |
0 commit comments