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

chore: Migrate Helm chart from the eks-chart repository #1367

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions helm/aws-cloudwatch-metrics/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
17 changes: 17 additions & 0 deletions helm/aws-cloudwatch-metrics/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
name: aws-cloudwatch-metrics
description: A Helm chart to deploy aws-cloudwatch-metrics project
version: 0.0.11
appVersion: "1.300032.2b361"
# TODO - update with Public ECR repository
home: https://github.com/aws/eks-charts
# TODO - update with Public ECR repository
icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png
sources:
# TODO - update with Public ECR repository
- https://github.com/aws/eks-charts
keywords:
- eks
- cloudwatch
- cloudwatch-metrics
- containerinsights
45 changes: 45 additions & 0 deletions helm/aws-cloudwatch-metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# aws-cloudwatch-metrics

A helm chart for CloudWatch Agent to Collect Cluster Metrics

## Installing the Chart

Add the EKS repository to Helm:

```sh
# TODO - update with Public ECR repository
helm repo add eks https://aws.github.io/eks-charts
```

Install or upgrading aws-cloudwatch-metrics chart with default configuration:

```sh
# TODO - update with Public ECR repository
helm upgrade --install aws-cloudwatch-metrics \
--namespace amazon-cloudwatch eks/aws-cloudwatch-metrics \
--set clusterName=my-eks-cluster
```

## Configuration

| Parameter | Description | Default | Required |
| - | - | - | -
| `image.repository` | Image to deploy | `amazon/cloudwatch-agent` | ✔
| `image.tag` | Image tag to deploy | `1.247345.36b249270`
| `image.pullPolicy` | Pull policy for the image | `IfNotPresent` | ✔
| `clusterName` | Name of your cluster | `cluster_name` | ✔
| `enhancedContainerInsights` | EKS cluster with enhanced monitoring | `true` |
| `serviceAccount.create` | Whether a new service account should be created | `true` |
| `serviceAccount.name` | Service account to be used | |
| `hostNetwork` | Allow to use the network namespace and network resources of the node | `false` |
| `nodeSelector` | Node labels for pod assignment | {} |
| `tolerations` | Optional deployment tolerations | {} |
| `annotations` | Optional pod annotations | {} |
| `containerdSockPath` | Path to containerd' socket | /run/containerd/containerd.sock |
| `priorityClassName` | Optional priorityClassName | |
| `statsd.enabled` | Whether the cloudwatch agent should listen for statsd metrics | `false` |
| `statsd.port` | The port listening for statsd metrics | `8125` |
| `statsd.protocol` | The protocol used for statsd metrics | `UDP` |
| `statsd.cloudwatch_namespace` | Optional custom Cloudwatch namespace for statsd metrics | |
| `statsd.metrics_aggregation_interval` | Optional cutom metrics aggregation interval for statsd metrics | |
| `statsd.metrics_collection_interval` | Optional custom metrics collection interval for statsd metrics | |
3 changes: 3 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ .Release.Name }} has been installed or updated. To check the status of pods, run:

kubectl get pods -l app.kubernetes.io/name: {{ include "aws-cloudwatch-metrics.name" . }}
70 changes: 70 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "aws-cloudwatch-metrics.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "aws-cloudwatch-metrics.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "aws-cloudwatch-metrics.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "aws-cloudwatch-metrics.labels" -}}
helm.sh/chart: {{ include "aws-cloudwatch-metrics.chart" . }}
{{ include "aws-cloudwatch-metrics.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "aws-cloudwatch-metrics.selectorLabels" -}}
app.kubernetes.io/name: {{ include "aws-cloudwatch-metrics.name" . }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "aws-cloudwatch-metrics.serviceAccountName" -}}
{{ default (include "aws-cloudwatch-metrics.fullname" .) .Values.serviceAccount.name }}
{{- end -}}

{{/*
Create a config section for StatsD ports.
*/}}
{{- define "aws-cloudwatch-metrics.statsdConfig" -}}
{{- if .Values.statsd.enabled -}}
ports:
- containerPort: {{ .Values.statsd.port }}
hostPort: {{ .Values.statsd.port }}
protocol: {{ .Values.statsd.protocol }}
{{ end -}}
{{- end -}}
24 changes: 24 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
rules:
- apiGroups: [""]
resources: ["pods", "nodes", "endpoints"]
verbs: ["list", "watch"]
- apiGroups: ["apps"]
resources: ["replicasets", "daemonsets", "deployments", "statefulsets"]
verbs: ["list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["nodes/proxy"]
verbs: ["get"]
- apiGroups: [""]
resources: ["nodes/stats", "configmaps", "events"]
verbs: ["create"]
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["cwagent-clusterleader"]
verbs: ["get","update"]
12 changes: 12 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "aws-cloudwatch-metrics.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
40 changes: 40 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
labels:
{{- include "aws-cloudwatch-metrics.labels" . | nindent 4 }}
data:
cwagentconfig.json: |
{
"logs": {
"metrics_collected": {
"kubernetes": {
"cluster_name": "{{ .Values.clusterName }}",
"enhanced_container_insights": {{ .Values.enhancedContainerInsights.enabled }},
"metrics_collection_interval": 60
}
},
"force_flush_interval": 5
{{- if .Values.statsd.enabled }}
},
"metrics": {
{{- if .Values.statsd.cloudwatch_namespace }}
"namespace": "{{- .Values.statsd.cloudwatch_namespace -}}",
{{- end }}
"metrics_collected": {
"statsd": {
{{- if .Values.statsd.metrics_aggregation_interval }}
"metrics_aggregation_interval": {{ .Values.statsd.metrics_aggregation_interval }},
{{- end }}
{{- if .Values.statsd.metrics_collection_interval }}
"metrics_collection_interval": {{ .Values.statsd.metrics_collection_interval }},
{{- end }}
"service_address": ":{{- .Values.statsd.port -}}"
}
}
}
{{- else }}
}
{{- end }}
}
100 changes: 100 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
labels:
{{- include "aws-cloudwatch-metrics.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "aws-cloudwatch-metrics.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "aws-cloudwatch-metrics.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "aws-cloudwatch-metrics.serviceAccountName" . }}
hostNetwork: {{ .Values.hostNetwork }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- include "aws-cloudwatch-metrics.statsdConfig" . | nindent 8 -}}
# Please don't change below envs
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: HOST_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CI_VERSION
value: "k8s/1.3.9"
# Please don't change the mountPath
volumeMounts:
- name: cwagentconfig
mountPath: /etc/cwagentconfig
- name: rootfs
mountPath: /rootfs
readOnly: true
- name: dockersock
mountPath: /var/run/docker.sock
readOnly: true
- name: varlibdocker
mountPath: /var/lib/docker
readOnly: true
- name: containerdsock
mountPath: /run/containerd/containerd.sock
readOnly: true
- name: sys
mountPath: /sys
readOnly: true
- name: devdisk
mountPath: /dev/disk
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 10 }}
volumes:
- name: cwagentconfig
configMap:
name: {{ include "aws-cloudwatch-metrics.fullname" . }}
- name: rootfs
hostPath:
path: /
- name: dockersock
hostPath:
path: /var/run/docker.sock
- name: varlibdocker
hostPath:
path: /var/lib/docker
- name: containerdsock
hostPath:
path: {{ .Values.containerdSockPath }}
- name: sys
hostPath:
path: /sys
- name: devdisk
hostPath:
path: /dev/disk/
terminationGracePeriodSeconds: 60
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
12 changes: 12 additions & 0 deletions helm/aws-cloudwatch-metrics/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "aws-cloudwatch-metrics.serviceAccountName" . }}
labels:
{{- include "aws-cloudwatch-metrics.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
Loading
Loading