Skip to content

Commit

Permalink
neonvm: Move runner image env var into YAML (#988)
Browse files Browse the repository at this point in the history
For neondatabase/cloud#10177, we want to be able to override the
neonvm-runner image that the controller uses *after* it's built and the
YAML is generated.

To do this, we need to actually define the runner image in the YAML
somewhere.

This commit:

1. Moves VM_RUNNER_IMAGE env var from the neonvm-controller dockerfile
   into its Pod spec.
2. Adds neonvm-runner-image-loader to neonvm.yaml (required for 1)
  • Loading branch information
sharnoff authored Jun 25, 2024
1 parent e009065 commit 1de4aa4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 0 additions & 3 deletions neonvm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -tags
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot

ARG VM_RUNNER_IMAGE=runner:dev
ENV VM_RUNNER_IMAGE=${VM_RUNNER_IMAGE}

WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
Expand Down
2 changes: 2 additions & 0 deletions neonvm/config/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ spec:
- "--failure-pending-period=1m"
- "--failing-refresh-interval=15s"
env:
- name: VM_RUNNER_IMAGE
value: $(VM_RUNNER_IMAGE) # will be replaced by kustomize based on neonvm-runner-image-loader image
- name: NAD_IPAM_NAME
value: $(NAD_IPAM_NAME)
- name: NAD_IPAM_NAMESPACE
Expand Down
10 changes: 9 additions & 1 deletion neonvm/config/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namePrefix: neonvm-
# someName: someValue

bases:
- namespace
- crd
- rbac
- controller
Expand All @@ -24,12 +23,21 @@ bases:
- vxlan-controller
- network
- device-plugin
- ../runner-image-loader

patchesStrategicMerge:
- webhookcainjection_patch.yaml

# the following config is for teaching kustomize how to do var substitution
vars:
- name: VM_RUNNER_IMAGE # full name of the neonvm-runner image
objref:
kind: DaemonSet
name: runner-image-loader
group: apps
version: v1
fieldref:
fieldpath: spec.template.spec.containers.[name=neonvm-runner-loader].image
- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
objref:
kind: Certificate
Expand Down
4 changes: 4 additions & 0 deletions neonvm/runner-image-loader/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ spec:
name: neonvm-runner-image-loader
spec:
containers:
# NOTE: this image is referenced by kustomize in order to set the value of the
# neonvm-controller's VM_RUNNER_IMAGE env var. We do it that way so that we can use
# 'kustomize edit image' to set the runner image, even if it does require some
# spooky action at a distance.
- image: runner:dev
name: neonvm-runner-loader
command: ["sh", "-c", "echo 'image loaded and container started' && sleep 100d"]
Expand Down

0 comments on commit 1de4aa4

Please sign in to comment.