Skip to content

Commit ccd4c17

Browse files
authored
Update Helm Chart to Support CloudWatch Agent on ROSA Clusters (#181)
* added rosa support for cloudwatch agent
1 parent d38ae61 commit ccd4c17

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed

charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml

+36-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ data:
4949

5050
{{- $clusterName := .Values.clusterName | required ".Values.clusterName is required." -}}
5151
{{- $region := .Values.region | required ".Values.region is required." -}}
52-
52+
{{- $isROSA := eq $.Values.k8sMode "ROSA" -}}
5353
{{- range .Values.agents }}
5454
{{- $agent := merge . (deepCopy $.Values.agent) }}
5555
apiVersion: cloudwatch.aws.amazon.com/v1alpha1
@@ -64,6 +64,13 @@ spec:
6464
nodeSelector:
6565
kubernetes.io/os: linux
6666
serviceAccount: {{ $agent.serviceAccount.name | default (include "cloudwatch-agent.serviceAccountName" $) }}
67+
{{ if $isROSA }}
68+
securityContext:
69+
runAsNonRoot: false
70+
capabilities:
71+
add:
72+
- SYS_ADMIN
73+
{{ end }}
6774
priorityClassName: {{ $agent.priorityClassName | default $.Values.agent.priorityClassName }}
6875
affinity:
6976
nodeAffinity:
@@ -111,6 +118,12 @@ spec:
111118
readOnly: true
112119
- mountPath: /run/containerd/containerd.sock
113120
name: containerdsock
121+
- mountPath: /var/run/crio/crio.sock
122+
name: criosock
123+
- mountPath: /var/lib/containers
124+
name: criocontainer
125+
- mountPath: /var/log/pods
126+
name: criologs
114127
- mountPath: /var/lib/docker
115128
name: varlibdocker
116129
readOnly: true
@@ -131,6 +144,10 @@ spec:
131144
readOnly: true
132145
- mountPath: /var/lib/kubelet/pod-resources
133146
name: kubelet-podresources
147+
{{ if $isROSA }}
148+
- mountPath: /etc/kubernetes/kubelet-ca.crt
149+
name: kubelet-ca
150+
{{ end }}
134151
volumes:
135152
- name: kubelet-podresources
136153
hostPath:
@@ -148,6 +165,15 @@ spec:
148165
- hostPath:
149166
path: /run/containerd/containerd.sock
150167
name: containerdsock
168+
- hostPath:
169+
path: /var/run/crio/crio.sock
170+
name: criosock
171+
- hostPath:
172+
path: /var/lib/containers
173+
name: criocontainer
174+
- hostPath:
175+
path: /var/log/pods
176+
name: criologs
151177
- hostPath:
152178
path: /sys
153179
name: sys
@@ -174,6 +200,11 @@ spec:
174200
path: server.crt
175201
- key: tls.key
176202
path: server.key
203+
{{ if $isROSA }}
204+
- name: kubelet-ca
205+
hostPath:
206+
path: /etc/kubernetes/kubelet-ca.crt
207+
{{end }}
177208
env:
178209
- name: K8S_NODE_NAME
179210
valueFrom:
@@ -191,6 +222,10 @@ spec:
191222
valueFrom:
192223
fieldRef:
193224
fieldPath: metadata.namespace
225+
{{ if $isROSA }}
226+
- name: RUN_IN_ROSA
227+
value: "True"
228+
{{ end }}
194229
- name: K8S_CLUSTER_NAME
195230
value: {{ $.Values.clusterName }}
196231
{{- with $.Values.tolerations }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{ if and .Values.agent.enabled (eq .Values.k8sMode "ROSA") }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: system:openshift:scc:cloudwatch-agent-scc
6+
rules:
7+
- apiGroups: [""]
8+
resources: ["securitycontextconstraints"]
9+
verbs: ["use"]
10+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{ if and .Values.agent.enabled (eq .Values.k8sMode "ROSA") }}
2+
apiVersion: security.openshift.io/v1
3+
kind: SecurityContextConstraints
4+
metadata:
5+
name: cloudwatch-agent-scc
6+
allowHostDirVolumePlugin: true
7+
allowHostIPC: false
8+
allowHostNetwork: true
9+
allowHostPID: false
10+
allowHostPorts: true
11+
allowPrivilegeEscalation: true
12+
allowPrivilegedContainer: true
13+
allowedCapabilities: null
14+
readOnlyRootFilesystem: false
15+
runAsUser:
16+
type: RunAsAny
17+
seLinuxContext:
18+
type: RunAsAny
19+
supplementalGroups:
20+
type: RunAsAny
21+
defaultAddCapabilities:
22+
- SYS_ADMIN
23+
fsGroup:
24+
type: RunAsAny
25+
groups: []
26+
requiredDropCapabilities:
27+
- ALL
28+
volumes:
29+
- configMap
30+
- secret
31+
- emptyDir
32+
- hostPath
33+
- projected
34+
users:
35+
- system:serviceaccount:{{ .Release.Namespace }}:{{ template "cloudwatch-agent.serviceAccountName" . }}
36+
37+
38+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{ if and .Values.agent.enabled (eq .Values.k8sMode "ROSA") }}
2+
kind: ClusterRoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: {{ template "cloudwatch-agent.name" . }}-scc-role-binding
6+
roleRef:
7+
kind: ClusterRole
8+
name: system:openshift:scc:cloudwatch-agent-scc
9+
apiGroup: rbac.authorization.k8s.io
10+
subjects:
11+
- kind: ServiceAccount
12+
name: {{ template "cloudwatch-agent.serviceAccountName" . }}
13+
namespace: {{ .Release.Namespace }}
14+
{{- end }}

charts/amazon-cloudwatch-observability/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ nameOverride: ""
1010
clusterName:
1111
## Provide the Region (this is a required parameter)
1212
region:
13+
k8sMode: EKS # can be EKS | ROSA | K8S
1314
nodeLabelKey: node.kubernetes.io/instance-type
1415
fargateLabelKey: eks.amazonaws.com/compute-type
1516
## NVIDIA GPU instance types

0 commit comments

Comments
 (0)