From c88bee20fcf14614405244ca7a073583f90f5ce2 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 15 Sep 2023 15:00:37 -0700 Subject: [PATCH 1/3] Add os to schema and in ExpandSpec --- kubernetes/schema_pod_spec.go | 13 +++++++++++++ kubernetes/structures_pod.go | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/kubernetes/schema_pod_spec.go b/kubernetes/schema_pod_spec.go index d5d2ab71bf..2861fcabb0 100644 --- a/kubernetes/schema_pod_spec.go +++ b/kubernetes/schema_pod_spec.go @@ -201,6 +201,19 @@ func podSpecFields(isUpdatable, isComputed bool) map[string]*schema.Schema { ForceNew: !isUpdatable, Description: "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", }, + "os": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, "image_pull_secrets": { Type: schema.TypeList, Description: "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod", diff --git a/kubernetes/structures_pod.go b/kubernetes/structures_pod.go index 86221bbc60..00614d4472 100644 --- a/kubernetes/structures_pod.go +++ b/kubernetes/structures_pod.go @@ -812,6 +812,12 @@ func expandPodSpec(p []interface{}) (*v1.PodSpec, error) { obj.NodeSelector = nodeSelectors } + if v, ok := in["os"].(map[string]interface{}); ok { + if n, ok := v["name"].(string); ok && n != "" { + obj.OS.Name = v1.OSName(n) + } + } + if v, ok := in["runtime_class_name"].(string); ok && v != "" { obj.RuntimeClassName = ptrToString(v) } From a35eb7260963a1b953788671085137a131241b83 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 2 Oct 2023 08:58:02 -0700 Subject: [PATCH 2/3] add flattenSpec and docs --- kubernetes/schema_pod_spec.go | 7 ++++--- kubernetes/structures_pod.go | 6 ++++++ website/docs/r/pod.html.markdown | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kubernetes/schema_pod_spec.go b/kubernetes/schema_pod_spec.go index 2861fcabb0..e9f78a4a57 100644 --- a/kubernetes/schema_pod_spec.go +++ b/kubernetes/schema_pod_spec.go @@ -202,9 +202,10 @@ func podSpecFields(isUpdatable, isComputed bool) map[string]*schema.Schema { Description: "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.", }, "os": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Specifies the OS of the containers in the pod.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { diff --git a/kubernetes/structures_pod.go b/kubernetes/structures_pod.go index 00614d4472..93f251ab07 100644 --- a/kubernetes/structures_pod.go +++ b/kubernetes/structures_pod.go @@ -92,6 +92,12 @@ func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) { } att["image_pull_secrets"] = flattenLocalObjectReferenceArray(in.ImagePullSecrets) + if in.OS.Name != "" { + att["os"] = map[string]interface{}{ + "name": in.OS.Name, + } + } + if in.NodeName != "" { att["node_name"] = in.NodeName } diff --git a/website/docs/r/pod.html.markdown b/website/docs/r/pod.html.markdown index da545a7a5c..e1dd4cb455 100644 --- a/website/docs/r/pod.html.markdown +++ b/website/docs/r/pod.html.markdown @@ -215,7 +215,8 @@ The following arguments are supported: * `image_pull_secrets` - (Optional) ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) * `node_name` - (Optional) NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements. * `node_selector` - (Optional) NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/). -* `priority_class_name` - (Optional) If specified, indicates the pod's priority. 'system-node-critical' and 'system-cluster-critical' are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. +* `os` - (Optional) Specifies the OS of the containers in the pod. +* `priority_class_name` - (Optional) If specified, indicates the pod's priority. 'system-node-critical' and 'system-cluster-critical' are two special keywords which indicate the highest priorities with the formerer being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. * `restart_policy` - (Optional) Restart policy for all containers within the pod. One of Always, OnFailure, Never. For more info see [Kubernetes reference](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy). * `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) * `security_context` - (Optional) SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty From 9a7da0ce7a0a057775649719eaa49d6a92ab588e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Mon, 2 Oct 2023 09:04:16 -0700 Subject: [PATCH 3/3] add changelog-entry --- .changelog/2290.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2290.txt diff --git a/.changelog/2290.txt b/.changelog/2290.txt new file mode 100644 index 0000000000..05aba39f68 --- /dev/null +++ b/.changelog/2290.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +`kubernetes/schema_pod_spec.go`: Add `os` to podSpecFields +``` \ No newline at end of file