Skip to content

Commit

Permalink
Merge pull request #2035 from marioferh/topology_spread_constrains_th…
Browse files Browse the repository at this point in the history
…anos_querier

MON-3181: Expose and propagate TopologySpreadConstraints for thanos-querier
  • Loading branch information
openshift-merge-robot committed Jul 6, 2023
2 parents 60f4899 + 991bf69 commit 01ec473
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
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

0 comments on commit 01ec473

Please sign in to comment.