Skip to content

Commit 82c9562

Browse files
(feat): Cluster Agent PC and PDB support (#1485)
1 parent 8294066 commit 82c9562

27 files changed

+1119
-602
lines changed

docs/resources/cluster.md

+51
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,35 @@ EOF
312312
}
313313
```
314314

315+
### Creating Rancher v2 RKE cluster with cluster agent scheduling customization. For Custom and Imported clusters provisioned by Rancher v2.11.0 and above.
316+
317+
```hcl
318+
resource "rancher2_cluster" "foo" {
319+
name = "foo"
320+
description = "Terraform cluster with agent customization"
321+
rke_config {
322+
}
323+
cluster_agent_deployment_customization {
324+
scheduling_customization {
325+
priority_class {
326+
# The preemption_policy must be set to 'Never', 'PreemptLowerPriority', or omitted.
327+
# If omitted, the default of 'PreemptLowerPriority' is used.
328+
preemption_policy = "PreemptLowerPriority"
329+
# The value cannot be less than negative 1 billion, or greater than 1 billion
330+
value = 1000000000
331+
}
332+
pod_disruption_budget {
333+
# min_available and max_unavailable must either be non-negative whole integers,
334+
# or whole number percentages greater than 0 and less than or equal to 100 (e.g. "50%").
335+
# You cannot set both min_available and max_unavailable at the same time.
336+
min_available = "1"
337+
#max_unavailable
338+
}
339+
}
340+
}
341+
}
342+
```
343+
315344
### Creating Rancher v2 RKE cluster with Pod Security Admission Configuration Template (PSACT). For Rancher v2.7.2 and above.
316345

317346
```hcl
@@ -649,6 +678,7 @@ The following attributes are exported:
649678
* `append_tolerations` - (Optional) User defined tolerations to append to agent (list)
650679
* `override_affinity` - (Optional) User defined affinity to override default agent affinity (string)
651680
* `override_resource_requirements` - (Optional) User defined resource requirements to set on the agent (list)
681+
* `scheduling_customization` - (Optional) Supported in Rancher 2.11.0 and above. Defines the configuration of a Priority Class and or Pod Disruption Budget. Currently only supported by the `cluster_agent_deployment_customization` field, and requires the `cattle_cluster_agent_scheduling_customization` feature to be enabled.
652682

653683
#### `append_tolerations`
654684

@@ -669,6 +699,27 @@ The following attributes are exported:
669699
* `memory_limit` - (Optional) The maximum memory limit for agent (string)
670700
* `memory_request` - (Optional) The minimum memory required for agent (string)
671701

702+
#### `scheduling_customization`
703+
704+
#### Arguments
705+
706+
* `pod_disruption_budget` - (Optional, list) The definition of a Pod Disruption Budget deployed for the cluster agent
707+
* `priority_class` - (Optional, list) The definition of a Priority Class deployed for the cluster agent
708+
709+
#### `pod_disruption_budget`
710+
711+
#### Arguments
712+
713+
* `min_available` - (Optional, string) The minimum number of agent replicas that must be running at a given time. This can be a non-negative whole number or a whole number percentage (e.g. "1", "50%"). This field cannot be used at the same time as `max_unavailable`.
714+
* `max_unavailable` - (Optional, string) The maximum number of agent replicas that can be unavailable at a given time. This can be a non-negative whole number or a whole number percentage (e.g. "1", "50%"). This field cannot be used at the same time as `min_available`.
715+
716+
#### `priority_class`
717+
718+
#### Arguments
719+
720+
* `value` - (Optional, int) The priority value set for the Priority Class. Must be greater than or equal to negative 1 billion, and less than or equal to 1 billion.
721+
* `preemption_policy` (Optional, string) The preemption policy set for the Priority Class. Must be set to either 'Never', or 'PreemptLowerPriority'
722+
672723
### `rke_config`
673724

674725
**Note:** `rke_config` works the same as within Rancher GUI; it will not _provision_ hosts when not using `node_pool` nor `node_driver`. It is expected that nodes are registered by having the `node_command` run on each node. Running the `node_command` is outside the scope of this provider.

docs/resources/cluster_v2.md

+68-1
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,51 @@ EOF
442442
}
443443
```
444444

445+
#### Customize scheduling for the cluster agent
446+
447+
This argument is available in Rancher 2.11.0 and above.
448+
449+
You can configure a Priority Class and or Pod Disruption Budget to be automatically deployed for the cattle cluster agent when provisioning or updating downstream clusters.
450+
451+
In order to use this field, you must ensure that the `cluster-agent-scheduling-customization` feature is enabled in the Rancher server.
452+
453+
454+
The example below demonstrates how to set the `scheduling_customization` field to deploy a Priority Class and Pod Disruption Budget. Currently, this field is only supported for the cluster agent.
455+
456+
```hcl
457+
resource "rancher2_cluster_v2" "foo" {
458+
name = "foo"
459+
kubernetes_version = "rke2/k3s-version"
460+
cluster_agent_deployment_customization {
461+
scheduling_customization {
462+
priority_class {
463+
# The preemption_policy must be set to 'Never', 'PreemptLowerPriority', or omitted.
464+
# If omitted, the default of 'PreemptLowerPriority' is used.
465+
preemption_policy = "PreemptLowerPriority"
466+
# The value cannot be less than negative 1 billion, or greater than 1 billion
467+
value = 1000000000
468+
}
469+
pod_disruption_budget {
470+
# min_available and max_unavailable must either be non-negative whole integers,
471+
# or whole number percentages greater than 0 and less than or equal to 100 (e.g. "50%").
472+
# You cannot set both min_available and max_unavailable at the same time.
473+
min_available = "1"
474+
475+
# max_unavailable = "1"
476+
}
477+
}
478+
479+
}
480+
481+
rke_config {
482+
# In the case of a node-driver cluster
483+
machine_pools {
484+
# ...
485+
}
486+
}
487+
}
488+
```
489+
445490
### Enable Pod Security Policy Admission Configuration Template (PSACT) on the cluster
446491

447492
This argument is available in Rancher v2.7.2 and above.
@@ -878,13 +923,14 @@ The following attributes are exported:
878923

879924
### `cluster_agent_deployment_customization` and `fleet_agent_deployment_customization`
880925

881-
Those arguments are available in Rancher v2.7.5 and above.
926+
These arguments are available in Rancher v2.7.5 and above. The `scheduling_customization` argument is only available in Rancher 2.11 and above, may only be set within `cluster_agent_deployment_customization`, and requires that the `cattle-cluster-agent-scheduling-customization` feature be enabled.
882927

883928
#### Arguments
884929

885930
* `append_tolerations` - (Optional, list) A list of tolerations to be appended to the default tolerations.
886931
* `override_affinity` - (Optional, string, JSON format) Override affinity overrides the global default affinity setting.
887932
* `override_resource_requirements` - (Optional, list) Override resource requirements overrides the default value for requests and/or limits.
933+
+ `scheduling_customization` - (Optional, list) Supported in Rancher 2.11.0 and above. Defines the configuration of a Priority Class and or Pod Disruption Budget. Currently only supported in the `cluster_agent_deployment_customization` field, and requires the `cattle_cluster_agent_scheduling_customization` feature to be enabled.
888934

889935
### `append_tolerations`
890936

@@ -908,6 +954,27 @@ see more information on [Resource Management for Pods and Containers](https://ku
908954
* `memory_limit` - (Optional, string) The maximum memory limit for agent.
909955
* `memory_request` - (Optional, string) The minimum memory required for agent.
910956

957+
### `scheduling_customization`
958+
959+
#### Arguments
960+
961+
* `pod_disruption_budget` - (Optional, list) The definition of a Pod Disruption Budget deployed for the cluster agent
962+
* `priority_class` - (Optional, list) The definition of a Priority Class deployed for the cluster agent
963+
964+
### `pod_disruption_budget`
965+
966+
#### Arguments
967+
968+
* `min_available` - (Optional, string) The minimum number of agent replicas that must be running at a given time. This can be a non-negative whole number or a whole number percentage (e.g. "1", "50%"). This field cannot be used at the same time as `max_unavailable`.
969+
* `max_unavailable` - (Optional, string) The maximum number of agent replicas that can be unavailable at a given time. This can be a non-negative whole number or a whole number percentage (e.g. "1", "50%"). This field cannot be used at the same time as `min_available`.
970+
971+
### `priority_class`
972+
973+
#### Arguments
974+
975+
* `value` - (Optional, int) The priority value set for the Priority Class. Must be greater than or equal to negative 1 billion, and less than or equal to 1 billion.
976+
* `preemption_policy` (Optional, string) The preemption policy set for the Priority Class. Must be set to either 'Never', 'PreemptLowerPriority', or omitted.
977+
911978
### `rke_config`
912979

913980
#### Arguments

0 commit comments

Comments
 (0)