Skip to content

Commit b71eba6

Browse files
authored
build(controller)!: eliminate policy-controller image (#14348)
Long ago, the policy-controller image shipped with a distroless base image, but we have since been able to remove all runtime dependencies and ship with a scratch image. There's no reason to manage this binary seperately from the rest of the controller. This change moves the controller/Dockerfile to Dockerfile.controller, and it is updated to subsume the policy-controller/Dockerfile. This should *not* impact users, except to reduce the overhead of extra image pulls. BREAKING CHANGE: with this change, we no longer ship a seperate policy-controller image.
1 parent 2fb7bb0 commit b71eba6

38 files changed

+109
-235
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ jobs:
102102
matrix:
103103
component:
104104
- controller
105-
- policy-controller
106105
- proxy
107106
timeout-minutes: 20
108107
steps:
@@ -216,7 +215,6 @@ jobs:
216215
- run: just policy-test-build
217216
- run: just k3d-k8s='${{ matrix.k8s }}' k3d-create
218217
- run: docker load <image-archives/controller.tar
219-
- run: docker load <image-archives/policy-controller.tar
220218
- run: docker load <image-archives/proxy.tar
221219
- run: docker image ls
222220
- run: just linkerd-tag='${{ needs.meta.outputs.tag }}' linkerd-exec="$HOME/linkerd" linkerd-install
@@ -368,7 +366,7 @@ jobs:
368366
bin/scurl -v "https://raw.githubusercontent.com/k3d-io/k3d/${K3D_VERSION}/install.sh" | bash
369367
- name: Load docker images
370368
run: |
371-
for img in controller policy-controller proxy; do
369+
for img in controller proxy; do
372370
docker load <"image-archives/${img}.tar"
373371
done
374372
- run: docker image ls

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ jobs:
4242
component:
4343
- cli-bin
4444
- controller
45-
- policy-controller
4645
- debug
4746
- jaeger-webhook
4847
- metrics-api
4948
- proxy
5049
- tap
5150
- web
52-
# policy-controller docker builds have occasionally hit a 30-minute timeout.
5351
timeout-minutes: 45
5452
steps:
5553
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8

policy-controller/Dockerfile renamed to Dockerfile.controller

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
FROM --platform=$BUILDPLATFORM ghcr.io/linkerd/dev:v47-rust-musl AS controller
1+
# Precompile key slow-to-build dependencies
2+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS go-deps
3+
WORKDIR /linkerd-build
4+
COPY go.mod go.sum ./
5+
COPY bin/install-deps bin/
6+
RUN go mod download
7+
ARG TARGETARCH
8+
RUN ./bin/install-deps $TARGETARCH
9+
10+
## compile controller service
11+
FROM go-deps AS golang
12+
WORKDIR /linkerd-build
13+
COPY controller/gen controller/gen
14+
COPY pkg pkg
15+
COPY charts charts
16+
COPY controller controller
17+
COPY charts/patch charts/patch
18+
COPY charts/partials charts/partials
19+
COPY multicluster multicluster
20+
21+
ARG TARGETARCH
22+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o /out/controller -tags prod -mod=readonly -ldflags "-s -w" ./controller/cmd
23+
24+
FROM --platform=$BUILDPLATFORM ghcr.io/linkerd/dev:v47-rust-musl AS policy
225
ARG BUILD_TYPE="release"
326
WORKDIR /build
427
RUN mkdir -p target/bin
@@ -24,9 +47,17 @@ RUN --mount=type=cache,target=target \
2447
*) echo "unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \
2548
esac) && \
2649
just-cargo CFLAGS_aarch64_unknown_linux_musl="" profile=$BUILD_TYPE target=$target build --package=linkerd-policy-controller && \
27-
mv "target/$target/$BUILD_TYPE/linkerd-policy-controller" /tmp/
50+
mkdir /out && mv "target/$target/$BUILD_TYPE/linkerd-policy-controller" /out/
2851

29-
FROM scratch AS runtime
52+
## package runtime
53+
FROM scratch
3054
LABEL org.opencontainers.image.source=https://github.com/linkerd/linkerd2
31-
COPY --from=controller /tmp/linkerd-policy-controller /bin/
32-
ENTRYPOINT ["/bin/linkerd-policy-controller"]
55+
COPY LICENSE /linkerd/LICENSE
56+
COPY --from=golang /out/controller /controller
57+
COPY --from=policy /out/linkerd-policy-controller /
58+
# for heartbeat (https://versioncheck.linkerd.io/version.json)
59+
COPY --from=golang /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
60+
61+
ARG LINKERD_VERSION
62+
ENV LINKERD_CONTAINER_VERSION_OVERRIDE=${LINKERD_VERSION}
63+
ENTRYPOINT ["/controller"]

bin/_docker.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export SUPPORTED_ARCHS=${SUPPORTED_ARCHS:-linux/amd64,linux/arm64}
3333
export DOCKER_IMAGES=(${DOCKER_IMAGES:-
3434
cli-bin
3535
controller
36-
policy-controller
3736
metrics-api
3837
debug
3938
proxy

bin/_test-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export external_resource_test_names=(external-resources)
1717
# TODO(alpeb): add test cni-calico-deep-dual-stack
1818
export dual_stack_test_names=(deep-dual-stack)
1919
export all_test_names=(cluster-domain cni-calico-deep multicluster "${default_test_names[*]}" "${external_resource_test_names[*]}" "${dual_stack_test_names[*]}")
20-
images_load_default=(proxy controller policy-controller web metrics-api tap)
20+
images_load_default=(proxy controller web metrics-api tap)
2121

2222
tests_usage() {
2323
progname=${0##*/}

bin/docker-build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ bindir=$( cd "${0%/*}" && pwd )
1111

1212
"$bindir"/docker-build-proxy
1313
"$bindir"/docker-build-controller
14-
"$bindir"/docker-build-policy-controller
1514
"$bindir"/docker-build-web
1615
"$bindir"/docker-build-debug
1716
if [ -z "${LINKERD_LOCAL_BUILD_CLI:-}" ]; then

bin/docker-build-controller

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ rootdir=$( cd "$bindir"/.. && pwd )
1515
# shellcheck source=_tag.sh
1616
. "$bindir"/_tag.sh
1717

18-
dockerfile=$rootdir/controller/Dockerfile
19-
docker_build controller "${TAG:-$(head_root_tag)}" "$dockerfile" --build-arg LINKERD_VERSION="${TAG:-$(head_root_tag)}"
18+
docker_build controller "${TAG:-$(head_root_tag)}" "$rootdir/Dockerfile.controller" --build-arg LINKERD_VERSION="${TAG:-$(head_root_tag)}"

bin/docker-build-policy-controller

Lines changed: 0 additions & 20 deletions
This file was deleted.

charts/linkerd-control-plane/templates/destination.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ spec:
337337
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
338338
name: kube-api-access
339339
readOnly: true
340-
- args:
340+
- command: ["/linkerd-policy-controller"]
341+
args:
341342
- --admin-addr={{ if .Values.disableIPv6 }}0.0.0.0{{ else }}[::]{{ end }}:9990
342343
- --control-plane-namespace={{.Release.Namespace}}
343344
- --grpc-addr={{ if .Values.disableIPv6 }}0.0.0.0{{ else }}[::]{{ end }}:8090
@@ -361,8 +362,8 @@ spec:
361362
{{- range .Values.policyController.experimentalArgs }}
362363
- {{ . }}
363364
{{- end }}
364-
image: {{.Values.policyController.image.name}}:{{.Values.policyController.image.version | default .Values.linkerdVersion}}
365-
imagePullPolicy: {{.Values.policyController.image.pullPolicy | default .Values.imagePullPolicy}}
365+
image: {{ .Values.controllerImage }}:{{ .Values.controllerImageVersion | default .Values.linkerdVersion }}
366+
imagePullPolicy: {{ .Values.imagePullPolicy }}
366367
livenessProbe:
367368
httpGet:
368369
path: /live

charts/linkerd-control-plane/values.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,7 @@ runtimeClassName: ""
8080

8181
# policy controller configuration
8282
policyController:
83-
image:
84-
# -- Docker image for the policy controller
85-
name: cr.l5d.io/linkerd/policy-controller
86-
# -- Pull policy for the policy controller container image
87-
# @default -- imagePullPolicy
88-
pullPolicy: ""
89-
# -- Tag for the policy controller container image
90-
# @default -- linkerdVersion
91-
version: ""
83+
# `image` has been removed.
9284

9385
# -- Log level for the policy controller
9486
logLevel: info

0 commit comments

Comments
 (0)