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

Incorrect labels for StatefulSet selector section #131

Open
andreiionutdamian opened this issue Dec 15, 2023 · 1 comment
Open

Incorrect labels for StatefulSet selector section #131

andreiionutdamian opened this issue Dec 15, 2023 · 1 comment

Comments

@andreiionutdamian
Copy link

The problem is that the StatefulSet are not correctly generated resulting in the service not being able to correctly select coresponding pods. Basically I had this original manifest (part):

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-master
  labels:
    app: redis
    role: master
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
      role: master
  ...

after helmify I received:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: {{ include "sf.fullname" . }}-master
  labels:
    app: redis
    role: master
  {{- include "sf.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.master.replicas }}
  selector:
    matchLabels:
      app: redis
      role: master
  serviceName: ""
  template:
    metadata:
      labels:
        app: redis
        role: master
    ...

So the specs.selector.matchLabels and the spec.template.metadata.labels are missing a {{- include "<chart>.selectorLabels" . | nindent 6 }} while the service template has it as it should. I replicated the identical scenario with Deployment instead of StatefulSet and in the case of Deployment the results are correct as it is supposed to be (and service-pods communication works):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-master
  labels:
    app: redis
    role: master
  {{- include "stateless.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.master.replicas }}
  selector:
    matchLabels:
      app: redis
      role: master
    {{- include "stateless.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app: redis
        role: master
      {{- include "stateless.selectorLabels" . | nindent 8 }}
@arttor
Copy link
Owner

arttor commented Jan 2, 2024

Thank you for reporting the issue. I see that StatefulSet processor is not up to date with Deployment. Probably, it makes sense to have a single processor for both StatefulSet and Deployment or copy label processing logic from Deployment to StatefulSet as a quick fix.

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

No branches or pull requests

2 participants