mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 16:59:52 +00:00
fix: init container security hardened for operation permission error (#1680)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
{{- $logDir := .Values.config.rustfs.obs_log_directory }}
|
||||||
|
|
||||||
{{- if .Values.mode.standalone.enabled }}
|
{{- if .Values.mode.standalone.enabled }}
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -55,40 +57,36 @@ spec:
|
|||||||
tolerations:
|
tolerations:
|
||||||
{{- toYaml .Values.tolerations | nindent 8 }}
|
{{- toYaml .Values.tolerations | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.podSecurityContext }}
|
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||||
{{- end }}
|
|
||||||
{{- if .Values.imagePullSecrets }}
|
{{- if .Values.imagePullSecrets }}
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
|
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: init-step
|
- name: init-step
|
||||||
image: "{{ .Values.initStep.image.repository }}:{{ .Values.initStep.image.tag }}"
|
image: "{{ .Values.image.initImage.repository }}:{{ .Values.image.initImage.tag }}"
|
||||||
imagePullPolicy: {{ .Values.initStep.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.initImage.pullPolicy }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.initStep.containerSecurityContext | nindent 12 }}
|
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
mkdir -p /data /logs
|
mkdir -p /data /mnt/rustfs/logs
|
||||||
chown 10001:10001 /data /logs
|
chmod 755 /mnt/rustfs/logs
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
- name: logs
|
- name: logs
|
||||||
mountPath: /logs
|
mountPath: /mnt/rustfs
|
||||||
containers:
|
containers:
|
||||||
- name: {{ .Chart.Name }}
|
- name: {{ .Chart.Name }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
image: "{{ .Values.image.rustfs.repository }}:{{ .Values.image.rustfs.tag | default .Chart.AppVersion }}"
|
||||||
command: ["/usr/bin/rustfs"]
|
command: ["/usr/bin/rustfs"]
|
||||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.rustfs.pullPolicy }}
|
||||||
{{- if .Values.containerSecurityContext }}
|
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||||
{{- end }}
|
|
||||||
ports:
|
ports:
|
||||||
- name: endpoint
|
- name: endpoint
|
||||||
containerPort: {{ .Values.service.endpoint.port }}
|
containerPort: {{ .Values.service.endpoint.port }}
|
||||||
@@ -121,14 +119,11 @@ spec:
|
|||||||
failureThreshold: 3
|
failureThreshold: 3
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: logs
|
- name: logs
|
||||||
mountPath: /logs
|
mountPath: {{ $logDir }}
|
||||||
|
subPath: logs
|
||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
- name: tmp
|
|
||||||
mountPath: /tmp
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: tmp
|
|
||||||
emptyDir: {}
|
|
||||||
- name: logs
|
- name: logs
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: {{ include "rustfs.fullname" . }}-logs
|
claimName: {{ include "rustfs.fullname" . }}-logs
|
||||||
|
|||||||
@@ -59,20 +59,18 @@ spec:
|
|||||||
tolerations:
|
tolerations:
|
||||||
{{- toYaml .Values.tolerations | nindent 8 }}
|
{{- toYaml .Values.tolerations | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if .Values.podSecurityContext }}
|
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||||
{{- end }}
|
|
||||||
{{- if .Values.imagePullSecrets }}
|
{{- if .Values.imagePullSecrets }}
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
|
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: init-step
|
- name: init-step
|
||||||
image: "{{ .Values.initStep.image.repository }}:{{ .Values.initStep.image.tag }}"
|
image: "{{ .Values.image.initImage.repository }}:{{ .Values.image.initImage.tag }}"
|
||||||
imagePullPolicy: {{ .Values.initStep.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.initImage.pullPolicy }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.initStep.containerSecurityContext | nindent 12 }}
|
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||||
env:
|
env:
|
||||||
- name: REPLICA_COUNT
|
- name: REPLICA_COUNT
|
||||||
value: {{ .Values.replicaCount | quote }}
|
value: {{ .Values.replicaCount | quote }}
|
||||||
@@ -87,8 +85,8 @@ spec:
|
|||||||
elif [ "$REPLICA_COUNT" -eq 16 ]; then
|
elif [ "$REPLICA_COUNT" -eq 16 ]; then
|
||||||
mkdir -p /data
|
mkdir -p /data
|
||||||
fi
|
fi
|
||||||
mkdir -p {{ $logDir }}
|
mkdir -p /mnt/rustfs/logs
|
||||||
chown 10001:10001 /data {{ $logDir }}
|
chmod 755 /mnt/rustfs/logs
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
{{- if eq (int .Values.replicaCount) 4 }}
|
{{- if eq (int .Values.replicaCount) 4 }}
|
||||||
{{- range $i := until (int .Values.replicaCount) }}
|
{{- range $i := until (int .Values.replicaCount) }}
|
||||||
@@ -100,16 +98,14 @@ spec:
|
|||||||
mountPath: /data
|
mountPath: /data
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- name: logs
|
- name: logs
|
||||||
mountPath: {{ $logDir }}
|
mountPath: /mnt/rustfs
|
||||||
containers:
|
containers:
|
||||||
- name: {{ .Chart.Name }}
|
- name: {{ .Chart.Name }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
image: "{{ .Values.image.rustfs.repository }}:{{ .Values.image.rustfs.tag | default .Chart.AppVersion }}"
|
||||||
command: ["/usr/bin/rustfs"]
|
command: ["/usr/bin/rustfs"]
|
||||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.rustfs.pullPolicy }}
|
||||||
{{- if .Values.containerSecurityContext }}
|
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||||
{{- end }}
|
|
||||||
ports:
|
ports:
|
||||||
- name: endpoint
|
- name: endpoint
|
||||||
containerPort: {{ .Values.service.endpoint.port }}
|
containerPort: {{ .Values.service.endpoint.port }}
|
||||||
@@ -127,10 +123,9 @@ spec:
|
|||||||
readinessProbe:
|
readinessProbe:
|
||||||
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: tmp
|
|
||||||
mountPath: /tmp
|
|
||||||
- name: logs
|
- name: logs
|
||||||
mountPath: {{ $logDir }}
|
mountPath: {{ $logDir }}
|
||||||
|
subPath: logs
|
||||||
{{- if eq (int .Values.replicaCount) 4 }}
|
{{- if eq (int .Values.replicaCount) 4 }}
|
||||||
{{- range $i := until (int .Values.replicaCount) }}
|
{{- range $i := until (int .Values.replicaCount) }}
|
||||||
- name: data-rustfs-{{ $i }}
|
- name: data-rustfs-{{ $i }}
|
||||||
@@ -140,9 +135,6 @@ spec:
|
|||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
{{- end }}
|
{{- end }}
|
||||||
volumes:
|
|
||||||
- name: tmp
|
|
||||||
emptyDir: {}
|
|
||||||
volumeClaimTemplates:
|
volumeClaimTemplates:
|
||||||
- metadata:
|
- metadata:
|
||||||
name: logs
|
name: logs
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: wget
|
- name: wget
|
||||||
image: "{{ .Values.initStep.image.repository }}:{{ .Values.initStep.image.tag }}"
|
image: "{{ .Values.image.initImage.repository }}:{{ .Values.image.initImage.tag }}"
|
||||||
imagePullPolicy: {{ .Values.initStep.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.initImage.pullPolicy }}
|
||||||
command: ['wget']
|
command: ['wget']
|
||||||
args: ['-O', '/dev/null', '{{ include "rustfs.fullname" . }}-svc:{{ .Values.service.endpoint.port }}/health']
|
args: ['-O', '/dev/null', '{{ include "rustfs.fullname" . }}-svc:{{ .Values.service.endpoint.port }}/health']
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
+11
-15
@@ -7,11 +7,16 @@ replicaCount: 4
|
|||||||
|
|
||||||
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
|
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
|
||||||
image:
|
image:
|
||||||
repository: rustfs/rustfs
|
rustfs: # This sets the rustfs image repository and tag.
|
||||||
# This sets the pull policy for images.
|
repository: rustfs/rustfs
|
||||||
pullPolicy: IfNotPresent
|
# This sets the pull policy for images.
|
||||||
# Overrides the image tag whose default is the chart appVersion.
|
pullPolicy: IfNotPresent
|
||||||
tag: ""
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
|
tag: ""
|
||||||
|
initImage: # This sets the init container image repository and tag.
|
||||||
|
repository: busybox
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
tag: "stable"
|
||||||
|
|
||||||
# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
@@ -94,6 +99,7 @@ containerSecurityContext:
|
|||||||
drop:
|
drop:
|
||||||
- ALL
|
- ALL
|
||||||
readOnlyRootFilesystem: true
|
readOnlyRootFilesystem: true
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
|
|
||||||
service:
|
service:
|
||||||
@@ -193,16 +199,6 @@ storageclass:
|
|||||||
dataStorageSize: 256Mi
|
dataStorageSize: 256Mi
|
||||||
logStorageSize: 256Mi
|
logStorageSize: 256Mi
|
||||||
|
|
||||||
# Init container parameters.
|
|
||||||
initStep:
|
|
||||||
image:
|
|
||||||
repository: busybox
|
|
||||||
pullPolicy: IfNotPresent
|
|
||||||
tag: "latest"
|
|
||||||
containerSecurityContext:
|
|
||||||
runAsUser: 0
|
|
||||||
runAsGroup: 0
|
|
||||||
|
|
||||||
pdb:
|
pdb:
|
||||||
create: false
|
create: false
|
||||||
# Minimum number/percentage of pods that should remain scheduled
|
# Minimum number/percentage of pods that should remain scheduled
|
||||||
|
|||||||
Reference in New Issue
Block a user