-
Notifications
You must be signed in to change notification settings - Fork 24
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
Logic to generate default cluster_name if not supplied #80
Conversation
{{- if empty .Values.clusterName }} | ||
{{- default "" (printf "k8s-cluster-%s" (sha256sum .Release.Name | trunc 7)) }} | ||
{{- else }} | ||
{{- default "" .Values.clusterName }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt lines 12-16 the same as
{{- default (printf "k8s-cluster-%s" (sha256sum .Release.Name | trunc 7)) .Values.clusterName }}
?
{{- if empty .Values.region }} | ||
{{- fail "region is a required field" }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the built in required
func, Lines 1-3 can instead be:
{{- $region := .Values.region | required ".Values.region is required." -}}
@@ -28,7 +31,7 @@ spec: | |||
- name: AWS_REGION | |||
value: {{ .Values.region }} | |||
- name: CLUSTER_NAME | |||
value: {{ .Values.clusterName | quote }} | |||
value: {{ include "kubernetes-cluster.name" . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@movence doesnt this bring back the bug you fixed for numeric only cluster names not being quoted?
{{- end }} | ||
|
||
{{/* | ||
Helper function to modify cloudwatch-agent config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats diff between the two funcs below?
I would have expected a generic helper function that takes a config (either user provided or default) as an input and then just merges region & cluster name on top of that.
.Values.agent.config | injectRegionAndClusterName | toJson | quote
.Values.agent.defaultConfig | injectRegionAndClusterName | toJson | quote
|
||
## Provide the Region (optional when installing via EKS add-on) | ||
region: AWS_REGION_NAME | ||
## Provide the Region |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the comments on these saying this is required and the cluster name is optional and we generate one if not provdied
*/}} | ||
{{- define "kubernetes-cluster.name" -}} | ||
{{- if empty .Values.clusterName }} | ||
{{- default "" (printf "k8s-cluster-%s" (sha256sum .Release.Name | trunc 7)) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the release name unique enough for our purposes here? Is a hash good enough or do we need randomness?
If the same release is installed on multiple clusters with the same name, wont all the clusters have the same hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, and we should add some randomness to it.
Description of changes:
Testing
cluster_name is not provided, attaching snippets rather than the entire YAML
cluster_name is provided via the helm chart, attaching snippets rather than the entire YAML
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.