Skip to content

Commit

Permalink
Merge pull request #23 from clyang82/affinity
Browse files Browse the repository at this point in the history
Overwrite affinity for deployment and statefulset
  • Loading branch information
metalmatze authored Nov 4, 2020
2 parents a163410 + d2c0899 commit acb908d
Show file tree
Hide file tree
Showing 4 changed files with 366 additions and 6 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/observatorium_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type ObservatoriumSpec struct {
// NodeSelector causes all components to be scheduled on nodes with matching labels.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Affinity causes all components to be scheduled on nodes with matching rules.
// +optional
Affinity *v1.Affinity `json:"affinity,omitempty"`
}

type ObjectStorageConfig struct {
Expand Down
6 changes: 6 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.

22 changes: 16 additions & 6 deletions jsonnet/obs-operator.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,22 @@ local patchObs = obs {
uid: config.uid,
}],
},
spec+: if (std.objectHas(obs.config, 'nodeSelector') && (v.kind == 'StatefulSet' || v.kind == 'Deployment')) then {
template+: {
spec+:{
nodeSelector: obs.config.nodeSelector,
spec+: (
if (std.objectHas(obs.config, 'nodeSelector') && (v.kind == 'StatefulSet' || v.kind == 'Deployment')) then {
template+: {
spec+:{
nodeSelector: obs.config.nodeSelector,
},
},
},
} else {},
} else {}
) + (
if (std.objectHas(obs.config, 'affinity') && (v.kind == 'StatefulSet' || v.kind == 'Deployment')) then {
template+: {
spec+:{
affinity: obs.config.affinity,
},
},
} else {}
),
}, patchObs.manifests),
}
Loading

0 comments on commit acb908d

Please sign in to comment.