aws / eks-charts

Amazon EKS Helm chart repository
Apache License 2.0
1.21k stars 984 forks source link

Add support for EKS ContainerD Runtime in CloudWatch Metrics charts #638

Open fitchtech opened 3 years ago

fitchtech commented 3 years ago

The latest release of the aws-cloudwatch-metrics chart does not work on EKS when using the ContainerD runtime on EKS node groups. Need the ability to set the volumeMounts and volumes hostPath in the daemonset.yaml

https://github.com/aws/eks-charts/blob/v0.0.68/stable/aws-cloudwatch-metrics/templates/daemonset.yaml

More details on the issue here: https://github.com/aws/amazon-cloudwatch-agent/issues/188 https://github.com/aws/amazon-cloudwatch-agent/issues/261

I cloned the charts and modified the daemonset.yaml to get it working for me. However, it'd be preferable if the Helm chart had a value to select what runtime is being used and set the volume paths accordingly.

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 }}
        # 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.2.2"
#
# Below shows the ContainerD sock volume mount and host path
#
        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: /run/dockershim.sock
        - name: sys
          hostPath:
            path: /sys
        - name: devdisk
          hostPath:
            path: /dev/disk/
      terminationGracePeriodSeconds: 60
muellerk22 commented 3 years ago

@fitchtech , thanks for this as I ran into same issue.

stv-io commented 2 years ago

This seems to be fixed (or at least improved / supported) in https://github.com/aws/eks-charts/pull/706