Skip to content

Commit cd01e32

Browse files
Jon Whitcraftk8s-ci-robot
authored andcommitted
Fluentd-Cloudwatch Changes (helm#3229)
* Fluentd-Cloudwatch Changes - Add support for awsRoles vai kube2iam role - Add rbac create support - Standardize helpers with other charts * Fix the lint errors * Forgot to update the secrets * Address Code Review Comments
1 parent 4c18b62 commit cd01e32

File tree

9 files changed

+71
-5
lines changed

9 files changed

+71
-5
lines changed

incubator/fluentd-cloudwatch/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: fluentd-cloudwatch
2-
version: 0.1.2
2+
version: 0.2.0
33
appVersion: 0.1.1
44
description: A Fluentd CloudWatch Helm chart for Kubernetes.
55
icon: https://raw.githubusercontent.com/fluent/fluentd-docs/master/public/logo/Fluentd_square.png

incubator/fluentd-cloudwatch/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This chart bootstraps a [Fluentd](https://www.fluentd.org/) [Cloudwatch](https:/
1515
## Prerequisites
1616

1717
- Kubernetes 1.4+ with Beta APIs enabled
18+
- [kube2iam](../../stable/kube2iam) installed to used the **awsRole** config option
1819

1920
## Installing the Chart
2021

@@ -23,6 +24,8 @@ To install the chart with the release name `my-release`:
2324
```console
2425
$ # edit secrets/aws_access_key_id and secrets/aws_access_key_id with the key/password of a AWS user with a policy to access Cloudwatch
2526
$ helm install --name my-release incubator/fluentd-cloudwatch
27+
$ # or add a role to aws with the correct policy to add to cloud watch
28+
$ helm install --name my-release incubator/fluentd-cloudwatch --set awsRole=roll_name_here
2629
```
2730

2831
The command deploys Fluentd Cloudwatch on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
@@ -53,8 +56,11 @@ The following tables lists the configurable parameters of the Fluentd Cloudwatch
5356
| `hostNetwork` | Host network | `false` |
5457
| `annotations` (removed for now) | Annotations | `nil` |
5558
| `awsRegion` | AWS Cloudwatch region | `us-east-1` |
59+
| `awsRole` | AWS IAM Role To Use | `nil` |
5660
| `fluentdConfig` | Fluentd configuration | `example configuration` |
5761
| `logGroupName` | AWS Cloudwatch log group | `kubernetes` |
62+
| `rbac.create` | If true, create & use RBAC resources | `false` |
63+
| `rbac.serviceAccountName` | existing ServiceAccount to use (ignored if rbac.create=true) | `default` |
5864

5965
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
6066

incubator/fluentd-cloudwatch/templates/_helpers.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Expand the name of the chart.
44
*/}}
55
{{- define "fluentd-cloudwatch.name" -}}
6-
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
77
{{- end -}}
88

99
{{/*
@@ -12,5 +12,6 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
1212
*/}}
1313
{{- define "fluentd-cloudwatch.fullname" -}}
1414
{{- $name := default .Chart.Name .Values.nameOverride -}}
15-
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
1616
{{- end -}}
17+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1beta1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "fluentd-cloudwatch.fullname" . }}
6+
labels:
7+
app: {{ template "fluentd-cloudwatch.name" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
rules:
12+
- apiGroups: [""]
13+
resources: ["fluentd-cloudwatch.namespaces", "pods"]
14+
verbs: ["get", "list", "watch"]
15+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{ if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1beta1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ template "fluentd-cloudwatch.fullname" . }}
6+
labels:
7+
app: {{ template "fluentd-cloudwatch.name" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
subjects:
12+
- kind: ServiceAccount
13+
name: {{ template "fluentd-cloudwatch.fullname" . }}
14+
namespace: {{ .Release.Namespace }}
15+
roleRef:
16+
kind: ClusterRole
17+
name: {{ template "fluentd-cloudwatch.fullname" . }}
18+
apiGroup: rbac.authorization.k8s.io
19+
{{ end }}

incubator/fluentd-cloudwatch/templates/daemonset.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ spec:
1414
app: {{ template "fluentd-cloudwatch.name" . }}
1515
release: "{{ .Release.Name }}"
1616
annotations:
17+
{{ if .Values.awsRole }}iam.amazonaws.com/role: {{ .Values.awsRole }}{{ end }}
18+
{{- if .Values.podAnnotations }}
1719
{{ toYaml .Values.annotations | indent 8 }}
20+
{{- end }}
1821
spec:
22+
serviceAccountName: {{ if .Values.rbac.create }}{{ template "fluentd-cloudwatch.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }}
1923
containers:
2024
- name: {{ template "fluentd-cloudwatch.fullname" . }}
2125
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
@@ -26,7 +30,7 @@ spec:
2630
value: {{ .Values.awsRegion }}
2731
- name: LOG_GROUP_NAME
2832
value: {{ .Values.logGroupName }}
29-
33+
{{- if not .Values.awsRole }}
3034
- name: AWS_ACCESS_KEY_ID
3135
valueFrom:
3236
secretKeyRef:
@@ -37,7 +41,7 @@ spec:
3741
secretKeyRef:
3842
key: aws_secret_access_key
3943
name: {{ template "fluentd-cloudwatch.fullname" . }}
40-
44+
{{- end }}
4145
resources:
4246
{{ toYaml .Values.resources | indent 10 }}
4347
volumeMounts:

incubator/fluentd-cloudwatch/templates/secrets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.awsRole }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
@@ -10,3 +11,4 @@ metadata:
1011
type: Opaque
1112
data:
1213
{{ (.Files.Glob "secrets/*").AsSecrets | indent 2 }}
14+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ template "fluentd-cloudwatch.fullname" . }}
6+
labels:
7+
app: {{ template "fluentd-cloudwatch.name" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
{{- end }}

incubator/fluentd-cloudwatch/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ resources:
2323
annotations: {}
2424

2525
awsRegion: us-east-1
26+
awsRole:
2627
logGroupName: kubernetes
2728

29+
rbac:
30+
## If true, create and use RBAC resources
31+
create: false
32+
33+
## Ignored if rbac.create is true
34+
serviceAccountName: default
35+
2836
fluentdConfig: |
2937
<match fluent.**>
3038
type null

0 commit comments

Comments
 (0)