Skip to content

Instantly share code, notes, and snippets.

@ebuildy
Created May 24, 2021 17:14
Show Gist options
  • Select an option

  • Save ebuildy/1eb9a3f95334e9a458db6c6a7ee5b8e2 to your computer and use it in GitHub Desktop.

Select an option

Save ebuildy/1eb9a3f95334e9a458db6c6a7ee5b8e2 to your computer and use it in GitHub Desktop.
Secure elasticsearch StatefulSet for kubernetes / Helm
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- all.yaml
patchesStrategicMerge:
- |-
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: djobi-metrics-es
spec:
template:
spec:
initContainers:
- name: keystore
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
patchesJson6902:
- target:
group: apps
version: v1
kind: StatefulSet
name: djobi-metrics-es
patch: |-
- op: add
path: /spec/template/spec/volumes/-
value:
name: keystore-es-config
emptyDir: {}
- op: add
path: /spec/template/spec/volumes/-
value:
name: common-tmp
emptyDir: {}
- op: add
path: /spec/template/spec/volumes/-
value:
name: elasticsearch-logs
emptyDir: {}
- op: add
path: /spec/template/spec/initContainers/0/volumeMounts/-
value:
name: keystore-es-config
mountPath: /usr/share/elasticsearch/config
- op: add
path: /spec/template/spec/initContainers/0/volumeMounts/-
value:
name: common-tmp
mountPath: /tmp
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: common-tmp
mountPath: /tmp
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
name: elasticsearch-logs
mountPath: /usr/share/elasticsearch/logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment