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

Configure IC root filesystem as read-only #3548

Merged
merged 1 commit into from
Mar 16, 2023
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
36 changes: 36 additions & 0 deletions deployments/daemon-set/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault
# fsGroup: 101 #nginx
sysctls:
- name: "net.ipv4.ip_unprivileged_port_start"
value: "0"
# volumes:
# - name: nginx-etc
# emptyDir: {}
# - name: nginx-cache
# emptyDir: {}
# - name: nginx-lib
# emptyDir: {}
# - name: nginx-log
# emptyDir: {}
containers:
- image: nginx/nginx-ingress:3.0.2
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -54,10 +64,20 @@ spec:
# memory: "1Gi"
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
capabilities:
drop:
- ALL
# volumeMounts:
# - mountPath: /etc/nginx
# name: nginx-etc
# - mountPath: /var/cache/nginx
# name: nginx-cache
# - mountPath: /var/lib/nginx
# name: nginx-lib
# - mountPath: /var/log/nginx
# name: nginx-log
env:
- name: POD_NAMESPACE
valueFrom:
Expand All @@ -76,3 +96,19 @@ spec:
#- -external-service=nginx-ingress
#- -enable-prometheus-metrics
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
# initContainers:
# - image: nginx/nginx-ingress:3.0.2
# imagePullPolicy: IfNotPresent
# name: init-nginx-ingress
# command: ['cp', '-vdR', '/etc/nginx/.', '/mnt/etc']
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
# - ALL
# volumeMounts:
# - mountPath: /mnt/etc
# name: nginx-etc
36 changes: 36 additions & 0 deletions deployments/daemon-set/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault
# fsGroup: 101 #nginx
sysctls:
- name: "net.ipv4.ip_unprivileged_port_start"
value: "0"
# volumes:
# - name: nginx-etc
# emptyDir: {}
# - name: nginx-cache
# emptyDir: {}
# - name: nginx-lib
# emptyDir: {}
# - name: nginx-log
# emptyDir: {}
containers:
- image: nginx-plus-ingress:3.0.2
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -54,10 +64,20 @@ spec:
# memory: "1Gi"
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
capabilities:
drop:
- ALL
# volumeMounts:
# - mountPath: /etc/nginx
# name: nginx-etc
# - mountPath: /var/cache/nginx
# name: nginx-cache
# - mountPath: /var/lib/nginx
# name: nginx-lib
# - mountPath: /var/log/nginx
# name: nginx-log
env:
- name: POD_NAMESPACE
valueFrom:
Expand All @@ -79,3 +99,19 @@ spec:
#- -external-service=nginx-ingress
#- -enable-prometheus-metrics
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
# initContainers:
# - image: nginx/nginx-ingress:3.0.2
# imagePullPolicy: IfNotPresent
# name: init-nginx-ingress
# command: ['cp', '-vdR', '/etc/nginx/.', '/mnt/etc']
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
# - ALL
# volumeMounts:
# - mountPath: /mnt/etc
# name: nginx-etc
36 changes: 36 additions & 0 deletions deployments/deployment/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault
# fsGroup: 101 #nginx
sysctls:
- name: "net.ipv4.ip_unprivileged_port_start"
value: "0"
# volumes:
# - name: nginx-etc
# emptyDir: {}
# - name: nginx-cache
# emptyDir: {}
# - name: nginx-lib
# emptyDir: {}
# - name: nginx-log
# emptyDir: {}
containers:
- image: nginx/nginx-ingress:3.0.2
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -53,11 +63,21 @@ spec:
# memory: "1Gi"
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
- ALL
# volumeMounts:
# - mountPath: /etc/nginx
# name: nginx-etc
# - mountPath: /var/cache/nginx
# name: nginx-cache
# - mountPath: /var/lib/nginx
# name: nginx-lib
# - mountPath: /var/log/nginx
# name: nginx-log
env:
- name: POD_NAMESPACE
valueFrom:
Expand All @@ -78,3 +98,19 @@ spec:
#- -external-service=nginx-ingress
#- -enable-prometheus-metrics
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
# initContainers:
# - image: nginx/nginx-ingress:3.0.2
# imagePullPolicy: IfNotPresent
# name: init-nginx-ingress
# command: ['cp', '-vdR', '/etc/nginx/.', '/mnt/etc']
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
# - ALL
# volumeMounts:
# - mountPath: /mnt/etc
# name: nginx-etc
36 changes: 36 additions & 0 deletions deployments/deployment/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault
# fsGroup: 101 #nginx
sysctls:
- name: "net.ipv4.ip_unprivileged_port_start"
value: "0"
# volumes:
# - name: nginx-etc
# emptyDir: {}
# - name: nginx-cache
# emptyDir: {}
# - name: nginx-lib
# emptyDir: {}
# - name: nginx-log
# emptyDir: {}
containers:
- image: nginx-plus-ingress:3.0.2
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -55,11 +65,21 @@ spec:
# memory: "1Gi"
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
- ALL
# volumeMounts:
# - mountPath: /etc/nginx
# name: nginx-etc
# - mountPath: /var/cache/nginx
# name: nginx-cache
# - mountPath: /var/lib/nginx
# name: nginx-lib
# - mountPath: /var/log/nginx
# name: nginx-log
env:
- name: POD_NAMESPACE
valueFrom:
Expand All @@ -84,3 +104,19 @@ spec:
#- -enable-prometheus-metrics
#- -enable-service-insight
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
# initContainers:
# - image: nginx/nginx-ingress:3.0.2
# imagePullPolicy: IfNotPresent
# name: init-nginx-ingress
# command: ['cp', '-vdR', '/etc/nginx/.', '/mnt/etc']
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
# - ALL
# volumeMounts:
# - mountPath: /mnt/etc
# name: nginx-etc
1 change: 1 addition & 0 deletions deployments/helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Parameter | Description | Default
`controller.podDisruptionBudget.maxUnavailable` | The number of Ingress Controller pods that can be unavailable. This is a mutually exclusive setting with "minAvailable". | 0
`controller.strategy` | Specifies the strategy used to replace old Pods with new ones. Docs for [Deployment update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) and [Daemonset update strategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) | {}
`controller.disableIPV6` | Disable IPV6 listeners explicitly for nodes that do not support the IPV6 stack. | false
`controller.readOnlyRootFilesystem` | Configure root filesystem as read-only and add volumes for temporary data. | false
`rbac.create` | Configures RBAC. | true
`prometheus.create` | Expose NGINX or NGINX Plus metrics in the Prometheus format. | true
`prometheus.port` | Configures the port to scrape the metrics. | 9113
Expand Down
50 changes: 47 additions & 3 deletions deployments/helm-chart/templates/controller-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
securityContext:
seccompProfile:
type: RuntimeDefault
{{- if .Values.controller.readOnlyRootFilesystem }}
fsGroup: 101 #nginx
{{- end }}
sysctls:
- name: "net.ipv4.ip_unprivileged_port_start"
value: "0"
Expand All @@ -61,9 +64,19 @@ spec:
affinity:
{{ toYaml .Values.controller.affinity | indent 8 }}
{{- end }}
{{- if or .Values.controller.volumes .Values.nginxServiceMesh.enable }}
{{- if or .Values.controller.readOnlyRootFilesystem .Values.nginxServiceMesh.enable .Values.controller.volumes }}
volumes:
{{- end }}
{{- if .Values.controller.readOnlyRootFilesystem }}
- name: nginx-etc
emptyDir: {}
- name: nginx-cache
emptyDir: {}
- name: nginx-lib
emptyDir: {}
- name: nginx-log
emptyDir: {}
{{- end }}
{{- if .Values.nginxServiceMesh.enable }}
- hostPath:
path: /run/spire/sockets
Expand Down Expand Up @@ -116,14 +129,25 @@ spec:
{{- end }}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: {{ .Values.controller.readOnlyRootFilesystem }}
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
- ALL
{{- if or .Values.controller.volumeMounts .Values.nginxServiceMesh.enable }}
{{- if or .Values.controller.readOnlyRootFilesystem .Values.nginxServiceMesh.enable .Values.controller.volumeMounts }}
volumeMounts:
{{- end }}
{{- if .Values.controller.readOnlyRootFilesystem }}
- mountPath: /etc/nginx
name: nginx-etc
- mountPath: /var/cache/nginx
name: nginx-cache
- mountPath: /var/lib/nginx
name: nginx-lib
- mountPath: /var/log/nginx
name: nginx-log
sigv marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- if .Values.nginxServiceMesh.enable }}
- mountPath: /run/spire/sockets
name: spire-agent-socket
Expand Down Expand Up @@ -239,8 +263,28 @@ spec:
{{- if .Values.controller.extraContainers }}
{{ toYaml .Values.controller.extraContainers | nindent 6 }}
{{- end }}
{{- if or .Values.controller.readOnlyRootFilesystem .Values.controller.initContainers }}
initContainers:
{{- end }}
{{- if .Values.controller.readOnlyRootFilesystem }}
- name: init-{{ include "nginx-ingress.name" . }}
image: {{ include "nginx-ingress.image" . }}
imagePullPolicy: "{{ .Values.controller.image.pullPolicy }}"
command: ['cp', '-vdR', '/etc/nginx/.', '/mnt/etc']
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
- ALL
volumeMounts:
- mountPath: /mnt/etc
name: nginx-etc
{{- end }}
{{- if .Values.controller.initContainers }}
initContainers: {{ toYaml .Values.controller.initContainers | nindent 8 }}
{{ toYaml .Values.controller.initContainers | indent 6 }}
{{- end }}
{{- if .Values.controller.strategy }}
updateStrategy:
Expand Down
Loading