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

if inside range block not working as expected #366

Open
jaswanth2273 opened this issue Oct 29, 2024 · 1 comment
Open

if inside range block not working as expected #366

jaswanth2273 opened this issue Oct 29, 2024 · 1 comment

Comments

@jaswanth2273
Copy link

deployment yaml file

{{ range .Values.deployments }}
---
{{- if .service.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ .name }}
spec:
  type: {{ .service.type }}
  ports:
    - port: {{ .service.port }}
      targetPort: {{ .service.port }}
  selector:
    app: {{ .name }}
{{- end }}

{{- if .dep.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .name }}
spec:
  replicas: {{ .replicas }}
  selector:
    matchLabels:
      app: {{ .name }}
  template:
    metadata:
      labels:
        app: {{ .name }}
    spec:
      containers:
        - name: {{ .name }}
          image: {{ .image }}
{{- end }}

{{ end }}


values file

deployments:
  - name: dep1
    replicas: 2
    image: dep1-image:latest
    dep:
      enabled: false
    service:
      enabled: false
      type: ClusterIP
      port: 80

  - name: dep2
    replicas: 3
    image: dep2-image:latest
    dep:
      enabled: true
    service:
      enabled: true
      type: ClusterIP
      port: 80
  - name: dep3
    replicas: 1
    image: dep2-image:latest
    dep:
      enabled: true
    service:
      enabled: true
      type: ClusterIP
      port: 80


Helm template output

---
# Source: deploy/templates/depl.yaml
---
apiVersion: v1
kind: Service
metadata:
  name: dep2
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 80
  selector:
    app: dep2
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dep2
spec:
  replicas: 3
  selector:
    matchLabels:
      app: dep2
  template:
    metadata:
      labels:
        app: dep2
    spec:
      containers:
        - name: dep2
          image: dep2-image:latest
---
# Source: deploy/templates/depl.yaml
apiVersion: v1
kind: Service
metadata:
  name: dep3
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 80
  selector:
    app: dep3
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dep3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dep3
  template:
    metadata:
      labels:
        app: dep3
    spec:
      containers:
        - name: dep3
          image: dep2-image:latest

as per values file it needs to create deployment with name dep2 and dep3 and a service for dep2 and dep 3 . but it is not working in this pattern. can you please check this.

@gjenkins8
Copy link
Member

hi 👋 Is this an issue related to the helm CLI? If so, can you please raise over on https://github.com/helm/helm as a Helm issue please

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