Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #18873 to 7.x: Allow the Docker image to be run with a random user id (#12905) #19555

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ field. You can revert this change by configuring tags for the module and omittin
- Add support for fixed length extraction in `dissect` processor. {pull}17191[17191]
- Update RPM packages contained in Beat Docker images. {issue}17035[17035]
- Add TLS support to Kerberos authentication in Elasticsearch. {pull}18607[18607]
- Change ownership of files in docker images so they can be used in secured environments. {pull}12905[12905]
- Upgrade k8s.io/client-go and k8s keystore tests. {pull}18817[18817]
- Add support for multiple sets of hints on autodiscover {pull}18883[18883]

Expand Down
5 changes: 3 additions & 2 deletions deploy/kubernetes/auditbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ spec:
path: /etc
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: auditbeat-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: auditbeat-daemonset-modules
- name: data
hostPath:
# When auditbeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/auditbeat-data
type: DirectoryOrCreate
- name: run-containerd
Expand Down
5 changes: 3 additions & 2 deletions deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ spec:
path: /etc
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: auditbeat-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: auditbeat-daemonset-modules
- name: data
hostPath:
# When auditbeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/auditbeat-data
type: DirectoryOrCreate
- name: run-containerd
Expand Down
3 changes: 2 additions & 1 deletion deploy/kubernetes/filebeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ spec:
volumes:
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: filebeat-config
- name: varlibdockercontainers
hostPath:
Expand All @@ -123,6 +123,7 @@ spec:
# data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
- name: data
hostPath:
# When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/filebeat-data
type: DirectoryOrCreate
---
Expand Down
3 changes: 2 additions & 1 deletion deploy/kubernetes/filebeat/filebeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
volumes:
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: filebeat-config
- name: varlibdockercontainers
hostPath:
Expand All @@ -79,5 +79,6 @@ spec:
# data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
- name: data
hostPath:
# When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/filebeat-data
type: DirectoryOrCreate
9 changes: 5 additions & 4 deletions deploy/kubernetes/metricbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ spec:
path: /var/run/docker.sock
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-daemonset-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-daemonset-modules
- name: data
hostPath:
# When metricbeat runs as non-root user, this directory needs to be writable by group (g+w)
path: /var/lib/metricbeat-data
type: DirectoryOrCreate
---
Expand Down Expand Up @@ -302,11 +303,11 @@ spec:
volumes:
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-deployment-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-deployment-modules
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
5 changes: 3 additions & 2 deletions deploy/kubernetes/metricbeat/metricbeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ spec:
path: /var/run/docker.sock
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-daemonset-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-daemonset-modules
- name: data
hostPath:
# When metricbeat runs as non-root user, this directory needs to be writable by group (g+w)
path: /var/lib/metricbeat-data
type: DirectoryOrCreate
4 changes: 2 additions & 2 deletions deploy/kubernetes/metricbeat/metricbeat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ spec:
volumes:
- name: config
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-deployment-config
- name: modules
configMap:
defaultMode: 0600
defaultMode: 0640
name: metricbeat-deployment-modules
4 changes: 2 additions & 2 deletions dev-tools/packaging/templates/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN chmod 755 /usr/local/bin/docker-entrypoint
RUN groupadd --gid 1000 {{ .BeatName }}

RUN mkdir {{ $beatHome }}/data {{ $beatHome }}/logs && \
chown -R root:{{ .BeatName }} {{ $beatHome }} && \
chown -R root:root {{ $beatHome }} && \
find {{ $beatHome }} -type d -exec chmod 0750 {} \; && \
find {{ $beatHome }} -type f -exec chmod 0640 {} \; && \
chmod 0750 {{ $beatBinary }} && \
Expand All @@ -43,7 +43,7 @@ RUN mkdir {{ $beatHome }}/data {{ $beatHome }}/logs && \
chmod 0770 {{ $beatHome }}/data {{ $beatHome }}/logs

{{- if ne .user "root" }}
RUN useradd -M --uid 1000 --gid 1000 --home {{ $beatHome }} {{ .user }}
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }}
{{- end }}
USER {{ .user }}

Expand Down