Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calico apiserver improvements #3481

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions api/v1/apiserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type APIServerDeploymentContainer struct {
// If used in conjunction with the deprecated ComponentResources, then this value takes precedence.
// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`

// +optional
Lifecycle *v1.Lifecycle `json:"lifecycle,omitempty" protobuf:"bytes,12,opt,name=lifecycle"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to hear the use case for adding this. (I hadn't heard of Lifecycle before but looking at the K8s API reference I don't understand what its use case would be for the apiserver.)

}

// APIServerDeploymentInitContainer is an API server Deployment init container.
Expand Down Expand Up @@ -146,6 +149,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
Expand Down Expand Up @@ -173,6 +180,12 @@ type APIServerDeployment struct {

// APIServerDeploymentSpec defines configuration for the API server Deployment.
type APIServerDeploymentSpec struct {
// Replicas defines how many instances of the API server pod will run.
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=2147483647
Replicas *int32 `json:"replicas,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replicas for the apiserver can already be controlled through the Installation resource with the controlPlaneReplicas field.
I'm not saying this wouldn't be useful but just wanted to point out it is possible to change the number of replicas.


// MinReadySeconds is the minimum number of seconds for which a newly created Deployment pod should
// be ready without any of its container crashing, for it to be considered available.
// If specified, this overrides any minReadySeconds value that may be set on the API server Deployment.
Expand All @@ -185,6 +198,24 @@ type APIServerDeploymentSpec struct {
// Template describes the API server Deployment pod that will be created.
// +optional
Template *APIServerDeploymentPodTemplateSpec `json:"template,omitempty"`

// The deployment strategy to use to replace existing pods with new ones.
// +optional
// +patchStrategy=retainKeys
Strategy *APIServerDeploymentStrategy `json:"strategy,omitempty" patchStrategy:"retainKeys" protobuf:"bytes,4,opt,name=strategy"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want to hear what the use case is that we need to add this override for the apiserver. In other words why would someone need to change the Strategy?

}

// APIServerDeploymentStrategy describes how to replace existing pods with new ones.
type APIServerDeploymentStrategy struct {
// Rolling update config params. Present only if DeploymentStrategyType =
// RollingUpdate.
// to be.
// +optional
RollingUpdate *appsv1.RollingUpdateDeployment `json:"rollingUpdate,omitempty" protobuf:"bytes,2,opt,name=rollingUpdate"`

// Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
// +optional
Type *appsv1.DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"`
}

func (c *APIServerDeployment) GetMetadata() *Metadata {
Expand Down
10 changes: 10 additions & 0 deletions pkg/render/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,16 @@ func (c *apiServerComponent) apiServerContainer() corev1.Container {
Args: c.startUpArgs(),
Env: env,
VolumeMounts: volumeMounts,
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/version",
Port: intstr.FromInt(APIServerPort),
Scheme: corev1.URISchemeHTTPS,
},
},
PeriodSeconds: 60,
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down
Loading