|
580 | 580 | } |
581 | 581 | ``` |
582 | 582 |
|
| 583 | +### Creating Rancher V2 Cluster with Machine Selector Files. For Rancher v2.7.2 and above. |
| 584 | + |
| 585 | +Machine selector files provides a means to deliver files to nodes, so that the files can be in place before initiating K3s server or agent processes. |
| 586 | +For more information, please refer to Rancher documentation: |
| 587 | +[RKE2 Cluster Configuration Reference](https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/rke2-cluster-configuration#machineselectorconfig) or |
| 588 | +[K3s Cluster Configuration Reference](https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/k3s-cluster-configuration#machineselectorfiles) |
| 589 | + |
| 590 | +```hcl |
| 591 | +resource "rancher2_cluster_v2" "foo" { |
| 592 | + name = var.rke2_cluster_name |
| 593 | + kubernetes_version = "v1.25.13+rke2r1" // or a K3s version |
| 594 | + enable_network_policy = false |
| 595 | + rke_config { |
| 596 | + machine_pools { |
| 597 | + name = "pool1" |
| 598 | + cloud_credential_secret_name = rancher2_cloud_credential.foo.id |
| 599 | + control_plane_role = true |
| 600 | + etcd_role = true |
| 601 | + worker_role = true |
| 602 | + quantity = 1 |
| 603 | + machine_config { |
| 604 | + kind = rancher2_machine_config_v2.foo.kind |
| 605 | + name = rancher2_machine_config_v2.foo.name |
| 606 | + } |
| 607 | + } |
| 608 | + machine_selector_files { |
| 609 | + machine_label_selector { |
| 610 | + match_labels = { |
| 611 | + "rke.cattle.io/control-plane-role" = "true" |
| 612 | + } |
| 613 | + } |
| 614 | + file_sources { |
| 615 | + secret { |
| 616 | + name = "config-file-v1" |
| 617 | + default_permissions = "644" |
| 618 | + items { |
| 619 | + key = "audit-policy" |
| 620 | + path ="/etc/rancher/rke2/custom/policy-v1.yaml" |
| 621 | + permissions = "666" |
| 622 | + } |
| 623 | + } |
| 624 | + } |
| 625 | + } |
| 626 | + } |
| 627 | +} |
| 628 | +``` |
| 629 | + |
583 | 630 | ## Argument Reference |
584 | 631 |
|
585 | 632 | The following arguments are supported: |
@@ -659,6 +706,7 @@ The following attributes are exported: |
659 | 706 | * `machine_global_config` - (Optional) Cluster V2 machine global config. Must be in YAML format (string) |
660 | 707 | * `machine_pools` - (Optional/Computed) Cluster V2 machine pools (list) |
661 | 708 | * `machine_selector_config` - (Optional/Computed) Cluster V2 machine selector config (list) |
| 709 | +* `machine_selector_files` - (Optional/Computed) Cluster V2 machine selector files (list) |
662 | 710 | * `registries` - (Optional) Cluster V2 docker registries (list maxitems:1) |
663 | 711 | * `etcd` - (Optional) Cluster V2 etcd (list maxitems:1) |
664 | 712 | * `rotate_certificates` (Optional) Cluster V2 certificate rotation (list maxitems:1) |
@@ -764,6 +812,46 @@ The following attributes are exported: |
764 | 812 | * `operator` - (Optional) Machine selector label match expressions operator (string) |
765 | 813 | * `values` - (Optional) Machine selector label match expressions values (List string) |
766 | 814 |
|
| 815 | +#### `machine_selector_files` |
| 816 | + |
| 817 | +##### Arguments |
| 818 | + |
| 819 | +* `machine_label_selector` - (Optional) Machine selector label (list maxitems:1) |
| 820 | +* `files` - (Optional) Machine selector files (list) |
| 821 | + |
| 822 | +#### `files` |
| 823 | + |
| 824 | +##### Arguments |
| 825 | + |
| 826 | +* `secret` - (Optional) The secret which is the source of files (list maxitems:1) |
| 827 | +* `configmap` - (Optional) The configmap which is the source of files (list maxitems:1) |
| 828 | + |
| 829 | +#### `secret` |
| 830 | + |
| 831 | +##### Arguments |
| 832 | + |
| 833 | +* `name` - (Required) The name of the secret (string) |
| 834 | +* `default_permissions` - (Optional) The numeric representation of the file default permissions (string) |
| 835 | +* `items` - (Optional) Items to retrieve from the secret (list) |
| 836 | + |
| 837 | +#### `configmap` |
| 838 | + |
| 839 | +##### Arguments |
| 840 | + |
| 841 | +* `name` - (Required) The name of the configmap (string) |
| 842 | +* `default_permissions` - (Optional) The numeric representation of the file default permissions (string) |
| 843 | +* `items` - (Optional) Items to retrieve from the configmap (list) |
| 844 | + |
| 845 | +#### `items` |
| 846 | + |
| 847 | +##### Arguments |
| 848 | + |
| 849 | +* `key` - (Required) The key of the item to retrieve (string) |
| 850 | +* `path` - (Required) The path to put the file in the target node (string) |
| 851 | +* `dynamic` - (Optional) If true, the file is ignored when determining whether the node should be drained before updating the node plan (Boolean, default: true) |
| 852 | +* `permissions` - (Optional) The numeric representation of the file permission (string) |
| 853 | +* `hash` - (Optional) The base64 encoded value of the SHA256 checksum of the file's content (string) |
| 854 | + |
767 | 855 | #### `registries` |
768 | 856 |
|
769 | 857 | ##### Arguments |
|
0 commit comments