Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
[kibana] optionally disable SA token automount (#1301) (#1482)
Browse files Browse the repository at this point in the history
Kibana has no direct interaction with the Kubernetes API, and as such,
it does not need a mounted service account token in its pods. By
disabling this automount, potential attackers cannot access the API on
behalf/through the Pod.

This commit allows users to opt out on SA token automount, but leaves
leaves current behaviour untouched to avoid breaking things.

Signed-off-by: Jorik Jonker <[email protected]>

Co-authored-by: Jorik Jonker <[email protected]>
  • Loading branch information
jmlrt and jonkerj authored Dec 14, 2021
1 parent 0cab81c commit a338798
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions kibana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ as a reference. They are also used in the automated testing of this chart.
| Parameter | Description | Default |
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `affinity` | Configurable [affinity][] | `{}` |
| `automountToken` | Whether or not to automount the service account token in the Pod | `true` |
| `elasticsearchHosts` | The URLs used to connect to Elasticsearch | `http://elasticsearch-master:9200` |
| `envFrom` | Templatable string to be passed to the [environment from variables][] which will be appended to the `envFrom:` definition for the container | `[]` |
| `extraContainers` | Templatable string of additional containers to be passed to the `tpl` function | `""` |
Expand Down
1 change: 1 addition & 0 deletions kibana/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
{{- end }}
spec:
automountServiceAccountToken: {{ .Values.automountToken }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
Expand Down
25 changes: 25 additions & 0 deletions kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,28 @@ def test_hostaliases():
r = helm_template(config)
hostAliases = r["deployment"][name]["spec"]["template"]["spec"]["hostAliases"]
assert {"ip": "127.0.0.1", "hostnames": ["foo.local", "bar.local"]} in hostAliases


def test_default_automount_sa_token():
config = """
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"][
"automountServiceAccountToken"
]
== True
)


def test_disable_automount_sa_token():
config = """
automountToken: false
"""
r = helm_template(config)
assert (
r["deployment"][name]["spec"]["template"]["spec"][
"automountServiceAccountToken"
]
== False
)
3 changes: 3 additions & 0 deletions kibana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ securityContext:

serviceAccount: ""

# Whether or not to automount the service account token in the pod. Normally, Kibana does not need this
automountToken: true

# This is the PriorityClass settings as defined in
# https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
priorityClassName: ""
Expand Down

0 comments on commit a338798

Please sign in to comment.