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

Missing .spec.serviceName in the Thanos Ruler statefulset #5631

Closed
simonpasquier opened this issue Jun 2, 2023 · 1 comment · Fixed by #5632
Closed

Missing .spec.serviceName in the Thanos Ruler statefulset #5631

simonpasquier opened this issue Jun 2, 2023 · 1 comment · Fixed by #5632

Comments

@simonpasquier
Copy link
Contributor

What happened?

  • Deploy a ThanosRuler resource named foo in namespace default with 1 replica.
  • Resolve the thanos-ruler-foo-0.thanos-operated.default.cluster.local` name inside the Thanos ruler container.

The name can't be resolved.

Did you expect to see something different?

The name should be resolved to the IP of the pod.

How to reproduce it (as minimally and precisely as possible):

See above.

Environment

  • Prometheus Operator version: main

  • Kubernetes version information: N/A

  • Kubernetes cluster kind: N/A

  • Manifests: N/A

  • Prometheus Operator Logs: N/A

Anything else we need to know?:

The operator doesn't set the .spec.serviceName to thanos-operator in the statefulset.

Though the Kubernetes documentation states that service name is mandatory, an empty value is valid (see kubernetes/kubernetes#69608) hence we didn't catch it before. In practice, it only causes an issue if you want to resolve the IP address of an individual pod but to configure a Thanos query, you would use the DNSSRV records of the service which return the expected result.

@simonpasquier
Copy link
Contributor Author

the fix is to add ServiceName: governingServiceName in this block

return &appsv1.StatefulSetSpec{
Replicas: tr.Spec.Replicas,
MinReadySeconds: minReadySeconds,
PodManagementPolicy: appsv1.ParallelPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
Type: appsv1.RollingUpdateStatefulSetStrategyType,
},
Selector: &metav1.LabelSelector{
MatchLabels: finalLabels,
},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: finalLabels,
Annotations: podAnnotations,
},
Spec: v1.PodSpec{
NodeSelector: tr.Spec.NodeSelector,
PriorityClassName: tr.Spec.PriorityClassName,
ServiceAccountName: tr.Spec.ServiceAccountName,
TerminationGracePeriodSeconds: &terminationGracePeriod,
Containers: containers,
InitContainers: tr.Spec.InitContainers,
Volumes: trVolumes,
SecurityContext: tr.Spec.SecurityContext,
Tolerations: tr.Spec.Tolerations,
Affinity: tr.Spec.Affinity,
TopologySpreadConstraints: tr.Spec.TopologySpreadConstraints,
HostAliases: operator.MakeHostAliases(tr.Spec.HostAliases),
},
},
}, nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant