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 diff --git a/kubernetes/schema_pod_spec.go b/kubernetes/schema_pod_spec.go index d5d2ab71bf..e9f78a4a57 100644 --- a/kubernetes/schema_pod_spec.go +++ b/kubernetes/schema_pod_spec.go @@ -201,6 +201,20 @@ 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, + Description: "Specifies the OS of the containers in the pod.", + 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..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 } @@ -812,6 +818,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) } 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