Skip to content

Commit

Permalink
Introduce .spec.schedulerName in Shoot API (gardener#8261)
Browse files Browse the repository at this point in the history
* Introduce `.spec.schedulerName` in Shoot API

* Address review comments

* Address review comments (II)

* Address review comment (III)
  • Loading branch information
timuthy authored Jul 25, 2023
1 parent 63346c3 commit 0426cfe
Show file tree
Hide file tree
Showing 22 changed files with 1,005 additions and 763 deletions.
42 changes: 42 additions & 0 deletions docs/api-reference/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,20 @@ ControlPlane
<p>ControlPlane contains general settings for the control plane of the shoot.</p>
</td>
</tr>
<tr>
<td>
<code>schedulerName</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>SchedulerName is the name of the responsible scheduler which schedules the shoot.
If not specified, the default scheduler takes over.
This field is immutable.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -10909,6 +10923,20 @@ ControlPlane
<p>ControlPlane contains general settings for the control plane of the shoot.</p>
</td>
</tr>
<tr>
<td>
<code>schedulerName</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>SchedulerName is the name of the responsible scheduler which schedules the shoot.
If not specified, the default scheduler takes over.
This field is immutable.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="core.gardener.cloud/v1beta1.ShootStateSpec">ShootStateSpec
Expand Down Expand Up @@ -11535,6 +11563,20 @@ ControlPlane
<p>ControlPlane contains general settings for the control plane of the shoot.</p>
</td>
</tr>
<tr>
<td>
<code>schedulerName</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>SchedulerName is the name of the responsible scheduler which schedules the shoot.
If not specified, the default scheduler takes over.
This field is immutable.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down
9 changes: 8 additions & 1 deletion docs/concepts/scheduler.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ The region does not matter, i.e., `testing` shoots may also be scheduled on a se
The `shoots/binding` subresource is used to bind a `Shoot` to a `Seed`. On creation of a shoot cluster/s, the scheduler updates the binding automatically if an appropriate seed cluster is available.
Only an operator with the necessary RBAC can update this binding manually. This can be done by changing the `.spec.seedName` of the shoot. However, if a different seed is already assigned to the shoot, this will trigger a control-plane migration. For required steps, please see [Triggering the Migration](../operations/control_plane_migration.md#triggering-the-migration).

## `spec.schedulerName` Field in the `Shoot` Specification

Similar to the `spec.schedulerName` field in `Pod`s, the `Shoot` specification has an optional `.spec.schedulerName` field. If this field is set on creation, only the scheduler which relates to the configured name is responsible for scheduling the shoot.
The `default-scheduler` name is reserved for the default scheduler of Gardener.
Affected Shoots will remain in `Pending` state if the mentioned scheduler is not present in the landscape.

## `spec.seedName` Field in the `Shoot` Specification

Similar to the `.spec.nodeName` field in `Pod`s, the `Shoot` specification has an optional `.spec.seedName` field. If this field is set on creation, the shoot will be scheduled to this seed. However, this field can only be set by users having RBAC for the `shoots/binding` subresource. If this field is not set, the `scheduler` will assign a suitable seed automatically and populate this field with the seed name.

## `seedSelector` Field in the `Shoot` Specification
Expand Down Expand Up @@ -116,4 +123,4 @@ In case the scheduler fails to find a suitable seed, the operation is being retr

## Current Limitation / Future Plans

- Azure unfortunately has a geographically non-hierarchical naming pattern and does not start with the continent. This is the reason why we will exchange the implementation of the `MinimalDistance` strategy with a more suitable one in the future.
- Azure unfortunately has a geographically non-hierarchical naming pattern and does not start with the continent. This is the reason why we will exchange the implementation of the `MinimalDistance` strategy with a more suitable one in the future.
1 change: 1 addition & 0 deletions example/90-shoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spec:
cloudProfileName: cloudprofile1
region: europe-central-1
purpose: evaluation # {testing,development,production,infrastructure}, "infrastructure" purpose only usable for shoots in garden namespace
# schedulerName: default-scheduler
provider:
type: <some-provider-name> # {aws,azure,gcp,...}
infrastructureConfig:
Expand Down
2 changes: 0 additions & 2 deletions example/provider-local/managedseeds/shoot-managedseed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ metadata:
shoot.gardener.cloud/infrastructure-cleanup-wait-period-seconds: "0"
shoot.gardener.cloud/cloud-config-execution-max-delay-seconds: "0"
spec:
seedName: local
cloudProfileName: local
secretBindingName: local
region: local
Expand All @@ -26,7 +25,6 @@ spec:
maxSurge: 1
maxUnavailable: 0
kubernetes:
version: 1.24.8
kubelet:
serializeImagePulls: false
registryPullQPS: 10
Expand Down
1 change: 0 additions & 1 deletion example/provider-local/shoot-workerless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: local-wl
namespace: garden-local
spec:
seedName: local
cloudProfileName: local
region: local
provider:
Expand Down
1 change: 0 additions & 1 deletion example/provider-local/shoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ metadata:
shoot.gardener.cloud/infrastructure-cleanup-wait-period-seconds: "0"
shoot.gardener.cloud/cloud-config-execution-max-delay-seconds: "0"
spec:
seedName: local
cloudProfileName: local
secretBindingName: local # dummy, doesn't contain any credentials
region: local
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/core/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type ShootSpec struct {
SystemComponents *SystemComponents
// ControlPlane contains general settings for the control plane of the shoot.
ControlPlane *ControlPlane
// SchedulerName is the name of the responsible scheduler which schedules the shoot.
// If not specified, the default scheduler takes over.
// This field is immutable.
SchedulerName *string
}

// GetProviderType gets the type of the provider.
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/core/v1beta1/constants/types_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ const (
// DefaultIngressGatewayAppLabelValue is the ingress gateway value for the app label.
DefaultIngressGatewayAppLabelValue = "istio-ingressgateway"

// DefaultSchedulerName is the name of the default scheduler.
DefaultSchedulerName = "default-scheduler"

// AnnotationManagedSeedAPIServer is a constant for an annotation on a Shoot resource containing the API server settings for a managed seed.
AnnotationManagedSeedAPIServer = "shoot.gardener.cloud/managed-seed-api-server"
// AnnotationShootIgnoreAlerts is the key for an annotation of a Shoot cluster whose value indicates
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/core/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ func SetDefaults_Shoot(obj *Shoot) {
obj.Spec.SystemComponents.CoreDNS.Autoscaling.Mode = CoreDNSAutoscalingModeHorizontal
}
}

if obj.Spec.SchedulerName == nil {
obj.Spec.SchedulerName = pointer.String(v1beta1constants.DefaultSchedulerName)
}
}

// SetDefaults_KubeAPIServerConfig sets default values for KubeAPIServerConfig objects.
Expand Down
16 changes: 16 additions & 0 deletions pkg/apis/core/v1beta1/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,22 @@ var _ = Describe("Defaults", func() {
Expect(obj.Spec.Kubernetes.Kubelet.SerializeImagePulls).To(PointTo(BeFalse()))
})

It("should default schedulerName", func() {
obj.Spec.SchedulerName = nil

SetObjectDefaults_Shoot(obj)

Expect(obj.Spec.SchedulerName).To(PointTo(Equal("default-scheduler")))
})

It("should not default schedulerName", func() {
obj.Spec.SchedulerName = pointer.String("foo-scheduler")

SetObjectDefaults_Shoot(obj)

Expect(obj.Spec.SchedulerName).To(PointTo(Equal("foo-scheduler")))
})

Context("default kubeReserved", func() {
var (
defaultKubeReservedMemory = resource.MustParse("1Gi")
Expand Down
Loading

0 comments on commit 0426cfe

Please sign in to comment.