diff --git a/internal/kubernetes/core/v1/pod/expand.go b/internal/kubernetes/core/v1/pod/expand.go index 82566275..4a71d50c 100644 --- a/internal/kubernetes/core/v1/pod/expand.go +++ b/internal/kubernetes/core/v1/pod/expand.go @@ -91,5 +91,9 @@ func Expand(in []interface{}) (corev1.PodTemplateSpec, error) { template.Spec.HostPID = val.(bool) } + if val, ok := raw[FieldPriorityClassName]; ok { + template.Spec.PriorityClassName = val.(string) + } + return template, nil } diff --git a/internal/kubernetes/core/v1/pod/fields.go b/internal/kubernetes/core/v1/pod/fields.go index 28d1dab2..e197c2db 100644 --- a/internal/kubernetes/core/v1/pod/fields.go +++ b/internal/kubernetes/core/v1/pod/fields.go @@ -26,6 +26,8 @@ const ( FieldPullSecret = "pull_secret" // FieldHostPID is a field identifier. FieldHostPID = "host_pid" + // FieldPriorityClassName is a field identifier. + FieldPriorityClassName = "priority_class_name" ) // Fields which define a Pod. @@ -37,11 +39,11 @@ func Fields() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - FieldAnnotations: &schema.Schema{ + FieldAnnotations: { Type: schema.TypeMap, Optional: true, }, - FieldLabels: &schema.Schema{ + FieldLabels: { Type: schema.TypeMap, Optional: true, }, @@ -65,6 +67,11 @@ func Fields() *schema.Schema { Description: "Use the host’s pid namespace.", Optional: true, }, + FieldPriorityClassName: { + Type: schema.TypeString, + Description: "Priority indicates the importance of a Pod relative to other Pods.", + Optional: true, + }, }, }, } diff --git a/internal/kubernetes/core/v1/pod/flatten.go b/internal/kubernetes/core/v1/pod/flatten.go index 972683d3..bcdf76eb 100644 --- a/internal/kubernetes/core/v1/pod/flatten.go +++ b/internal/kubernetes/core/v1/pod/flatten.go @@ -49,6 +49,10 @@ func Flatten(template corev1.PodTemplateSpec) []interface{} { row[FieldHostPID] = template.Spec.HostPID } + if template.Spec.PriorityClassName != "" { + row[FieldPriorityClassName] = template.Spec.PriorityClassName + } + out[0] = row return out