diff --git a/api/v1/apiserver_types.go b/api/v1/apiserver_types.go index 60acd60168..58a0e1f5e2 100644 --- a/api/v1/apiserver_types.go +++ b/api/v1/apiserver_types.go @@ -146,6 +146,10 @@ type APIServerDeploymentPodSpec struct { // WARNING: Please note that this field will override the default API server Deployment tolerations. // +optional Tolerations []v1.Toleration `json:"tolerations,omitempty"` + + // PriorityClassName allows to specify a PriorityClass resource to be used. + // +optional + PriorityClassName string `json:"priorityClassName,omitempty"` } // APIServerDeploymentPodTemplateSpec is the API server Deployment's PodTemplateSpec @@ -304,5 +308,11 @@ func (c *APIServerDeployment) GetDeploymentStrategy() *appsv1.DeploymentStrategy } func (c *APIServerDeployment) GetPriorityClassName() string { + if c.Spec.Template != nil { + if c.Spec.Template.Spec != nil { + return c.Spec.Template.Spec.PriorityClassName + } + } + return "" } diff --git a/pkg/crds/operator/operator.tigera.io_apiservers.yaml b/pkg/crds/operator/operator.tigera.io_apiservers.yaml index bef5bde710..34d998efd0 100644 --- a/pkg/crds/operator/operator.tigera.io_apiservers.yaml +++ b/pkg/crds/operator/operator.tigera.io_apiservers.yaml @@ -1225,6 +1225,10 @@ spec: If omitted, the API server Deployment will use its default value for nodeSelector. WARNING: Please note that this field will modify the default API server Deployment nodeSelector. type: object + priorityClassName: + description: PriorityClassName allows to specify a + PriorityClass resource to be used. + type: string tolerations: description: |- Tolerations is the API server pod's tolerations. diff --git a/pkg/render/apiserver.go b/pkg/render/apiserver.go index 12a1666b44..511ed3d906 100644 --- a/pkg/render/apiserver.go +++ b/pkg/render/apiserver.go @@ -1028,7 +1028,7 @@ func (c *apiServerComponent) apiServerDeployment() *appsv1.Deployment { Spec: appsv1.DeploymentSpec{ Replicas: c.cfg.Installation.ControlPlaneReplicas, Strategy: appsv1.DeploymentStrategy{ - Type: appsv1.RecreateDeploymentStrategyType, + Type: appsv1.RollingUpdateDeploymentStrategyType, }, Selector: c.deploymentSelector(), Template: corev1.PodTemplateSpec{ @@ -1050,6 +1050,7 @@ func (c *apiServerComponent) apiServerDeployment() *appsv1.Deployment { InitContainers: initContainers, Containers: containers, Volumes: c.apiServerVolumes(), + PriorityClassName: c.priorityClassName(), }, }, }, diff --git a/pkg/render/apiserver_test.go b/pkg/render/apiserver_test.go index 33a3d15d32..6d30257589 100644 --- a/pkg/render/apiserver_test.go +++ b/pkg/render/apiserver_test.go @@ -1958,6 +1958,8 @@ var _ = Describe("API server rendering tests (Calico)", func() { Value: "bar", } + priorityclassname := "priority" + cfg.APIServer.APIServerDeployment = &operatorv1.APIServerDeployment{ Metadata: &operatorv1.Metadata{ Labels: map[string]string{"top-level": "label1"}, @@ -1986,8 +1988,9 @@ var _ = Describe("API server rendering tests (Calico)", func() { NodeSelector: map[string]string{ "custom-node-selector": "value", }, - Affinity: affinity, - Tolerations: []corev1.Toleration{toleration}, + Affinity: affinity, + Tolerations: []corev1.Toleration{toleration}, + PriorityClassName: priorityclassname, }, }, }, @@ -2047,6 +2050,7 @@ var _ = Describe("API server rendering tests (Calico)", func() { Expect(d.Spec.Template.Spec.Tolerations).To(HaveLen(1)) Expect(d.Spec.Template.Spec.Tolerations[0]).To(Equal(toleration)) + Expect(d.Spec.Template.Spec.PriorityClassName).To(Equal(priorityclassname)) }) It("should override a ControlPlaneNodeSelector when specified", func() {