diff --git a/internal/kubernetes/core/v1/pod/expand.go b/internal/kubernetes/core/v1/pod/expand.go index c59d71fa..82566275 100644 --- a/internal/kubernetes/core/v1/pod/expand.go +++ b/internal/kubernetes/core/v1/pod/expand.go @@ -44,6 +44,10 @@ func Expand(in []interface{}) (corev1.PodTemplateSpec, error) { template.ObjectMeta.Annotations = interfaceutils.ExpandMap(val.(map[string]interface{})) } + if val, ok := raw[FieldNodeSelector]; ok { + template.Spec.NodeSelector = interfaceutils.ExpandMap(val.(map[string]interface{})) + } + if val, ok := raw[FieldInitContainer]; ok { initContainers, err := container.Expand(val.([]interface{})) if err != nil { diff --git a/internal/kubernetes/core/v1/pod/fields.go b/internal/kubernetes/core/v1/pod/fields.go index b49c11d0..28d1dab2 100644 --- a/internal/kubernetes/core/v1/pod/fields.go +++ b/internal/kubernetes/core/v1/pod/fields.go @@ -12,6 +12,8 @@ const ( FieldAnnotations = "annotations" // FieldLabels is a field identifier. FieldLabels = "labels" + // FieldNodeSelector is a field identifier. + FieldNodeSelector = "node_selector" // FieldInitContainer is a field identifier. FieldInitContainer = "init_container" // FieldContainer is a field identifier. @@ -43,6 +45,10 @@ func Fields() *schema.Schema { Type: schema.TypeMap, Optional: true, }, + FieldNodeSelector: { + Type: schema.TypeMap, + Optional: true, + }, FieldInitContainer: container.Fields(), FieldContainer: container.Fields(), FieldVolume: volume.Fields(), diff --git a/internal/kubernetes/core/v1/pod/flatten.go b/internal/kubernetes/core/v1/pod/flatten.go index b50af4bd..972683d3 100644 --- a/internal/kubernetes/core/v1/pod/flatten.go +++ b/internal/kubernetes/core/v1/pod/flatten.go @@ -21,6 +21,10 @@ func Flatten(template corev1.PodTemplateSpec) []interface{} { row[FieldAnnotations] = template.ObjectMeta.Annotations } + if len(template.Spec.NodeSelector) > 0 { + row[FieldNodeSelector] = template.Spec.NodeSelector + } + if len(template.Spec.InitContainers) > 0 { row[FieldInitContainer] = container.Flatten(template.Spec.InitContainers) }