Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add nodeAffinity label to cordon only cassandra from a k8s node, kudo…
Browse files Browse the repository at this point in the history
… v0.13.0 (#123)

* Add nodeAffinity label to cordon only cassandra from a k8s node
* Update KUDO dependency to 0.13.0

Signed-off-by: Andreas Neumann <[email protected]>
  • Loading branch information
ANeumann82 authored May 27, 2020
1 parent 2da1b65 commit da9b3ad
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 23 deletions.
2 changes: 1 addition & 1 deletion kuttl-tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KUDO_VERSION=0.12.0
KUDO_VERSION=0.13.0
KUTTL_VERSION=0.2.1
KUBERNETES_VERSION=1.17.2
KIND_VERSION=0.8.1
Expand Down
10 changes: 10 additions & 0 deletions kuttl-tests/suites/common/install-test/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ kind: StatefulSet
metadata:
name: cassandra-node
namespace: cassandra-install-test
spec:
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kudo-cassandra/cordon"
operator: DoesNotExist
status:
readyReplicas: 1
---
Expand Down
2 changes: 1 addition & 1 deletion metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export VENDOR_DIRECTORY="${_project_directory}/shared/vendor"
export CASSANDRA_VERSION="3.11.5"

# https://github.com/kudobuilder/kudo/releases/tag/vx.y.z
export KUDO_VERSION="0.11.1"
export KUDO_VERSION="0.13.0"

export KUBERNETES_VERSION="1.15.0"

Expand Down
2 changes: 1 addition & 1 deletion operator/operator.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kudo.dev/v1beta1
name: "cassandra"
operatorVersion: "0.1.2"
kudoVersion: "0.11.1"
kudoVersion: "0.13.0"
kubernetesVersion: "1.15.0"
appVersion: "3.11.5"
maintainers:
Expand Down
14 changes: 8 additions & 6 deletions operator/templates/stateful-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,22 @@ spec:
{{ end }}
{{ end }}
affinity:
{{ if $.Params.NODE_TOPOLOGY }}
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kudo-cassandra/cordon"
operator: DoesNotExist
{{ if $.Params.NODE_TOPOLOGY }}
- key: {{ $datacenter.rackLabelKey }}
operator: In
values:
{{ range $rack := $datacenter.racks }}
- {{ $rack.rackLabelValue }}
{{ end }}
{{ end }}
{{ if (eq $.Params.NODE_ANTI_AFFINITY "true") }}
{{ end }}
podAntiAffinity:
{{ if (eq $.Params.NODE_ANTI_AFFINITY "true") }}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
Expand All @@ -70,8 +72,8 @@ spec:
values:
- {{ $.Name }}
topologyKey: "kubernetes.io/hostname"
{{ end }}
{{ if $.Params.NODE_TOPOLOGY }}
{{ end }}
{{ if $.Params.NODE_TOPOLOGY }}
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
Expand All @@ -82,7 +84,7 @@ spec:
values:
- {{ $.Name }}
topologyKey: "{{ $datacenter.rackLabelKey }}"
{{ end }}
{{ end }}
securityContext:
# FIXME(mpereira): are the two settings below necessary?
# allowPrivilegeEscalation: false
Expand Down
14 changes: 8 additions & 6 deletions templates/operator/templates/stateful-set.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,22 @@ spec:
{{ end }}
{{ end }}
affinity:
{{ if $.Params.NODE_TOPOLOGY }}
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kudo-cassandra/cordon"
operator: DoesNotExist
{{ if $.Params.NODE_TOPOLOGY }}
- key: {{ $datacenter.rackLabelKey }}
operator: In
values:
{{ range $rack := $datacenter.racks }}
- {{ $rack.rackLabelValue }}
{{ end }}
{{ end }}
{{ if (eq $.Params.NODE_ANTI_AFFINITY "true") }}
{{ end }}
podAntiAffinity:
{{ if (eq $.Params.NODE_ANTI_AFFINITY "true") }}
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
Expand All @@ -70,8 +72,8 @@ spec:
values:
- {{ $.Name }}
topologyKey: "kubernetes.io/hostname"
{{ end }}
{{ if $.Params.NODE_TOPOLOGY }}
{{ end }}
{{ if $.Params.NODE_TOPOLOGY }}
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
Expand All @@ -82,7 +84,7 @@ spec:
values:
- {{ $.Name }}
topologyKey: "{{ $datacenter.rackLabelKey }}"
{{ end }}
{{ end }}
securityContext:
# FIXME(mpereira): are the two settings below necessary?
# allowPrivilegeEscalation: false
Expand Down
17 changes: 9 additions & 8 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ require (
github.com/aws/aws-sdk-go v1.29.14
github.com/google/uuid v1.1.1
github.com/imdario/mergo v0.3.8 // indirect
github.com/kudobuilder/kudo v0.11.1
github.com/kudobuilder/test-tools v0.4.0
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/kudobuilder/kudo v0.13.0
github.com/kudobuilder/test-tools v0.5.0
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/afero v1.2.2
github.com/thoas/go-funk v0.5.0
github.com/thoas/go-funk v0.6.0
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.4
k8s.io/apimachinery v0.17.4
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.17.6
k8s.io/apimachinery v0.17.6
)

replace k8s.io/api => k8s.io/api v0.17.4
Expand Down
Loading

0 comments on commit da9b3ad

Please sign in to comment.