const PluginName … // Register registers a plugin func Register(plugins *admission.Plugins) { … } type Plugin … var _ … var _ … var _ … var _ … // NewPlugin creates a new priority admission plugin. func NewPlugin() *Plugin { … } // ValidateInitialization implements the InitializationValidator interface. func (p *Plugin) ValidateInitialization() error { … } // SetExternalKubeClientSet implements the WantsInternalKubeClientSet interface. func (p *Plugin) SetExternalKubeClientSet(client kubernetes.Interface) { … } // SetExternalKubeInformerFactory implements the WantsInternalKubeInformerFactory interface. func (p *Plugin) SetExternalKubeInformerFactory(f informers.SharedInformerFactory) { … } var podResource … var priorityClassResource … // Admit checks Pods and admits or rejects them. It also resolves the priority of pods based on their PriorityClass. // Note that pod validation mechanism prevents update of a pod priority. func (p *Plugin) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { … } // Validate checks PriorityClasses and admits or rejects them. func (p *Plugin) Validate(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { … } // admitPod makes sure a new pod does not set spec.Priority field. It also makes sure that the PriorityClassName exists if it is provided and resolves the pod priority from the PriorityClassName. func (p *Plugin) admitPod(a admission.Attributes) error { … } // validatePriorityClass ensures that the value field is not larger than the highest user definable priority. If the GlobalDefault is set, it ensures that there is no other PriorityClass whose GlobalDefault is set. func (p *Plugin) validatePriorityClass(a admission.Attributes) error { … } func (p *Plugin) getDefaultPriorityClass() (*schedulingv1.PriorityClass, error) { … } func (p *Plugin) getDefaultPriority() (string, int32, *apiv1.PreemptionPolicy, error) { … }