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

MON-3181: Expose and propagate TopologySpreadConstraints for thanos-querier #2035

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/api.md
Expand Up @@ -542,6 +542,7 @@ The `ThanosQuerierConfig` resource defines settings for the Thanos Querier compo
| nodeSelector | map[string]string | Defines the nodes on which the pods are scheduled. |
| resources | *[v1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#resourcerequirements-v1-core) | Defines resource requests and limits for the Thanos Querier container. |
| tolerations | [][v1.Toleration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#toleration-v1-core) | Defines tolerations for the pods. |
| topologySpreadConstraints | []v1.TopologySpreadConstraint | Defines a pod's topology spread constraints. |

[Back to TOC](#table-of-contents)

Expand Down
2 changes: 2 additions & 0 deletions Documentation/openshiftdocs/modules/thanosquerierconfig.adoc
Expand Up @@ -30,6 +30,8 @@ Appears in: link:clustermonitoringconfiguration.adoc[ClusterMonitoringConfigurat

|tolerations|[]v1.Toleration|Defines tolerations for the pods.

|topologySpreadConstraints|[]v1.TopologySpreadConstraint|Defines a pod's topology spread constraints.

|===

link:../index.adoc[Back to TOC]
4 changes: 4 additions & 0 deletions pkg/manifests/manifests.go
Expand Up @@ -2799,6 +2799,10 @@ func (f *Factory) ThanosQuerierDeployment(grpcTLS *v1.Secret, enableUserWorkload
if len(f.config.ClusterMonitoringConfiguration.ThanosQuerierConfig.Tolerations) > 0 {
d.Spec.Template.Spec.Tolerations = f.config.ClusterMonitoringConfiguration.ThanosQuerierConfig.Tolerations
}
if len(f.config.ClusterMonitoringConfiguration.ThanosQuerierConfig.TopologySpreadConstraints) > 0 {
d.Spec.Template.Spec.TopologySpreadConstraints =
f.config.ClusterMonitoringConfiguration.ThanosQuerierConfig.TopologySpreadConstraints
}

return d, nil
}
Expand Down
31 changes: 30 additions & 1 deletion pkg/manifests/manifests_test.go
Expand Up @@ -3348,7 +3348,14 @@ func TestThanosQuerierConfiguration(t *testing.T) {
memory: 4Mi
logLevel: debug
enableRequestLogging: true
enableCORS: true`, false)
enableCORS: true
topologySpreadConstraints:
- maxSkew: 1
topologyKey: type
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
foo: bar`, false)

if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -3391,6 +3398,28 @@ func TestThanosQuerierConfiguration(t *testing.T) {
})
}

for _, tc := range []struct {
name string
want, got interface{}
}{
{
name: "Topology",
want: []v1.TopologySpreadConstraint{
{
MaxSkew: 1,
WhenUnsatisfiable: "DoNotSchedule",
},
},
got: d.Spec.Template.Spec.TopologySpreadConstraints[0],
},
} {
t.Run(tc.name, func(t *testing.T) {
if reflect.DeepEqual(tc.got, tc.want) {
t.Errorf("thanos-querier topology spread contraints WhenUnsatisfiable not configured correctly: want %+v, got %+v", tc.want, tc.got)
}
})
}

kubeRbacProxyTLSCipherSuitesArg := ""
kubeRbacProxyMinTLSVersionArg := ""
for _, c := range d.Spec.Template.Spec.Containers {
Expand Down
2 changes: 2 additions & 0 deletions pkg/manifests/types.go
Expand Up @@ -270,6 +270,8 @@ type ThanosQuerierConfig struct {
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
// Defines tolerations for the pods.
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// Defines a pod's topology spread constraints.
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// The `NodeExporterConfig` resource defines settings for the `node-exporter` agent.
Expand Down