Skip to content

Commit f90c11a

Browse files
committed
BUILD/MAJOR: replace s6 with pebble
s6 is giving us some issues, so decision was made to move to pebble init system
1 parent 9a7f602 commit f90c11a

File tree

29 files changed

+170
-90
lines changed

29 files changed

+170
-90
lines changed

build/Dockerfile

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ COPY /go.mod /src/go.mod
2020
COPY /go.sum /src/go.sum
2121
RUN cd /src && go mod download
2222

23+
RUN go install github.com/canonical/pebble/cmd/pebble@v1.25.0
24+
2325
COPY / /src
2426

2527
RUN mkdir -p /var/run/vars && \
@@ -48,40 +50,26 @@ ENV S6_USER=haproxy
4850
ENV S6_GROUP=haproxy
4951

5052
COPY /fs /
53+
COPY --from=builder /go/bin/pebble /usr/local/bin
5154
COPY --from=builder-c /src/libblock_secrets.so /usr/local/lib/libblock_secrets.so
5255
COPY --from=builder-c /src/haproxy_wrapper /usr/local/sbin/haproxy_wrapper
5356

5457
RUN apk --no-cache add socat openssl util-linux htop tzdata curl libcap && \
5558
rm -f /usr/local/bin/dataplaneapi /usr/bin/dataplaneapi /etc/haproxy/dataplaneapi.yml && \
5659
rm -f /usr/local/bin/dataplaneapi-v2 /usr/bin/dataplaneapi-v2 && \
5760
rm -f /etc/haproxy/haproxy.cfg && \
61+
rm usr/local/hug/defaults.go && \
5862
mkdir -p /usr/local/hug/aux && \
63+
mkdir -p /var/run/haproxy && \
5964
chgrp -R haproxy /usr/local/hug && \
6065
chmod -R ug+rwx /usr/local/hug && \
61-
chown -R "${S6_USER}:${S6_GROUP}" /usr/local/etc/haproxy /run /var && \
66+
chown -R "haproxy:haproxy" /usr/local/etc/haproxy /run /var && \
6267
chmod -R ug+rwx /usr/local/etc/haproxy /run /var && \
6368
chmod u+rx /usr/local/sbin/haproxy_wrapper && \
64-
setcap 'cap_net_bind_service=+ep' /usr/local/sbin/haproxy_wrapper && \
65-
case "${TARGETPLATFORM}" in \
66-
"linux/arm64") S6_ARCH=aarch64 ;; \
67-
"linux/amd64") S6_ARCH=x86_64 ;; \
68-
"linux/arm/v6") S6_ARCH=arm ;; \
69-
"linux/arm/v7") S6_ARCH=armhf ;; \
70-
"linux/ppc64") S6_ARCH=powerpc64 ;; \
71-
"linux/ppc64le") S6_ARCH=powerpc64le ;; \
72-
"linux/486") S6_ARCH=i486 ;; \
73-
"linux/686") S6_ARCH=i686 ;; \
74-
*) echo "ARG TARGETPLATFORM undeclared" >&2 && exit 1 ;; \
75-
esac && \
76-
curl -sS -L -o /tmp/s6-overlay-scripts.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" && \
77-
tar -C / -Jxpf /tmp/s6-overlay-scripts.tar.xz && \
78-
curl -sS -L -o /tmp/s6-overlay-binaries.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" && \
79-
tar -C / -Jxpf /tmp/s6-overlay-binaries.tar.xz && \
80-
rm -f /tmp/s6-overlay-scripts.tar.xz /tmp/s6-overlay-binaries.tar.xz && \
81-
chown -R "${S6_USER}:${S6_GROUP}" /init /etc/s6-overlay && \
82-
chmod u+x /init /etc/s6-overlay/scripts/* && \
83-
rm -rf /var/lib/pebble
84-
85-
COPY --from=builder /src/fs/kubernetes-controller .
69+
setcap 'cap_net_bind_service=+ep' /usr/local/sbin/haproxy_wrapper
70+
71+
COPY --from=builder /src/fs/kubernetes-controller /usr/local/sbin/hug
72+
73+
STOPSIGNAL SIGTERM
8674

8775
ENTRYPOINT ["/start.sh"]

build/Dockerfile.dev

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
FROM golang:1.25-alpine AS builder
15+
16+
RUN apk --no-cache add git openssh
17+
RUN go install github.com/canonical/pebble/cmd/pebble@v1.25.0
1418

1519
FROM haproxytech/haproxy-alpine:3.2 AS builder-c
1620
RUN apk add --no-cache build-base gcc musl-dev
@@ -25,13 +29,8 @@ FROM haproxytech/haproxy-alpine:3.2
2529

2630
ARG TARGETPLATFORM
2731

28-
ARG S6_OVERLAY_VERSION=3.1.6.2
29-
ENV S6_OVERLAY_VERSION=$S6_OVERLAY_VERSION
30-
ENV S6_READ_ONLY_ROOT=1
31-
ENV S6_USER=haproxy
32-
ENV S6_GROUP=haproxy
33-
3432
COPY /fs /
33+
COPY --from=builder /go/bin/pebble /usr/local/bin
3534
COPY --from=builder-c /src/libblock_secrets.so /usr/local/lib/libblock_secrets.so
3635
COPY --from=builder-c /src/haproxy_wrapper /usr/local/sbin/haproxy_wrapper
3736

@@ -43,33 +42,18 @@ RUN apk --no-cache add socat openssl util-linux htop tzdata curl libcap && \
4342
rm -f /usr/local/bin/dataplaneapi /usr/bin/dataplaneapi /etc/haproxy/dataplaneapi.yml && \
4443
rm -f /usr/local/bin/dataplaneapi-v2 /usr/bin/dataplaneapi-v2 && \
4544
rm -f /etc/haproxy/haproxy.cfg && \
45+
rm usr/local/hug/defaults.go && \
4646
mkdir -p /usr/local/hug/aux && \
47+
mkdir -p /var/run/haproxy && \
4748
chgrp -R haproxy /usr/local/hug && \
4849
chmod -R ug+rwx /usr/local/hug && \
49-
chown -R "${S6_USER}:${S6_GROUP}" /usr/local/etc/haproxy /run /var && \
50+
chown -R "haproxy:haproxy" /usr/local/etc/haproxy /run /var && \
5051
chmod -R ug+rwx /usr/local/etc/haproxy /run /var && \
5152
chmod u+rx /usr/local/sbin/haproxy_wrapper && \
52-
setcap 'cap_net_bind_service=+ep' /usr/local/sbin/haproxy_wrapper && \
53-
case "${TARGETPLATFORM}" in \
54-
"linux/arm64") S6_ARCH=aarch64 ;; \
55-
"linux/amd64") S6_ARCH=x86_64 ;; \
56-
"linux/arm/v6") S6_ARCH=arm ;; \
57-
"linux/arm/v7") S6_ARCH=armhf ;; \
58-
"linux/ppc64") S6_ARCH=powerpc64 ;; \
59-
"linux/ppc64le") S6_ARCH=powerpc64le ;; \
60-
"linux/486") S6_ARCH=i486 ;; \
61-
"linux/686") S6_ARCH=i686 ;; \
62-
*) echo "ARG TARGETPLATFORM undeclared" >&2 && exit 1 ;; \
63-
esac && \
64-
curl -sS -L -o /tmp/s6-overlay-scripts.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz" && \
65-
tar -C / -Jxpf /tmp/s6-overlay-scripts.tar.xz && \
66-
curl -sS -L -o /tmp/s6-overlay-binaries.tar.xz "https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz" && \
67-
tar -C / -Jxpf /tmp/s6-overlay-binaries.tar.xz && \
68-
rm -f /tmp/s6-overlay-scripts.tar.xz /tmp/s6-overlay-binaries.tar.xz && \
69-
chown -R "${S6_USER}:${S6_GROUP}" /init /etc/s6-overlay && \
70-
chmod u+x /init /etc/s6-overlay/scripts/* && \
71-
rm -rf /var/lib/pebble
53+
setcap 'cap_net_bind_service=+ep' /usr/local/sbin/haproxy_wrapper
54+
55+
COPY build/kubernetes-controller /usr/local/sbin/hug
7256

73-
COPY build/kubernetes-controller ./kubernetes-controller
57+
STOPSIGNAL SIGTERM
7458

7559
ENTRYPOINT ["/start.sh"]

cmd/controller/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func main() {
6969
params := haproxyparams.Params{
7070
Test: hugConfig.Test,
7171
UseWiths6Overlay: hugConfig.UseWiths6Overlay,
72+
UseWithPebble: hugConfig.UseWithPebble,
7273
HaproxyDirs: hugConfig.HaproxyDirs,
7374
}
7475
p := process.New(params, haproxyClient, gateconfig.Logger)
@@ -107,7 +108,7 @@ func main() {
107108
cntlr.Configuration.Logger.Info("Context cancelled: shutting down controller")
108109
cntlr.Configuration.Logger.Info("Graceful shutdown requested...")
109110

110-
// Stop your controller logic
111+
// Stop controller logic if its still running
111112
haproxyAppManager.Stop()
112113

113114
// Wait for background goroutines to finish

example/deploy/hug/controller.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ spec:
3030
memory: 2560Mi
3131
requests:
3232
memory: 2048Mi
33+
lifecycle:
34+
preStop:
35+
exec:
36+
# Send SIGUSR1 directly to the haproxy process
37+
command: ["/bin/sh", "-c", "kill -SIGUSR1 $(cat /var/run/haproxy.pid)"]
3338
args:
3439
# specify the hugconf CRD location, all other params are in configuration file
3540
- --hugconf-crd=haproxy-unified-gateway/hugconf

fs/etc/s6-overlay/s6-rc.d/haproxy/dependencies.d/base

Whitespace-only changes.

fs/etc/s6-overlay/s6-rc.d/haproxy/dependencies.d/sigusr1

Whitespace-only changes.

fs/etc/s6-overlay/s6-rc.d/haproxy/type

Lines changed: 0 additions & 1 deletion
This file was deleted.

fs/etc/s6-overlay/s6-rc.d/kubernetes-controller/dependencies.d/base

Whitespace-only changes.

fs/etc/s6-overlay/s6-rc.d/kubernetes-controller/dependencies.d/haproxy

Whitespace-only changes.

fs/etc/s6-overlay/s6-rc.d/kubernetes-controller/dependencies.d/sigusr1

Whitespace-only changes.

0 commit comments

Comments
 (0)