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

Chart: Admission controller name too long #11350

Open
OriBenHur-akeyless opened this issue May 8, 2024 · 22 comments
Open

Chart: Admission controller name too long #11350

OriBenHur-akeyless opened this issue May 8, 2024 · 22 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@OriBenHur-akeyless
Copy link

What happened:
I'm getting this error while trying to deploy ingress-nginx
Service "<some_prfix>-<cluster_name>-ingress-nginx-controller-admission" is invalid: metadata.name: Invalid value: "<some_prfix>-<cluster_name>-ingress-nginx-controller-admission": must be no more than 63 characters

What you expected to happen:
The name should be truncated on the 63-char

seems like this part is not working for some reason

{{- define "ingress-nginx.controller.fullname" -}}
{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

@OriBenHur-akeyless OriBenHur-akeyless added the kind/bug Categorizes issue or PR as related to a bug. label May 8, 2024
@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority labels May 8, 2024
@longwuyuan
Copy link
Contributor

/remove-kind bug
/kind support

  • its a spec that is NOT defined by this controller
  • its inherited from the K8S KEP
  • its not a bug

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. and removed kind/bug Categorizes issue or PR as related to a bug. labels May 8, 2024
@longwuyuan
Copy link
Contributor

There is also likely a previous issue that explains usage of the 63 chars and how many chars are available for the name

@longwuyuan
Copy link
Contributor

#7442 (comment)

@OriBenHur-akeyless
Copy link
Author

The bug is not about the error the bug is that the trunc function is not working here for some reason it should have truncated the name but for some reason, it did not, probably there is some other logic somewhere that blocks it. I've confirmed that the truck function itself is working so it's not something in Helm itself

@longwuyuan
Copy link
Contributor

ok.

How did you install. Can you provide the exact command as used in real. Asking because I see this

% helm install ingress-nginx-2-01234567890123456789012345678901234567890123456789 ingress-nginx/ingress-nginx
--namespace ingress-nginx-2
--set controller.ingressClassResource.name=nginx-two
--set controller.ingressClass=nginx-two
--set controller.ingressClassResource.controllerValue="example.com/ingress-nginx-2"
--set controller.ingressClassResource.enabled=true
--set controller.ingressClassByName=true
Error: INSTALLATION FAILED: release name "ingress-nginx-2-01234567890123456789012345678901234567890123456789": invalid release name, must match regex ^a-z0-9?(.a-z0-9?)*$ and the length must not be longer than 53

@OriBenHur-akeyless
Copy link
Author

OriBenHur-akeyless commented May 8, 2024

Nothing too fancy
helm install my_very_long_release_name ingress-nginx/ingress-nginx -n ingress-nginx --create-namespace -f values.yaml

it actually being installed using argocd but the release name is long, it's composed of a ${tenant}-${clusterName}-${environment}

values.yaml

controller:
  ingressClassResource:
    name: my-nginx-class
  scope:
    namespaceSelector: "nginx=this"
  service:
    loadBalancerIP: SOME_IP
    externalTrafficPolicy: Local
  autoscaling:
    enabled: true
    minReplicas: 2

  topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app.kubernetes.io/name: ingress-nginx

  resources:
    requests:
      memory: 200Mi

@longwuyuan
Copy link
Contributor

Thank you for the info. It creates action item.

Can you try a helm install with as close a template match to the argo install please. Need to know the error message as I can not reproduce a Argo install to debug this.

@OriBenHur-akeyless
Copy link
Author

OriBenHur-akeyless commented May 9, 2024

This is the exact command that matches the ArgoCD install
Please keep in mind that argo is running helm template and applies the resulting objects to Kubernetes.
so it might have something to do with the helm template mechanism

@longwuyuan
Copy link
Contributor

longwuyuan commented May 9, 2024

How do I test and reproduce what you said about trunc function not working ?
I thought that seeing your helm command, with the exact string-literal, that Argo would render, for those name prefix vars, would help. But neither you provided that debug info nor I can guess the literals used in the hypothetical helm command.

I also tested a potentially similar helm command and sent you the command and output, by simulating a 60+ chars name prefix. But the error message there is not hinting at truncating name. The error message in my test is actually denying creation of a helm-release, which I think is expected and fair behavior.

Regardless of the tool being Argo or Helm or Flux or Kubectl or even the in-cluster-client, all of them will ultimately post some JSON payload to API-Server. So to get a action-item from this triaging, that shows that trunc function is not working, I had assumed, I could look at your hypothetical helm command, that actually uses the real and complete string-literal, for the prefix (and the output of that command).

@OriBenHur-akeyless
Copy link
Author

OriBenHur-akeyless commented May 9, 2024

As i said argo is doing helm template and applies the resulting object

helm template vary-long-company-name-production-us-west1-gke ingress-nginx/ingress-nginx -f values.yaml --debug -s templates/controller-service-webhook.yaml

you can see that the resulting name is longer than 63 chars

@longwuyuan
Copy link
Contributor

Thank you. That helps.

Now any chance you can do the helm install with this and copy/paste both the command you typed and also the output of the command. I think this request will come across to you as pointless. But to me this will concur with the test I did.

@OriBenHur-akeyless
Copy link
Author

OriBenHur-akeyless commented May 9, 2024

command:

helm install vary-long-company-name-production-us-west1-gke ingress-nginx/ingress-nginx -f /tmp/values.yaml

Output:

Error: 1 error occurred:
	* Service "vary-long-company-name-production-us-west1-gke-ingress-nginx-co-admission" is invalid: metadata.name: Invalid value: "vary-long-company-name-production-us-west1-gke-ingress-nginx-co-admission": must be no more than 63 characters

command:

helm template vary-long-company-name-production-us-west1-gke ingress-nginx/ingress-nginx -f /tmp/values.yaml  -s templates/controller-service-webhook.yaml

Output:

---
# Source: ingress-nginx/templates/controller-service-webhook.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    helm.sh/chart: ingress-nginx-4.10.1
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: vary-long-company-name-production-us-west1-gke
    app.kubernetes.io/version: "1.10.1"
    app.kubernetes.io/part-of: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: controller
  name: vary-long-company-name-production-us-west1-gke-ingress-nginx-co-admission
  namespace: default
spec:
  type: ClusterIP
  ports:
    - name: https-webhook
      port: 443
      targetPort: webhook
      appProtocol: https
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/instance: vary-long-company-name-production-us-west1-gke
    app.kubernetes.io/component: controller

@longwuyuan
Copy link
Contributor

thank you very much @OriBenHur-akeyless this helps.
This concurs with what is done is CI pipeline althought I have to check if there is a test for 63+ chars.

Also it looks like there is a bug in dealing with this use-case because the I am confused if truncating was attempted. As visible, the string "co" in the name generally renders as the full word "controller". Checking

@Gacko any comments. I think the truncating is conditional and we dont have a test-case where we check for this use-case.

@OriBenHur-akeyless its not my place to tell you what to do and your design seems reasonable by normal management standards. But what we have here is a commentable situation. I think that regardless of the truncating getting fixed in the template of the controller by the project, because any service name anywhere in any system needs to integrate with service discovery mechanisms, the vast populace has not faced this situation owing to using other ways to get uniqe self-explanatory names. So you could also consider shorter prefixes in your design. I think your design helps a ton as a label in monitoring and tracing obviously but its a tradeoff when it comes to RFCs.

Please wait for any other comments. I am waiting for @Gacko 's remarks as well. I will also check if the trunc of helm https://helm.sh/docs/chart_template_guide/function_list/#trunc has to honor some conditions, unlike the trunc of linux shell command

@longwuyuan
Copy link
Contributor

/triage accepted
/kind bug

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. kind/bug Categorizes issue or PR as related to a bug. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 10, 2024
@longwuyuan
Copy link
Contributor

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority labels May 10, 2024
@adrianmoisey
Copy link

As per this suggestion: #7442 (comment)
Would you accept a PR truncating the name to 52 characters?

I'm happy to make that change if needed.

@longwuyuan
Copy link
Contributor

cc @tao12345666333 @rikatz
I am not the best person to comment on such a PR

@Gacko
Copy link
Member

Gacko commented May 23, 2024

No, please do not truncate to a hardcoded length. We added truncating for the admission webhook job here: #10523. I already noticed this is not happening for other names while working on this PR, so in the end it's not perfect, yes, but neither is truncating, as this can also lead to ambiguous names.

@adrianmoisey
Copy link

Does it make sense to add some sort of validation? If some names are longer than allowed, get Helm to bail out?

@Gacko
Copy link
Member

Gacko commented May 23, 2024

Hm, I wouldn't go this way and rather try to align the way we are doing it for the admission webhook jobs (including a template which truncates names) for other occurrences. I know, this isn't perfect as it could lead to ambiguous names, but still better than the current situation.

@Gacko
Copy link
Member

Gacko commented May 23, 2024

/assign

@Gacko
Copy link
Member

Gacko commented May 23, 2024

/retitle Chart: Admission controller name too long

@k8s-ci-robot k8s-ci-robot changed the title admission controller name is more then 63 chars Chart: Admission controller name too long May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/support Categorizes issue or PR as a support question. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

No branches or pull requests

5 participants