-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCO-585: MCO-569: MCO-563: MCO-586: Introduces BuildController #3731
Merged
openshift-merge-robot
merged 9 commits into
openshift:master
from
cheesesashimi:zzlotnik/buildcontroller-interface
Jul 20, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f036845
Add structures defining pool-owned build resources
jkyros 3a4f2d4
Add build controller for layered/image builds
jkyros 010a23a
controller/common: image stream helpers and consts
jkyros d27c3df
Adds some constants for layering and a helper.
jkyros c20970c
we longer have 'legacy' OS containers
cheesesashimi a2cf458
vendor deps
cheesesashimi 692f814
introduces buildcontroller with image builder backends
cheesesashimi bfb4468
remove skopeo dependency for custom build pod
cheesesashimi 48ac23e
adds podman builder and clarifies buildah
cheesesashimi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
pkg/controller/build/assets/Dockerfile.on-cluster-build-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This Dockerfile is not intended to be directly built. Instead, it is embedded | ||
# within the Build Controller binary (see //go:embed) and templatized with | ||
# certain options around base image pullspecs. | ||
# | ||
# Decode and extract the MachineConfig from the gzipped ConfigMap and move it | ||
# into position. We do this in a separate stage so that we don't have the | ||
# gzipped MachineConfig laying around. | ||
FROM {{.BaseImage.Pullspec}} AS extract | ||
COPY ./machineconfig/machineconfig.json.gz /tmp/machineconfig.json.gz | ||
RUN mkdir -p /etc/machine-config-daemon && \ | ||
cat /tmp/machineconfig.json.gz | base64 -d | gunzip - > /etc/machine-config-daemon/currentconfig | ||
|
||
{{if .ExtensionsImage.Pullspec}} | ||
# Pull our extensions image. Not sure yet what / how this should be wired up | ||
# though. Ideally, I'd like to use some Buildah tricks to have the extensions | ||
# directory mounted into the container at build-time so that I don't have to | ||
# copy the RPMs into the container, configure the repo, and do the | ||
# installation. Alternatively, I'd have to start a pod with an HTTP server. | ||
FROM {{.ExtensionsImage.Pullspec}} AS extensions | ||
{{end}} | ||
|
||
|
||
FROM {{.BaseImage.Pullspec}} AS final | ||
# Copy the extracted MachineConfig into the expected place in the image. | ||
COPY --from=extract /etc/machine-config-daemon/currentconfig /etc/machine-config-daemon/currentconfig | ||
# Do the ignition live-apply, extracting the Ignition config from the MachineConfig. | ||
RUN exec -a ignition-apply /usr/lib/dracut/modules.d/30ignition/ignition --ignore-unsupported <(cat /etc/machine-config-daemon/currentconfig | jq '.spec.config') && \ | ||
ostree container commit | ||
|
||
LABEL machineconfig={{.Pool.Spec.Configuration.Name}} | ||
LABEL machineconfigpool={{.Pool.Name}} | ||
LABEL releaseversion={{.ReleaseVersion}} | ||
LABEL baseOSContainerImage={{.BaseImage.Pullspec}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# assets | ||
|
||
These files get embedded within the Go binary and are not intended for direct | ||
use. In particular, the Dockerfile is interspersed with Go templates and will | ||
not build unless rendered with a tool such as [Gomplate](https://github.com/hairyhenderson/gomplate). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This script is not meant to be directly executed. Instead, it is embedded | ||
# within the Build Controller binary (see //go:embed) and injected into a | ||
# custom build pod. | ||
set -xeuo | ||
|
||
build_context="$HOME/context" | ||
|
||
# Create a directory to hold our build context. | ||
mkdir -p "$build_context/machineconfig" | ||
|
||
# Copy the Dockerfile and Machineconfigs from configmaps into our build context. | ||
cp /tmp/dockerfile/Dockerfile "$build_context" | ||
cp /tmp/machineconfig/machineconfig.json.gz "$build_context/machineconfig/" | ||
|
||
# Build our image using Buildah. | ||
buildah bud \ | ||
--storage-driver vfs \ | ||
--authfile="$BASE_IMAGE_PULL_CREDS" \ | ||
--tag "$TAG" \ | ||
--file="$build_context/Dockerfile" "$build_context" | ||
|
||
# Push our built image. | ||
buildah push \ | ||
--storage-driver vfs \ | ||
--authfile="$FINAL_IMAGE_PUSH_CREDS" \ | ||
--digestfile="/tmp/done/digestfile" \ | ||
--cert-dir /var/run/secrets/kubernetes.io/serviceaccount "$TAG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This script is not meant to be directly executed. Instead, it is embedded | ||
# within the Build Controller binary (see //go:embed) and injected into a | ||
# custom build pod. | ||
set -xeuo | ||
|
||
build_context="/tmp/context" | ||
|
||
# Create a directory to hold our build context. | ||
mkdir -p "$build_context/machineconfig" | ||
|
||
# Copy the Dockerfile and Machineconfigs from configmaps into our build context. | ||
cp /tmp/dockerfile/Dockerfile "$build_context" | ||
cp /tmp/machineconfig/machineconfig.json.gz "$build_context/machineconfig/" | ||
|
||
# Build our image using Buildah. | ||
podman build \ | ||
--storage-driver vfs \ | ||
--authfile="$BASE_IMAGE_PULL_CREDS" \ | ||
--tag "$TAG" \ | ||
--file="$build_context/Dockerfile" "$build_context" | ||
|
||
# Push our built image. | ||
podman push \ | ||
--storage-driver vfs \ | ||
--authfile="$FINAL_IMAGE_PUSH_CREDS" \ | ||
--digestfile="/tmp/digestfile" \ | ||
--cert-dir /var/run/secrets/kubernetes.io/serviceaccount "$TAG" | ||
|
||
# Store the digestfile in a configmap for future retrieval. | ||
oc create configmap \ | ||
"$DIGEST_CONFIGMAP_NAME" \ | ||
--namespace openshift-machine-config-operator \ | ||
--from-file=digest=/tmp/digestfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This script is not meant to be directly executed. Instead, it is embedded | ||
# within the Build Controller binary (see //go:embed) and injected into a | ||
# custom build pod. | ||
|
||
# Wait until the done file appears. | ||
while [ ! -f "/tmp/done/digestfile" ] | ||
do | ||
sleep 1 | ||
done | ||
|
||
oc create configmap \ | ||
"$DIGEST_CONFIGMAP_NAME" \ | ||
--namespace openshift-machine-config-operator \ | ||
--from-file=digest=/tmp/done/digestfile |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this makes it in before the API Migration does (it probably will) we'll just need to remember to stuff these into the API PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.