-
Notifications
You must be signed in to change notification settings - Fork 13
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
The hull.util.transformation.makefullname transformation and and the staticName parameter #273
Comments
@khmarochos First, wishing you a happy new year ;) Short answer is I think you are right, the whole outlook is missing here in the scope of an annotations value. I'll try to explain the concept and give some suggestions at the end on what you may do. There are several angles to object naming in charts and object referencing. The HULL tutorials also contain a section on the topic with some info, you can find it here. Object naming: Main question to ask is whether the particular object instance is only being used inside the helm chart or if it needs to be referred to from some external place outside of the charts scope. You could also think of it as a local or global variable scope in a programing language. The objects that are created in a chart are in my experience mostly only used in the same chart so have local scope. For these object instances it is definitively best to auto-create a "dynamic" name as per the global naming settings ( If you want to create object instances that are important outside of your helm charts scope, it is suitable to add the Object referencing: When refering to objects you may have three scenarios to consider:
For 1.: HULL further supports this standard local scope use case by allowing to reference object names via their instance keys only wherever the context is clearly defined, The places where dynamic names are auto-created from key names automatically are those where references to an object are made by its name:
It is a convenient shortcut to support standard local scope use case. As an example, your application needs some configuration in a configmap and this local scope configmap volume is briefly created with For 2.: An exception to 1. is to assign the If you opt to using a So in the context of objects created within the chart, essentially the In other places where there is no clear indication that a field references an objects name there is the complementary For 3.: The For your concrete question and example: Unlike the list of special fields above, the value of an annotation could be anything. In your example it can't be deduced that you are referering to particular object names. As a suggestion, maybe you can reevaluate if you actually want to have the object instances with
So it depends on what you want to do with your objects which way to go with the current possibilities. Last remark: I can also think of an addition to HULL where you could provide the object type optionally to the Since |
Thank you for the reply! I will carefully read it a bit later, but right now I'd like to apologise for not wishing you a happy new year too! Alas, I've completely forgotten about the New Year and everything related, as it was a pretty vivid night in Kyiv (~100 rockets came from ruzzians). I sat in the basement with my wife and son, they were sleeping and I was playing with HULL and my project, as my work usually helps me to unwind. :-) Will come back to you later, when I have more time to carefully read your answer. Again, thank you for your help and for your project! |
There is absolutely no need to apologize. You have all my sympathies and I miss the words to say how it makes me feel to know you are in that threatening situation. If fiddling with this project gives you some chance to take the mind of things then this is more than I would have ever hoped to achieve with this. And please know your input and the kind way you bring it foward is appreciated with the absolute highest regard. Again, I sincerely wish you all the possible best to you and your family in the new year! |
Hello again! Thank you for such a detailed explanation and, of course, for your understanding and wishes. What I wish you is to never deal with ruzzians; they are dishonourable, treacherous and sneaky enemies. Though their atrocities are out of the topic, let us return to much nicer things. My actual case is actually a bit different than the one I showed before. What I need is to let the user to choose the
I would like to let the user choose any name of the What do you think, what would be the best way to achieve the result that I need? |
...The solution could look somehow like the following: hull:
objects:
serviceaccount:
_my_serviceaccount:
metadataNameOverride: _HT*serviceAccount.name
staticName: _HT?(index . "$").Values.serviceAccount.staticName
deployment:
my-deployment:
pod:
serviceAccountName: >-
_HT!
{{- $parent := (index . "$") -}}
{{- $service_account := $parent.Values.serviceAccount -}}
{{-
ternary
$service_account.name
(include "hull.metadata.fullname" (
dict
"PARENT_CONTEXT" $parent
"COMPONENT" $service_account.name
))
$service_account.staticName
-}}
serviceAccount:
enabled: true
name: my-serviceaccount
staticName: true Though I don't like it at all, to be honest. :-( |
Hi, was trying to exactly understand the logic of your usecase but I think I got it now. This is my understanding:
Questions remaining for me:
So far it looks to me as if you have a little specialized logic, user expectations and outside world dependencies in your scenario which you need to take care of somewhere, I actually find your provided solution with the proxy service account config pretty ingenious and clever if it fits your use case for user configurability. The user has a lightweight (maybe well-known) interface with the It dawns on me that it is the custom code in the pods
could be removed and expressed with simpler inbuilt means? |
Hello! You've got my intention absolutely right! I'd like to let the user use my HULL-powered charts just the same way they use other charts, to set the parameters they used to use and get exactly what they expect. So, let's look again at these 3 parameters: serviceAccount:
enabled: true
name: my-serviceaccount
staticName: true When # added this line to make the object's creation optional:
enabled: _HT*serviceAccount.enabled
# proxy to `serviceAccount.name` just for users' convenience:
metadataNameOverride: _HT*serviceAccount.name
staticName: _HT?(index . "$").Values.serviceAccount.staticName When I don't like the idea of adding a hunk of code to the Thank you for your time and attention to this issue! |
To automatically evaluate an object's name you would need to know
With that information and taking the instances When looking at "name" fields that actually reference some other objects, I think it would be smarter to not make the distinction manually by using
For references of a clearly defined type, the reference type should be set automatically to the name resolution function. For references that are flexible in type (eg. RBAC context) a possibility would need to exist to pass the reference type to the name resolution function. Sounds like an overall smarter approach but could be a some work to implement, especially in a downward compatible way ... also any transformations involved in the creation of the referenced objects name would need to be resolved at the point the reference tself is resolved. I am not sure if this is out of scope of what can be done here in HULL yet but I am willing to try something out and do some experiments. For now to reduce code repetition with existing means could be to try utilizing
If you do this for
|
Thank you very much, I didn't think about utilising It seems that the issue could be considered as closed now. Again, thank you for your help and, of course, for a nice tool. |
Hello!
May I bother you with another question?
Do I understand it right that
hull.util.transformation.makefullname
should return the static name of an object in the case when the object'sstaticName
istrue
? If yes, then are there any exceptions?Here's set of values I'm giving to Helm:
Here are the annotations I get as the result:
I didn't find the answer in the documentation, but I see that
hull.util.transformation.makefullname
callshull.metadata.fullname
andhull.metadata.fullname
, obviously, respects thestaticName
parameter. But it seems thathull.metadata.fullname
doesn't have the whole outlook when it's being called byhull.util.transformation.makefullname
. Am I right?Thank you.
The text was updated successfully, but these errors were encountered: