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

Repetitive TemplateName #138

Closed
chriskery opened this issue Mar 26, 2024 · 5 comments
Closed

Repetitive TemplateName #138

chriskery opened this issue Mar 26, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@chriskery
Copy link
Contributor

The source yaml is :

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: myapp
  name: myapp
spec:
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
        - name: proxy-sidecar
          args:
            - --secure-listen-address=0.0.0.0:8443
            - --v=10
          image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
          ports:
            - containerPort: 8443
              name: https
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: myapp
  name: myapp
spec:
  ports:
    - name: https
      port: 8443
      targetPort: https
  selector:
    app: myapp

The resulting Helm template is:

·> cat test_data/sample-app.yaml| go run ./cmd/helmify myapp
git:(chartname) 
cyw@B-Q6U5MD6R-2311:s005->/Users/cyw/GolandProjects/helmify (0)
·> helm template myapp myapp --debug     
---
# Source: myapp/templates/myapp.yaml
apiVersion: v1
kind: Service
metadata:
  name: myapp-myapp
---
# Source: myapp/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-myapp

I wonder if it is always ok to force ```nameTeml = '{{include "%s.fullname".}}-%s'`` for every objName. Normally I would expect ObjName to remain the same if I changed tthe source o Helm Chart, Especially if my chart name is the same as my obj name.

@arttor
Copy link
Owner

arttor commented Mar 27, 2024

This approach allows having multiple releases in the same namespace. Helmify tries to follow Helm best practices so this behaviour was copied from default helm chart generated by helm create command.

@chriskery
Copy link
Contributor Author

This approach allows having multiple releases in the same namespace. Helmify tries to follow Helm best practices so this behaviour was copied from default helm chart generated by helm create command.

Thanks for your replying. But the scenario using Helmify is not the same as a scenario using helm create. When we used Helmify, we had the original yaml file, no matter where I specify helmify's output, I should expect the application deployed to be the same as the one deployed using the original yaml file.

But if we specify ```nameTeml = '{{include "%s.fullname".}}-%s'`, the application deployed with the generated helm chart will be different from the original yaml file.

Perhaps this should at least be an option for the user to decide if they want to change the ObjName ?

@arttor
Copy link
Owner

arttor commented Mar 27, 2024

understood. I still think that name prefix '{{include "%s.fullname".}}' is necessary because Helm release should be in resource name. We can have an option to just use '{{include "%s.fullname".}}' instead of '{{include "%s.fullname".}}-%s' but in this case we will have conflict if there are multiple deployments or services in the chart.

@chriskery
Copy link
Contributor Author

chriskery commented Mar 28, 2024

I'm sorry, I may have had a problem with the way I expressed it. What I mean is whether it is possible to provide an option to use the ResourceName in the original yaml file without adding the prefix of chart (not '{{include "%s.fullname".}}'). In the original yaml file, there will not be two identical deploys with the same ResourceName under the same namespace.

@arttor
Copy link
Owner

arttor commented Mar 28, 2024

I think we can add such option if it will not change default behaviour. I don't have capacity to implement it right now, but i can help with review if someone volunteers implementing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants