Skip to content

Commit

Permalink
Add OS to PodSpec (#2290)
Browse files Browse the repository at this point in the history
* Add os to schema and in ExpandSpec

* add flattenSpec and docs

* add changelog-entry
  • Loading branch information
BBBmau authored Oct 2, 2023
1 parent 32a58d2 commit c81d677
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/2290.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
`kubernetes/schema_pod_spec.go`: Add `os` to podSpecFields
```
14 changes: 14 additions & 0 deletions kubernetes/schema_pod_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions kubernetes/structures_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/pod.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c81d677

Please sign in to comment.