Merge pull request #45610 from bsalamat/priority_api

Automatic merge from submit-queue (batch tested with PRs 45610, 47628)

Add Priority to Kubernetes API

**What this PR does / why we need it**: This is the first in a series of PRs to add priority to Kubernetes API. Subsequent PRs will add priority name resolution to admission controller.


**Release note**:

```release-note
Add PriorityClassName and Priority fields to PodSpec.
```
This commit is contained in:
Kubernetes Submit Queue 2017-06-27 17:46:08 -07:00 committed by GitHub
commit 82eff38a63
30 changed files with 1498 additions and 944 deletions

View File

@ -51285,6 +51285,15 @@
"type": "string" "type": "string"
} }
}, },
"priority": {
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.",
"type": "integer",
"format": "int32"
},
"priorityClassName": {
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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.",
"type": "string"
},
"restartPolicy": { "restartPolicy": {
"description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy", "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy",
"type": "string" "type": "string"

View File

@ -3828,6 +3828,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -1575,6 +1575,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -2656,6 +2656,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -7300,6 +7300,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -19702,6 +19702,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -3797,6 +3797,20 @@ The StatefulSet guarantees that a given network identity will always map to the
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -3222,6 +3222,20 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -3229,6 +3229,20 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -4541,6 +4541,20 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -5405,6 +5405,20 @@ The resulting set of endpoints can be viewed as:<br>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -11166,6 +11166,15 @@
"type": "string" "type": "string"
} }
}, },
"priority": {
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.",
"type": "integer",
"format": "int32"
},
"priorityClassName": {
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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.",
"type": "string"
},
"restartPolicy": { "restartPolicy": {
"description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy", "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy",
"type": "string" "type": "string"

View File

@ -5044,6 +5044,15 @@
"$ref": "v1.HostAlias" "$ref": "v1.HostAlias"
}, },
"description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods." "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods."
},
"priorityClassName": {
"type": "string",
"description": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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."
},
"priority": {
"type": "integer",
"format": "int32",
"description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority."
} }
} }
}, },

View File

@ -4160,6 +4160,20 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_hostalias">v1.HostAlias</a> array</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priorityClassName</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If specified, indicates the pod&#8217;s priority. "SYSTEM" is a special keyword which indicates 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.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">priority</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -2213,6 +2213,20 @@ type PodSpec struct {
// file if specified. This is only valid for non-hostNetwork pods. // file if specified. This is only valid for non-hostNetwork pods.
// +optional // +optional
HostAliases []HostAlias HostAliases []HostAlias
// If specified, indicates the pod's priority. "SYSTEM" is a special keyword
// which indicates 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.
// +optional
PriorityClassName string
// The priority value. Various system components use this field to find the
// priority of the pod. When Priority Admission Controller is enabled, it
// prevents users from setting this field. The admission controller populates
// this field from PriorityClassName.
// The higher the value, the higher the priority.
// +optional
Priority *int32
} }
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the // HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the

View File

@ -3532,6 +3532,8 @@ func autoConvert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s c
out.SchedulerName = in.SchedulerName out.SchedulerName = in.SchedulerName
out.Tolerations = *(*[]api.Toleration)(unsafe.Pointer(&in.Tolerations)) out.Tolerations = *(*[]api.Toleration)(unsafe.Pointer(&in.Tolerations))
out.HostAliases = *(*[]api.HostAlias)(unsafe.Pointer(&in.HostAliases)) out.HostAliases = *(*[]api.HostAlias)(unsafe.Pointer(&in.HostAliases))
out.PriorityClassName = in.PriorityClassName
out.Priority = (*int32)(unsafe.Pointer(in.Priority))
return nil return nil
} }
@ -3577,6 +3579,8 @@ func autoConvert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s c
out.SchedulerName = in.SchedulerName out.SchedulerName = in.SchedulerName
out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations)) out.Tolerations = *(*[]v1.Toleration)(unsafe.Pointer(&in.Tolerations))
out.HostAliases = *(*[]v1.HostAlias)(unsafe.Pointer(&in.HostAliases)) out.HostAliases = *(*[]v1.HostAlias)(unsafe.Pointer(&in.HostAliases))
out.PriorityClassName = in.PriorityClassName
out.Priority = (*int32)(unsafe.Pointer(in.Priority))
return nil return nil
} }

View File

@ -276,6 +276,10 @@ var ValidateClusterName = genericvalidation.ValidateClusterName
// (where it should be) and this file. // (where it should be) and this file.
var ValidateClassName = NameIsDNSSubdomain var ValidateClassName = NameIsDNSSubdomain
// ValidatePiorityClassName can be used to check whether the given priority
// class name is valid.
var ValidatePriorityClassName = NameIsDNSSubdomain
// TODO update all references to these functions to point to the genericvalidation ones // TODO update all references to these functions to point to the genericvalidation ones
// NameIsDNSSubdomain is a ValidateNameFunc for names that must be a DNS subdomain. // NameIsDNSSubdomain is a ValidateNameFunc for names that must be a DNS subdomain.
func NameIsDNSSubdomain(name string, prefix bool) []string { func NameIsDNSSubdomain(name string, prefix bool) []string {
@ -2296,6 +2300,20 @@ func ValidatePodSpec(spec *api.PodSpec, fldPath *field.Path) field.ErrorList {
allErrs = append(allErrs, ValidateHostAliases(spec.HostAliases, fldPath.Child("hostAliases"))...) allErrs = append(allErrs, ValidateHostAliases(spec.HostAliases, fldPath.Child("hostAliases"))...)
} }
if len(spec.PriorityClassName) > 0 {
if !utilfeature.DefaultFeatureGate.Enabled(features.PodPriority) {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("priorityClassName"), "Pod priority is disabled by feature-gate"))
} else {
for _, msg := range ValidatePriorityClassName(spec.PriorityClassName, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("priorityClassName"), spec.PriorityClassName, msg))
}
}
}
if spec.Priority != nil && !utilfeature.DefaultFeatureGate.Enabled(features.PodPriority) {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("priority"), "Pod priority is disabled by feature-gate"))
}
return allErrs return allErrs
} }

View File

@ -3631,6 +3631,24 @@ func TestValidatePodSpec(t *testing.T) {
minGroupID := int64(0) minGroupID := int64(0)
maxGroupID := int64(2147483647) maxGroupID := int64(2147483647)
priorityEnabled := utilfeature.DefaultFeatureGate.Enabled("PodPriority")
defer func() {
var err error
// restoring the old value
if priorityEnabled {
err = utilfeature.DefaultFeatureGate.Set("PodPriority=true")
} else {
err = utilfeature.DefaultFeatureGate.Set("PodPriority=false")
}
if err != nil {
t.Errorf("Failed to restore feature gate for PodPriority: %v", err)
}
}()
err := utilfeature.DefaultFeatureGate.Set("PodPriority=true")
if err != nil {
t.Errorf("Failed to enable feature gate for PodPriority: %v", err)
return
}
successCases := []api.PodSpec{ successCases := []api.PodSpec{
{ // Populate basic fields, leave defaults for most. { // Populate basic fields, leave defaults for most.
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}}, Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
@ -3739,6 +3757,13 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy: api.RestartPolicyAlways, RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst, DNSPolicy: api.DNSClusterFirst,
}, },
{ // Populate PriorityClassName.
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
PriorityClassName: "valid-name",
},
} }
for i := range successCases { for i := range successCases {
if errs := ValidatePodSpec(&successCases[i], field.NewPath("field")); len(errs) != 0 { if errs := ValidatePodSpec(&successCases[i], field.NewPath("field")); len(errs) != 0 {
@ -3909,12 +3934,47 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy: api.RestartPolicyAlways, RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst, DNSPolicy: api.DNSClusterFirst,
}, },
"bad PriorityClassName": {
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
PriorityClassName: "InvalidName",
},
} }
for k, v := range failureCases { for k, v := range failureCases {
if errs := ValidatePodSpec(&v, field.NewPath("field")); len(errs) == 0 { if errs := ValidatePodSpec(&v, field.NewPath("field")); len(errs) == 0 {
t.Errorf("expected failure for %q", k) t.Errorf("expected failure for %q", k)
} }
} }
err = utilfeature.DefaultFeatureGate.Set("PodPriority=false")
if err != nil {
t.Errorf("Failed to disable feature gate for PodPriority: %v", err)
return
}
priority := int32(100)
featuregatedCases := map[string]api.PodSpec{
"set PriorityClassName": {
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
PriorityClassName: "valid-name",
},
"set Priority": {
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Priority: &priority,
},
}
for k, v := range featuregatedCases {
if errs := ValidatePodSpec(&v, field.NewPath("field")); len(errs) == 0 {
t.Errorf("expected failure due to gated feature: %q", k)
}
}
} }
func extendPodSpecwithTolerations(in api.PodSpec, tolerations []api.Toleration) api.PodSpec { func extendPodSpecwithTolerations(in api.PodSpec, tolerations []api.Toleration) api.PodSpec {
@ -5781,6 +5841,50 @@ func TestValidatePodUpdate(t *testing.T) {
"metadata.annotations[kubernetes.io/config.mirror]", "metadata.annotations[kubernetes.io/config.mirror]",
"changed mirror pod annotation", "changed mirror pod annotation",
}, },
{
api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
NodeName: "node1",
PriorityClassName: "bar-priority",
},
},
api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
NodeName: "node1",
PriorityClassName: "foo-priority",
},
},
"spec: Forbidden: pod updates",
"changed priority class name",
},
{
api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
NodeName: "node1",
PriorityClassName: "",
},
},
api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
NodeName: "node1",
PriorityClassName: "foo-priority",
},
},
"spec: Forbidden: pod updates",
"removed priority class name",
},
} }
for _, test := range tests { for _, test := range tests {

View File

@ -2619,6 +2619,11 @@ func DeepCopy_api_PodSpec(in interface{}, out interface{}, c *conversion.Cloner)
} }
} }
} }
if in.Priority != nil {
in, out := &in.Priority, &out.Priority
*out = new(int32)
**out = **in
}
return nil return nil
} }
} }

View File

@ -114,6 +114,12 @@ const (
// //
// Allows running a "debug container" in a pod namespaces to troubleshoot a running pod. // Allows running a "debug container" in a pod namespaces to troubleshoot a running pod.
DebugContainers utilfeature.Feature = "DebugContainers" DebugContainers utilfeature.Feature = "DebugContainers"
// owner: @bsalamat
// alpha: v1.8
//
// Add priority to pods. Priority affects scheduling and preemption of pods.
PodPriority utilfeature.Feature = "PodPriority"
) )
func init() { func init() {
@ -137,6 +143,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
PersistentLocalVolumes: {Default: false, PreRelease: utilfeature.Alpha}, PersistentLocalVolumes: {Default: false, PreRelease: utilfeature.Alpha},
LocalStorageCapacityIsolation: {Default: false, PreRelease: utilfeature.Alpha}, LocalStorageCapacityIsolation: {Default: false, PreRelease: utilfeature.Alpha},
DebugContainers: {Default: false, PreRelease: utilfeature.Alpha}, DebugContainers: {Default: false, PreRelease: utilfeature.Alpha},
PodPriority: {Default: false, PreRelease: utilfeature.Alpha},
// inherited features from generic apiserver, relisted here to get a conflict if it is changed // inherited features from generic apiserver, relisted here to get a conflict if it is changed
// unintentionally on either side: // unintentionally on either side:

View File

@ -7976,7 +7976,7 @@ func (x codecSelfer1234) decSliceStatefulSet(v *[]StatefulSet, d *codec1978.Deco
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 984) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1008)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]
@ -8214,7 +8214,7 @@ func (x codecSelfer1234) decSliceDeployment(v *[]Deployment, d *codec1978.Decode
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 968) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 992)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]

View File

@ -2481,7 +2481,7 @@ func (x codecSelfer1234) decSliceJob(v *[]Job, d *codec1978.Decoder) {
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 920) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 944)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]

View File

@ -2325,7 +2325,7 @@ func (x codecSelfer1234) decSliceCronJob(v *[]CronJob, d *codec1978.Decoder) {
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1192) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1216)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]

File diff suppressed because it is too large Load Diff

View File

@ -2791,6 +2791,22 @@ message PodSpec {
// +patchMergeKey=ip // +patchMergeKey=ip
// +patchStrategy=merge // +patchStrategy=merge
repeated HostAlias hostAliases = 23; repeated HostAlias hostAliases = 23;
// If specified, indicates the pod's priority. "SYSTEM" is a special keyword
// which indicates 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.
// +optional
optional string priorityClassName = 24;
// The priority value. Various system components use this field to find the
// priority of the pod. When Priority Admission Controller is enabled, it
// prevents users from setting this field. The admission controller populates
// this field from PriorityClassName.
// The higher the value, the higher the priority.
// +optional
optional int32 priority = 25;
} }
// PodStatus represents information about the status of a pod. Status may trail the actual // PodStatus represents information about the status of a pod. Status may trail the actual

View File

@ -35760,7 +35760,7 @@ func (x *PodSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} else { } else {
yysep2 := !z.EncBinary() yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [23]bool var yyq2 [25]bool
_, _, _ = yysep2, yyq2, yy2arr2 _, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false const yyr2 bool = false
yyq2[0] = len(x.Volumes) != 0 yyq2[0] = len(x.Volumes) != 0
@ -35785,9 +35785,11 @@ func (x *PodSpec) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[20] = x.SchedulerName != "" yyq2[20] = x.SchedulerName != ""
yyq2[21] = len(x.Tolerations) != 0 yyq2[21] = len(x.Tolerations) != 0
yyq2[22] = len(x.HostAliases) != 0 yyq2[22] = len(x.HostAliases) != 0
yyq2[23] = x.PriorityClassName != ""
yyq2[24] = x.Priority != nil
var yynn2 int var yynn2 int
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
r.EncodeArrayStart(23) r.EncodeArrayStart(25)
} else { } else {
yynn2 = 1 yynn2 = 1
for _, b := range yyq2 { for _, b := range yyq2 {
@ -36429,6 +36431,66 @@ func (x *PodSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} }
} }
} }
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[23] {
yym79 := z.EncBinary()
_ = yym79
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.PriorityClassName))
}
} else {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[23] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("priorityClassName"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym80 := z.EncBinary()
_ = yym80
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.PriorityClassName))
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[24] {
if x.Priority == nil {
r.EncodeNil()
} else {
yy82 := *x.Priority
yym83 := z.EncBinary()
_ = yym83
if false {
} else {
r.EncodeInt(int64(yy82))
}
}
} else {
r.EncodeNil()
}
} else {
if yyq2[24] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("priority"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Priority == nil {
r.EncodeNil()
} else {
yy84 := *x.Priority
yym85 := z.EncBinary()
_ = yym85
if false {
} else {
r.EncodeInt(int64(yy84))
}
}
}
}
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234) z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else { } else {
@ -36766,6 +36828,34 @@ func (x *PodSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
h.decSliceHostAlias((*[]HostAlias)(yyv44), d) h.decSliceHostAlias((*[]HostAlias)(yyv44), d)
} }
} }
case "priorityClassName":
if r.TryDecodeAsNil() {
x.PriorityClassName = ""
} else {
yyv46 := &x.PriorityClassName
yym47 := z.DecBinary()
_ = yym47
if false {
} else {
*((*string)(yyv46)) = r.DecodeString()
}
}
case "priority":
if r.TryDecodeAsNil() {
if x.Priority != nil {
x.Priority = nil
}
} else {
if x.Priority == nil {
x.Priority = new(int32)
}
yym49 := z.DecBinary()
_ = yym49
if false {
} else {
*((*int32)(x.Priority)) = int32(r.DecodeInt(32))
}
}
default: default:
z.DecStructFieldNotFound(-1, yys3) z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3 } // end switch yys3
@ -36777,16 +36867,16 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj46 int var yyj50 int
var yyb46 bool var yyb50 bool
var yyhl46 bool = l >= 0 var yyhl50 bool = l >= 0
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36794,21 +36884,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Volumes = nil x.Volumes = nil
} else { } else {
yyv47 := &x.Volumes yyv51 := &x.Volumes
yym48 := z.DecBinary() yym52 := z.DecBinary()
_ = yym48 _ = yym52
if false { if false {
} else { } else {
h.decSliceVolume((*[]Volume)(yyv47), d) h.decSliceVolume((*[]Volume)(yyv51), d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36816,21 +36906,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.InitContainers = nil x.InitContainers = nil
} else { } else {
yyv49 := &x.InitContainers yyv53 := &x.InitContainers
yym50 := z.DecBinary() yym54 := z.DecBinary()
_ = yym50 _ = yym54
if false { if false {
} else { } else {
h.decSliceContainer((*[]Container)(yyv49), d) h.decSliceContainer((*[]Container)(yyv53), d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36838,21 +36928,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Containers = nil x.Containers = nil
} else { } else {
yyv51 := &x.Containers yyv55 := &x.Containers
yym52 := z.DecBinary() yym56 := z.DecBinary()
_ = yym52 _ = yym56
if false { if false {
} else { } else {
h.decSliceContainer((*[]Container)(yyv51), d) h.decSliceContainer((*[]Container)(yyv55), d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36860,16 +36950,16 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.RestartPolicy = "" x.RestartPolicy = ""
} else { } else {
yyv53 := &x.RestartPolicy yyv57 := &x.RestartPolicy
yyv53.CodecDecodeSelf(d) yyv57.CodecDecodeSelf(d)
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36882,20 +36972,20 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if x.TerminationGracePeriodSeconds == nil { if x.TerminationGracePeriodSeconds == nil {
x.TerminationGracePeriodSeconds = new(int64) x.TerminationGracePeriodSeconds = new(int64)
} }
yym55 := z.DecBinary() yym59 := z.DecBinary()
_ = yym55 _ = yym59
if false { if false {
} else { } else {
*((*int64)(x.TerminationGracePeriodSeconds)) = int64(r.DecodeInt(64)) *((*int64)(x.TerminationGracePeriodSeconds)) = int64(r.DecodeInt(64))
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36908,20 +36998,20 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if x.ActiveDeadlineSeconds == nil { if x.ActiveDeadlineSeconds == nil {
x.ActiveDeadlineSeconds = new(int64) x.ActiveDeadlineSeconds = new(int64)
} }
yym57 := z.DecBinary() yym61 := z.DecBinary()
_ = yym57 _ = yym61
if false { if false {
} else { } else {
*((*int64)(x.ActiveDeadlineSeconds)) = int64(r.DecodeInt(64)) *((*int64)(x.ActiveDeadlineSeconds)) = int64(r.DecodeInt(64))
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36929,16 +37019,16 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.DNSPolicy = "" x.DNSPolicy = ""
} else { } else {
yyv58 := &x.DNSPolicy yyv62 := &x.DNSPolicy
yyv58.CodecDecodeSelf(d) yyv62.CodecDecodeSelf(d)
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36946,21 +37036,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.NodeSelector = nil x.NodeSelector = nil
} else { } else {
yyv59 := &x.NodeSelector yyv63 := &x.NodeSelector
yym60 := z.DecBinary() yym64 := z.DecBinary()
_ = yym60 _ = yym64
if false { if false {
} else { } else {
z.F.DecMapStringStringX(yyv59, false, d) z.F.DecMapStringStringX(yyv63, false, d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36968,21 +37058,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ServiceAccountName = "" x.ServiceAccountName = ""
} else { } else {
yyv61 := &x.ServiceAccountName yyv65 := &x.ServiceAccountName
yym62 := z.DecBinary() yym66 := z.DecBinary()
_ = yym62 _ = yym66
if false { if false {
} else { } else {
*((*string)(yyv61)) = r.DecodeString() *((*string)(yyv65)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -36990,21 +37080,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.DeprecatedServiceAccount = "" x.DeprecatedServiceAccount = ""
} else { } else {
yyv63 := &x.DeprecatedServiceAccount yyv67 := &x.DeprecatedServiceAccount
yym64 := z.DecBinary() yym68 := z.DecBinary()
_ = yym64 _ = yym68
if false { if false {
} else { } else {
*((*string)(yyv63)) = r.DecodeString() *((*string)(yyv67)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37017,20 +37107,20 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if x.AutomountServiceAccountToken == nil { if x.AutomountServiceAccountToken == nil {
x.AutomountServiceAccountToken = new(bool) x.AutomountServiceAccountToken = new(bool)
} }
yym66 := z.DecBinary() yym70 := z.DecBinary()
_ = yym66 _ = yym70
if false { if false {
} else { } else {
*((*bool)(x.AutomountServiceAccountToken)) = r.DecodeBool() *((*bool)(x.AutomountServiceAccountToken)) = r.DecodeBool()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37038,21 +37128,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.NodeName = "" x.NodeName = ""
} else { } else {
yyv67 := &x.NodeName yyv71 := &x.NodeName
yym68 := z.DecBinary() yym72 := z.DecBinary()
_ = yym68 _ = yym72
if false { if false {
} else { } else {
*((*string)(yyv67)) = r.DecodeString() *((*string)(yyv71)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37060,51 +37150,7 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.HostNetwork = false x.HostNetwork = false
} else { } else {
yyv69 := &x.HostNetwork yyv73 := &x.HostNetwork
yym70 := z.DecBinary()
_ = yym70
if false {
} else {
*((*bool)(yyv69)) = r.DecodeBool()
}
}
yyj46++
if yyhl46 {
yyb46 = yyj46 > l
} else {
yyb46 = r.CheckBreak()
}
if yyb46 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.HostPID = false
} else {
yyv71 := &x.HostPID
yym72 := z.DecBinary()
_ = yym72
if false {
} else {
*((*bool)(yyv71)) = r.DecodeBool()
}
}
yyj46++
if yyhl46 {
yyb46 = yyj46 > l
} else {
yyb46 = r.CheckBreak()
}
if yyb46 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.HostIPC = false
} else {
yyv73 := &x.HostIPC
yym74 := z.DecBinary() yym74 := z.DecBinary()
_ = yym74 _ = yym74
if false { if false {
@ -37112,13 +37158,57 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
*((*bool)(yyv73)) = r.DecodeBool() *((*bool)(yyv73)) = r.DecodeBool()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.HostPID = false
} else {
yyv75 := &x.HostPID
yym76 := z.DecBinary()
_ = yym76
if false {
} else {
*((*bool)(yyv75)) = r.DecodeBool()
}
}
yyj50++
if yyhl50 {
yyb50 = yyj50 > l
} else {
yyb50 = r.CheckBreak()
}
if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.HostIPC = false
} else {
yyv77 := &x.HostIPC
yym78 := z.DecBinary()
_ = yym78
if false {
} else {
*((*bool)(yyv77)) = r.DecodeBool()
}
}
yyj50++
if yyhl50 {
yyb50 = yyj50 > l
} else {
yyb50 = r.CheckBreak()
}
if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37133,13 +37223,13 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
} }
x.SecurityContext.CodecDecodeSelf(d) x.SecurityContext.CodecDecodeSelf(d)
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37147,21 +37237,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ImagePullSecrets = nil x.ImagePullSecrets = nil
} else { } else {
yyv76 := &x.ImagePullSecrets yyv80 := &x.ImagePullSecrets
yym77 := z.DecBinary() yym81 := z.DecBinary()
_ = yym77 _ = yym81
if false { if false {
} else { } else {
h.decSliceLocalObjectReference((*[]LocalObjectReference)(yyv76), d) h.decSliceLocalObjectReference((*[]LocalObjectReference)(yyv80), d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37169,21 +37259,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Hostname = "" x.Hostname = ""
} else { } else {
yyv78 := &x.Hostname yyv82 := &x.Hostname
yym79 := z.DecBinary() yym83 := z.DecBinary()
_ = yym79 _ = yym83
if false { if false {
} else { } else {
*((*string)(yyv78)) = r.DecodeString() *((*string)(yyv82)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37191,21 +37281,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Subdomain = "" x.Subdomain = ""
} else { } else {
yyv80 := &x.Subdomain yyv84 := &x.Subdomain
yym81 := z.DecBinary() yym85 := z.DecBinary()
_ = yym81 _ = yym85
if false { if false {
} else { } else {
*((*string)(yyv80)) = r.DecodeString() *((*string)(yyv84)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37220,13 +37310,13 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
} }
x.Affinity.CodecDecodeSelf(d) x.Affinity.CodecDecodeSelf(d)
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37234,21 +37324,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.SchedulerName = "" x.SchedulerName = ""
} else { } else {
yyv83 := &x.SchedulerName yyv87 := &x.SchedulerName
yym84 := z.DecBinary() yym88 := z.DecBinary()
_ = yym84 _ = yym88
if false { if false {
} else { } else {
*((*string)(yyv83)) = r.DecodeString() *((*string)(yyv87)) = r.DecodeString()
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37256,21 +37346,21 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Tolerations = nil x.Tolerations = nil
} else { } else {
yyv85 := &x.Tolerations yyv89 := &x.Tolerations
yym86 := z.DecBinary() yym90 := z.DecBinary()
_ = yym86 _ = yym90
if false { if false {
} else { } else {
h.decSliceToleration((*[]Toleration)(yyv85), d) h.decSliceToleration((*[]Toleration)(yyv89), d)
} }
} }
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
@ -37278,26 +37368,74 @@ func (x *PodSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.HostAliases = nil x.HostAliases = nil
} else { } else {
yyv87 := &x.HostAliases yyv91 := &x.HostAliases
yym88 := z.DecBinary() yym92 := z.DecBinary()
_ = yym88 _ = yym92
if false { if false {
} else { } else {
h.decSliceHostAlias((*[]HostAlias)(yyv87), d) h.decSliceHostAlias((*[]HostAlias)(yyv91), d)
}
}
yyj50++
if yyhl50 {
yyb50 = yyj50 > l
} else {
yyb50 = r.CheckBreak()
}
if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.PriorityClassName = ""
} else {
yyv93 := &x.PriorityClassName
yym94 := z.DecBinary()
_ = yym94
if false {
} else {
*((*string)(yyv93)) = r.DecodeString()
}
}
yyj50++
if yyhl50 {
yyb50 = yyj50 > l
} else {
yyb50 = r.CheckBreak()
}
if yyb50 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.Priority != nil {
x.Priority = nil
}
} else {
if x.Priority == nil {
x.Priority = new(int32)
}
yym96 := z.DecBinary()
_ = yym96
if false {
} else {
*((*int32)(x.Priority)) = int32(r.DecodeInt(32))
} }
} }
for { for {
yyj46++ yyj50++
if yyhl46 { if yyhl50 {
yyb46 = yyj46 > l yyb50 = yyj50 > l
} else { } else {
yyb46 = r.CheckBreak() yyb50 = r.CheckBreak()
} }
if yyb46 { if yyb50 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj46-1, "") z.DecStructFieldNotFound(yyj50-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
@ -72457,7 +72595,7 @@ func (x codecSelfer1234) decSlicePod(v *[]Pod, d *codec1978.Decoder) {
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 768) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 792)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]
@ -72576,7 +72714,7 @@ func (x codecSelfer1234) decSlicePodTemplate(v *[]PodTemplate, d *codec1978.Deco
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 824) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 848)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]

View File

@ -2520,6 +2520,20 @@ type PodSpec struct {
// +patchMergeKey=ip // +patchMergeKey=ip
// +patchStrategy=merge // +patchStrategy=merge
HostAliases []HostAlias `json:"hostAliases,omitempty" patchStrategy:"merge" patchMergeKey:"ip" protobuf:"bytes,23,rep,name=hostAliases"` HostAliases []HostAlias `json:"hostAliases,omitempty" patchStrategy:"merge" patchMergeKey:"ip" protobuf:"bytes,23,rep,name=hostAliases"`
// If specified, indicates the pod's priority. "SYSTEM" is a special keyword
// which indicates 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.
// +optional
PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,24,opt,name=priorityClassName"`
// The priority value. Various system components use this field to find the
// priority of the pod. When Priority Admission Controller is enabled, it
// prevents users from setting this field. The admission controller populates
// this field from PriorityClassName.
// The higher the value, the higher the priority.
// +optional
Priority *int32 `json:"priority,omitempty" protobuf:"bytes,25,opt,name=priority"`
} }
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the // HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the

View File

@ -1376,6 +1376,8 @@ var map_PodSpec = map[string]string{
"schedulerName": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.", "schedulerName": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.",
"tolerations": "If specified, the pod's tolerations.", "tolerations": "If specified, the pod's tolerations.",
"hostAliases": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", "hostAliases": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.",
"priorityClassName": "If specified, indicates the pod's priority. \"SYSTEM\" is a special keyword which indicates 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.",
"priority": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.",
} }
func (PodSpec) SwaggerDoc() map[string]string { func (PodSpec) SwaggerDoc() map[string]string {

View File

@ -2601,6 +2601,11 @@ func DeepCopy_v1_PodSpec(in interface{}, out interface{}, c *conversion.Cloner)
} }
} }
} }
if in.Priority != nil {
in, out := &in.Priority, &out.Priority
*out = new(int32)
**out = **in
}
return nil return nil
} }
} }

View File

@ -19886,7 +19886,7 @@ func (x codecSelfer1234) decSliceDeployment(v *[]Deployment, d *codec1978.Decode
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 968) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 992)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]
@ -20005,7 +20005,7 @@ func (x codecSelfer1234) decSliceDaemonSet(v *[]DaemonSet, d *codec1978.Decoder)
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 928) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 952)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]
@ -20719,7 +20719,7 @@ func (x codecSelfer1234) decSliceReplicaSet(v *[]ReplicaSet, d *codec1978.Decode
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 896) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 920)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]