Skip to content

Commit

Permalink
MAJOR: Add CAP_NET_BIND to haproxy binary and remove privileged sysctl
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dkorunic committed Apr 27, 2022
1 parent a28bf0e commit e0a936e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
6 changes: 4 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ ENV S6_READ_ONLY_ROOT=1
COPY /fs /
COPY --from=builder /src/fs/haproxy-ingress-controller .

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

ENTRYPOINT ["/start.sh"]
9 changes: 0 additions & 9 deletions deploy/haproxy-ingress-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
initContainers:
- name: sysctl
image: busybox:musl
command:
- /bin/sh
- -c
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
securityContext:
privileged: true
---
apiVersion: v1
kind: Service
Expand Down
9 changes: 0 additions & 9 deletions deploy/haproxy-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
initContainers:
- name: sysctl
image: busybox:musl
command:
- /bin/sh
- -c
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
securityContext:
privileged: true
---
apiVersion: v1
kind: Service
Expand Down
9 changes: 0 additions & 9 deletions deploy/tests/config/4.ingress-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
initContainers:
- name: sysctl
image: busybox:musl
command:
- /bin/sh
- -c
- sysctl -w net.ipv4.ip_unprivileged_port_start=0
securityContext:
privileged: true
---
apiVersion: v1
kind: Service
Expand Down

0 comments on commit e0a936e

Please sign in to comment.