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

Add SchedulingConstraints to Etcd spec #329

Merged
merged 4 commits into from
Apr 11, 2022
Merged
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
16 changes: 16 additions & 0 deletions api/v1alpha1/etcd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ type SharedConfig struct {
AutoCompactionRetention *string `json:"autoCompactionRetention,omitempty"`
}

// SchedulingConstraints defines the different scheduling constraints that must be applied to the
// pod spec in the etcd statefulset.
// Currently supported constraints are Affinity and TopologySpreadConstraints.
type SchedulingConstraints struct {
// Affinity defines the various affinity and anti-affinity rules for a pod
// that are honoured by the kube-scheduler.
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// TopologySpreadConstraints describes how a group of pods ought to spread across topology domains,
// that are honoured by the kube-scheduler.
// +optional
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
unmarshall marked this conversation as resolved.
Show resolved Hide resolved
}

// EtcdSpec defines the desired state of Etcd
type EtcdSpec struct {
// selector is a label query over pods that should match the replica count.
Expand All @@ -258,6 +272,8 @@ type EtcdSpec struct {
Backup BackupSpec `json:"backup"`
// +optional
Common SharedConfig `json:"sharedConfig,omitempty"`
// +optional
SchedulingConstraints SchedulingConstraints `json:"schedulingConstraints,omitempty"`
// +required
Replicas int32 `json:"replicas"`
// PriorityClassName is the name of a priority class that shall be used for the etcd pods.
Expand Down
28 changes: 28 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions charts/etcd/templates/etcd-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ spec:
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- if .Values.schedulingConstraints }}
{{- if .Values.schedulingConstraints.affinity }}
affinity:
{{ toYaml .Values.schedulingConstraints.affinity | indent 8 }}
{{- end }}
{{- if .Values.schedulingConstraints.topologySpreadConstraints }}
topologySpreadConstraints:
{{ toYaml .Values.schedulingConstraints.topologySpreadConstraints | indent 6 }}
abdasgupta marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- end }}
containers:
- name: etcd
image: {{ .Values.etcd.image }}
Expand Down
23 changes: 23 additions & 0 deletions charts/etcd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ sharedConfig:
autoCompactionMode: periodic
autoCompactionRetention: "30m"

schedulingConstraints: {}
## affinity defines the various affinity and anti-affinity rules for a pod
## that are honoured by the kube-scheduler.
# affinity:
# podAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - labelSelector:
# matchExpressions:
# - key: key
# operator: In
# values:
# - value
# topologyKey: topology.kubernetes.io/zone
## topologySpreadConstraints describes how a group of pods ought to spread across topology domains,
## that are honoured by the kube-scheduler.
# topologySpreadConstraints:
# - maxSkew: 1
# topologyKey: topology.kubernetes.io/zone
# whenUnsatisfiable: DoNotSchedule
# labelSelector:
# matchLabels:
# key: value

volumeClaimTemplateName: test
storageClass: ""
storageCapacity: 16Gi
Expand Down
Loading