Skip to content

Commit

Permalink
Merge pull request #46 from jsanda/tolerations
Browse files Browse the repository at this point in the history
make tolerations configurable
  • Loading branch information
jsanda authored May 14, 2021
2 parents 3a4ae76 + 17332d2 commit 6d01ad2
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/reaper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ type ReaperSpec struct {
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`

ServerConfig ServerConfig `json:"serverConfig,omitempty" yaml:"serverConfig,omitempty"`

// Tolerations applied to the Reaper pods
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}

// ReaperStatus defines the observed state of Reaper
Expand Down
8 changes: 8 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.

40 changes: 40 additions & 0 deletions config/crd/bases/reaper.cassandra-reaper.io_reapers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,46 @@ spec:
storageType:
type: string
type: object
tolerations:
description: Tolerations applied to the Reaper pods
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty, operator
must be Exists; this combination means to match all values and
all keys.
type: string
operator:
description: Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal. Exists
is equivalent to wildcard for value, so that a pod can tolerate
all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time the
toleration (which must be of effect NoExecute, otherwise this
field is ignored) tolerates the taint. By default, it is not
set, which means tolerate the taint forever (do not evict).
Zero and negative values will be treated as 0 (evict immediately)
by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise
just a regular string.
type: string
type: object
type: array
type: object
status:
description: ReaperStatus defines the observed state of Reaper
Expand Down
1 change: 1 addition & 0 deletions pkg/reconcile/reconcilers.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func newDeployment(reaper *api.Reaper, cassDcService string) *appsv1.Deployment
Env: envVars,
},
},
Tolerations: reaper.Spec.Tolerations,
},
},
},
Expand Down
26 changes: 26 additions & 0 deletions pkg/reconcile/reconcilers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ func TestNewDeployment(t *testing.T) {
assert.Equal(t, probe, container.ReadinessProbe)
}

func TestTolerations(t *testing.T) {
image := "test/reaper:latest"
tolerations := []corev1.Toleration{
{
Key: "key1",
Operator: corev1.TolerationOpEqual,
Value: "value1",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "key2",
Operator: corev1.TolerationOpEqual,
Value: "value2",
Effect: corev1.TaintEffectNoSchedule,
},
}

reaper := newReaperWithCassandraBackend()
reaper.Spec.Image = image
reaper.Spec.Tolerations = tolerations

deployment := newDeployment(reaper, "target-datacenter-service")

assert.ElementsMatch(t, tolerations, deployment.Spec.Template.Spec.Tolerations)
}

func newReaperWithCassandraBackend() *api.Reaper {
namespace := "service-test"
reaperName := "test-reaper"
Expand Down

0 comments on commit 6d01ad2

Please sign in to comment.