-
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
Changes from all commits
af414ca
8d6639b
9c4061f
05790c8
3b49c1e
48bce9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,66 @@ Expand the name of the chart. | |
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Name of k8s cluster | ||
*/}} | ||
{{- define "kubernetes-cluster.name" -}} | ||
{{- if empty .Values.clusterName }} | ||
{{- default "" (printf "k8s-cluster-%s" (sha256sum .Release.Name | trunc 7)) }} | ||
{{- else }} | ||
{{- default "" .Values.clusterName }} | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isnt lines 12-16 the same as
? |
||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Helper function to modify cloudwatch-agent config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats diff between the two funcs below?
|
||
*/}} | ||
{{- define "cloudwatch-agent.config-modifier" -}} | ||
{{- $configCopy := deepCopy .Values.agent.config }} | ||
|
||
{{- $agent := pluck "agent" $configCopy | first }} | ||
{{- if and (empty $agent) (empty $agent.region) }} | ||
{{- $agent := set $agent "region" .Values.region }} | ||
{{- end }} | ||
|
||
{{- $appSignals := pluck "app_signals" $configCopy.logs.metrics_collected | first }} | ||
{{- if empty $appSignals.hosted_in }} | ||
{{- $appSignals := set $appSignals "hosted_in" (include "kubernetes-cluster.name" .) }} | ||
{{- end }} | ||
|
||
{{- $containerInsights := pluck "kubernetes" $configCopy.logs.metrics_collected | first }} | ||
{{- if empty $containerInsights.cluster_name }} | ||
{{- $containerInsights := set $containerInsights "cluster_name" (include "kubernetes-cluster.name" .) }} | ||
{{- end }} | ||
|
||
{{- default "" $configCopy | toJson | quote }} | ||
{{- end }} | ||
|
||
{{/* | ||
Helper function to modify customer supplied agent config if ContainerInsights or ApplicationSignals is enabled | ||
*/}} | ||
{{- define "cloudwatch-agent.supplied-config" -}} | ||
{{- if or (hasKey .Values.agent.config.logs "app_signals") (and (hasKey .Values.agent.config.logs "metrics_collected") (hasKey .Values.agent.config.logs.metrics_collected "kubernetes")) }} | ||
{{- include "cloudwatch-agent.config-modifier" . }} | ||
{{- else }} | ||
{{- default "" .Values.agent.config | toJson | quote }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Helper function to modify default agent config | ||
*/}} | ||
{{- define "cloudwatch-agent.modify-default-config" -}} | ||
{{- $configCopy := deepCopy .Values.agent.defaultConfig }} | ||
{{- $agentRegion := dict "region" .Values.region }} | ||
{{- $agent := set $configCopy "agent" $agentRegion }} | ||
{{- $appSignals := pluck "app_signals" $configCopy.logs.metrics_collected | first }} | ||
{{- $appSignals := set $appSignals "hosted_in" (include "kubernetes-cluster.name" .) }} | ||
{{- $containerInsights := pluck "kubernetes" $configCopy.logs.metrics_collected | first }} | ||
{{- $containerInsights := set $containerInsights "cluster_name" (include "kubernetes-cluster.name" .) }} | ||
{{- default "" $configCopy | toJson | quote }} | ||
{{- end }} | ||
|
||
{{/* | ||
Name for cloudwatch-agent | ||
*/}} | ||
|
@@ -56,7 +116,7 @@ Common labels | |
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: EKS | ||
app.kubernetes.io/managed-by: "amazon-cloudwatch-agent-operator" | ||
{{- end }} | ||
|
||
{{/* | ||
|
@@ -113,4 +173,4 @@ Define the default service name | |
*/}} | ||
{{- define "amazon-cloudwatch-observability.webhookServiceName" -}} | ||
{{- default (printf "%s-webhook-service" (include "amazon-cloudwatch-observability.name" .)) .Values.manager.service.name }} | ||
{{- end -}} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{{- if empty .Values.region }} | ||
{{- fail "region is a required field" }} | ||
{{- end }} | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the built in
|
||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
|
@@ -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 commentThe 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? |
||
- name: READ_FROM_HEAD | ||
value: "Off" | ||
- name: READ_FROM_TAIL | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,11 @@ nameOverride: "" | |
## Reference one or more secrets to be used when pulling images from authenticated repositories. | ||
imagePullSecrets: [ ] | ||
|
||
## Provide the ClusterName (optional when installing via EKS add-on) | ||
clusterName: EKS_CLUSTER_NAME | ||
## Provide the ClusterName | ||
clusterName: | ||
|
||
## 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 commentThe 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 |
||
region: | ||
|
||
containerLogs: | ||
enabled: true | ||
|
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.