Skip to content

Commit e0a936e

Browse files
committed
MAJOR: Add CAP_NET_BIND to haproxy binary and remove privileged sysctl
Adding CAP_NET_BIND will allow us to remove privileged container for net.ipv4.ip_unprivileged_port_start sysctl in Helm Chart for rootless container setups and also support GKE Autopilot. This will however cause container to stop working on some older hosts due to CONFIG_AUFS_XATTR not being enabled.
1 parent a28bf0e commit e0a936e

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

build/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ ENV S6_READ_ONLY_ROOT=1
4747
COPY /fs /
4848
COPY --from=builder /src/fs/haproxy-ingress-controller .
4949

50-
RUN apk --no-cache add socat openssl util-linux htop tzdata curl && \
50+
RUN apk --no-cache add socat openssl util-linux htop tzdata curl libcap && \
5151
rm -f /usr/local/bin/dataplaneapi /usr/bin/dataplaneapi && \
5252
chgrp -R haproxy /usr/local/etc/haproxy /run /var && \
5353
chmod -R ug+rwx /usr/local/etc/haproxy /run /var && \
54+
setcap 'cap_net_bind_service=+ep' /usr/local/sbin/haproxy && \
5455
case "${TARGETPLATFORM}" in \
5556
"linux/arm64") S6_ARCH=aarch64 ;; \
5657
"linux/amd64") S6_ARCH=amd64 ;; \
@@ -67,6 +68,7 @@ RUN apk --no-cache add socat openssl util-linux htop tzdata curl && \
6768
mkdir /var/run/s6 && \
6869
chown haproxy:haproxy /var/run/s6 && \
6970
chmod ug+rwx /var/run/s6 && \
70-
sed -i 's/ root / haproxy /g' /etc/s6/init/init-stage2-fixattrs.txt
71+
sed -i 's/ root / haproxy /g' /etc/s6/init/init-stage2-fixattrs.txt && \
72+
chmod ugo+x /etc/services.d/*/run /etc/cont-init.d/*
7173

7274
ENTRYPOINT ["/start.sh"]

deploy/haproxy-ingress-daemonset.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,6 @@ spec:
203203
valueFrom:
204204
fieldRef:
205205
fieldPath: metadata.namespace
206-
initContainers:
207-
- name: sysctl
208-
image: busybox:musl
209-
command:
210-
- /bin/sh
211-
- -c
212-
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
213-
securityContext:
214-
privileged: true
215206
---
216207
apiVersion: v1
217208
kind: Service

deploy/haproxy-ingress.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,6 @@ spec:
201201
valueFrom:
202202
fieldRef:
203203
fieldPath: metadata.namespace
204-
initContainers:
205-
- name: sysctl
206-
image: busybox:musl
207-
command:
208-
- /bin/sh
209-
- -c
210-
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
211-
securityContext:
212-
privileged: true
213204
---
214205
apiVersion: v1
215206
kind: Service

deploy/tests/config/4.ingress-controller.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@ spec:
6161
valueFrom:
6262
fieldRef:
6363
fieldPath: metadata.namespace
64-
initContainers:
65-
- name: sysctl
66-
image: busybox:musl
67-
command:
68-
- /bin/sh
69-
- -c
70-
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
71-
securityContext:
72-
privileged: true
7364
---
7465
apiVersion: v1
7566
kind: Service

0 commit comments

Comments
 (0)