Skip to content

Commit 177c37b

Browse files
authored
Add scheduler_name attribute with docs and test (#2026)
* Add scheduler_name attribute with docs and test * add changelog-entry
1 parent 3180158 commit 177c37b

File tree

9 files changed

+24
-1
lines changed

9 files changed

+24
-1
lines changed

.changelog/2026.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note
2+
`kubernetes/schema_pod_spec.go`: Add `scheduler_name` attribute
3+
```

kubernetes/resource_kubernetes_deployment_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ func testAccKubernetesDeploymentConfig_minimal(name, imageName string) string {
12471247
}
12481248
}
12491249
spec {
1250+
scheduler_name = "test"
12501251
container {
12511252
image = "%s"
12521253
name = "tf-acc-test"

kubernetes/resource_kubernetes_pod_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func TestAccKubernetesPod_basic(t *testing.T) {
7676
resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"),
7777
resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"),
7878
resource.TestCheckResourceAttrSet(resourceName, "metadata.0.uid"),
79+
resource.TestCheckResourceAttr(resourceName, "spec.0.scheduler_name", "test"),
7980
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.env.0.value_from.0.secret_key_ref.0.name", secretName),
8081
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.env.0.value_from.0.secret_key_ref.0.key", "one"),
8182
resource.TestCheckResourceAttr(resourceName, "spec.0.container.0.env.0.value_from.0.secret_key_ref.0.optional", "true"),
@@ -1602,7 +1603,6 @@ resource "kubernetes_pod" "test" {
16021603
16031604
spec {
16041605
automount_service_account_token = false
1605-
16061606
container {
16071607
image = "%s"
16081608
name = "containername"

kubernetes/schema_pod_spec.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ func podSpecFields(isUpdatable, isComputed bool) map[string]*schema.Schema {
354354
},
355355
},
356356
},
357+
"scheduler_name": {
358+
Type: schema.TypeString,
359+
Optional: true,
360+
Computed: true,
361+
ForceNew: !isUpdatable,
362+
Description: "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.",
363+
},
357364
"service_account_name": {
358365
Type: schema.TypeString,
359366
Optional: true,

kubernetes/structures_pod.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) {
111111
att["security_context"] = flattenPodSecurityContext(in.SecurityContext)
112112
}
113113

114+
if in.SchedulerName != "" {
115+
att["scheduler_name"] = in.SchedulerName
116+
}
117+
114118
if in.ServiceAccountName != "" {
115119
att["service_account_name"] = in.ServiceAccountName
116120
}
@@ -780,6 +784,10 @@ func expandPodSpec(p []interface{}) (*v1.PodSpec, error) {
780784
obj.SecurityContext = ctx
781785
}
782786

787+
if v, ok := in["scheduler_name"].(string); ok {
788+
obj.SchedulerName = v
789+
}
790+
783791
if v, ok := in["service_account_name"].(string); ok {
784792
obj.ServiceAccountName = v
785793
}

website/docs/r/deployment.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ The following arguments are supported:
166166
* `restart_policy` - (Optional) Restart policy for all containers within the pod. One of Always, OnFailure, Never. For more info see [Kubernetes reference](http://kubernetes.io/docs/user-guide/pod-states#restartpolicy).
167167
* `runtime_class_name` - (Optional) RuntimeClassName is a feature for selecting the container runtime configuration. The container runtime configuration is used to run a Pod's containers. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/containers/runtime-class)
168168
* `security_context` - (Optional) SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty
169+
* `scheduler_name` - (Optional) If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.
169170
* `service_account_name` - (Optional) ServiceAccountName is the name of the ServiceAccount to use to run this pod. For more info see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/.
170171
* `share_process_namespace` - (Optional) Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set.
171172
* `subdomain` - (Optional) If specified, the fully qualified Pod hostname will be "...svc.". If not specified, the pod will not have a domainname at all..

website/docs/r/deployment_v1.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ The following arguments are supported:
166166
* `restart_policy` - (Optional) Restart policy for all containers within the pod. One of Always, OnFailure, Never. For more info see [Kubernetes reference](http://kubernetes.io/docs/user-guide/pod-states#restartpolicy).
167167
* `runtime_class_name` - (Optional) RuntimeClassName is a feature for selecting the container runtime configuration. The container runtime configuration is used to run a Pod's containers. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/containers/runtime-class)
168168
* `security_context` - (Optional) SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty
169+
* `scheduler_name` - (Optional) If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.
169170
* `service_account_name` - (Optional) ServiceAccountName is the name of the ServiceAccount to use to run this pod. For more info see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/.
170171
* `share_process_namespace` - (Optional) Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set.
171172
* `subdomain` - (Optional) If specified, the fully qualified Pod hostname will be "...svc.". If not specified, the pod will not have a domainname at all..

website/docs/r/pod.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ The following arguments are supported:
218218
* `restart_policy` - (Optional) Restart policy for all containers within the pod. One of Always, OnFailure, Never. For more info see [Kubernetes reference](http://kubernetes.io/docs/user-guide/pod-states#restartpolicy).
219219
* `runtime_class_name` - (Optional) RuntimeClassName is a feature for selecting the container runtime configuration. The container runtime configuration is used to run a Pod's containers. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/containers/runtime-class)
220220
* `security_context` - (Optional) SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty
221+
* `scheduler_name` - (Optional) If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.
221222
* `service_account_name` - (Optional) ServiceAccountName is the name of the ServiceAccount to use to run this pod. For more info see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/.
222223
* `share_process_namespace` - (Optional) Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set.
223224
* `subdomain` - (Optional) If specified, the fully qualified Pod hostname will be "...svc.". If not specified, the pod will not have a domainname at all..

website/docs/r/pod_v1.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ The following arguments are supported:
218218
* `restart_policy` - (Optional) Restart policy for all containers within the pod. One of Always, OnFailure, Never. For more info see [Kubernetes reference](http://kubernetes.io/docs/user-guide/pod-states#restartpolicy).
219219
* `runtime_class_name` - (Optional) RuntimeClassName is a feature for selecting the container runtime configuration. The container runtime configuration is used to run a Pod's containers. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/containers/runtime-class)
220220
* `security_context` - (Optional) SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty
221+
* `scheduler_name` - (Optional) If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.
221222
* `service_account_name` - (Optional) ServiceAccountName is the name of the ServiceAccount to use to run this pod. For more info see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/.
222223
* `share_process_namespace` - (Optional) Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set.
223224
* `subdomain` - (Optional) If specified, the fully qualified Pod hostname will be "...svc.". If not specified, the pod will not have a domainname at all..

0 commit comments

Comments
 (0)