-
Notifications
You must be signed in to change notification settings - Fork 256
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
🌱 Build node images with cloud build #1746
Open
lentzi90
wants to merge
6
commits into
kubernetes-sigs:main
Choose a base branch
from
Nordix:lentzi90/osimage-cloudbuild
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−0
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
427620d
Build node images with cloud build
lentzi90 bc6558b
Add github action
lentzi90 b5a93f3
Reduce logging
lentzi90 a34dac5
Reduce boot_wait
lentzi90 9fe52f4
Use newer ubuntu ISO
lentzi90 979fc28
Test build only ubuntu v1.28.2
lentzi90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: E2E node images | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
paths-ignore: | ||
- '**/*.md' | ||
- 'docs/**' | ||
- '.gitignore' | ||
- 'hack/*.sh' | ||
- 'LICENSE' | ||
- 'SECURITY_CONTACTS' | ||
- 'OWNERS' | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
build: | ||
name: Build and upload node images | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: kubernetes-sigs/image-builder | ||
path: image-builder | ||
ref: v0.1.22 | ||
|
||
- name: Patch image-builder Dockerfile with root user | ||
run: git apply "../osimages/image-builder.patch" | ||
working-directory: "./image-builder" | ||
|
||
- name: Build image-builder image with root user | ||
run: make docker-build | ||
working-directory: "./image-builder/images/capi" | ||
|
||
- name: Build images | ||
env: | ||
OSIMAGE_BUILDER: gcr.io/scl-image-builder/cluster-node-image-builder-amd64:dev | ||
run: make -C osimages -j2 ACCELERATOR=kvm osimage-flatcar-1.27.2 osimage-flatcar-1.28.2 osimage-ubuntu-2204-1.28.2 osimage-ubuntu-2204-1.27.2 | ||
|
||
- name: Upload images | ||
run: make -C osimages osimage-upload |
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,72 @@ | ||
# Copyright 2023 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
REPO_ROOT = $(shell git rev-parse --show-toplevel) | ||
|
||
ARTIFACTS ?= $(REPO_ROOT)/_artifacts | ||
OSIMAGE_DIR ?= $(ARTIFACTS)/osimages | ||
OSIMAGE_BUILDER ?= registry.k8s.io/scl-image-builder/cluster-node-image-builder-amd64:v0.1.20 | ||
STAGING_BUCKET ?= artifacts.k8s-staging-capi-openstack.appspot.com | ||
|
||
DISTROS ?= ubuntu-2204 flatcar | ||
KUBERNETES_VERSIONS ?= 1.28.2 1.27.2 | ||
|
||
# By default, build all distros with all kubernetes versions | ||
all_targets := $(foreach distro,$(DISTROS),$(addprefix osimage-$(distro)-,$(KUBERNETES_VERSIONS))) | ||
all: $(all_targets) | ||
|
||
# Set this to 'none' if kvm is not available | ||
ACCELERATOR ?= kvm | ||
|
||
ifeq ($(ACCELERATOR),kvm) | ||
privileged=--privileged | ||
else | ||
privileged= | ||
endif | ||
|
||
$(OSIMAGE_DIR): | ||
mkdir -p $(OSIMAGE_DIR) | ||
|
||
.PHONY: osimage | ||
osimage: DISTRO ?= ubuntu-2204 | ||
osimage: KUBERNETES_VERSION ?= v1.28.2 | ||
# KUBERNETES_SERIES default to vX.Y from KUBERNETES_VERSION | ||
osimage: KUBERNETES_SERIES ?= $(shell echo $(KUBERNETES_VERSION) | sed 's/\(v[0-9]\+\.[0-9]\+\).[0-9]\+/\1/;tx;q1;:x') | ||
osimage: | $(OSIMAGE_DIR) | ||
docker run --rm $(privileged) \ | ||
--network=host \ | ||
-v "$(OSIMAGE_DIR):/output" \ | ||
-e PACKER_FLAGS=" \ | ||
--var 'boot_wait=300s' \ | ||
--var 'accelerator=$(ACCELERATOR)' \ | ||
--var 'kubernetes_semver=$(KUBERNETES_VERSION)' \ | ||
--var 'kubernetes_series=$(KUBERNETES_SERIES)' \ | ||
" \ | ||
-e OEM_ID=openstack \ | ||
$(OSIMAGE_BUILDER) build-qemu-$(DISTRO) | ||
|
||
# Build a specific image, determined by the name of the target | ||
# e.g. osimage-flatcar-1.26.2 -> DISTRO=flatcar, KUBERNETES_VERSION=v1.26.2 | ||
osimage-%: DISTRO=$(shell echo $@ | sed 's/osimage-\(.*\)-\([^-]*\)/\1/') | ||
osimage-%: KUBERNETES_VERSION=v$(shell echo $@ | sed 's/osimage-\(.*\)-\([^-]*\)/\2/') | ||
osimage-%: FORCE | ||
$(MAKE) osimage DISTRO=$(DISTRO) KUBERNETES_VERSION=$(KUBERNETES_VERSION) | ||
|
||
.PHONY: FORCE | ||
FORCE: | ||
|
||
.PHONY: osimage-upload | ||
osimage-upload: | ||
ls $(OSIMAGE_DIR) | ||
gsutil cp $(OSIMAGE_DIR)/* gs://$(STAGING_BUCKET)/test |
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,21 @@ | ||
# See https://cloud.google.com/cloud-build/docs/build-config | ||
timeout: 7200s | ||
options: | ||
substitution_option: ALLOW_LOOSE | ||
machineType: 'N1_HIGHCPU_32' | ||
steps: | ||
- name: 'docker' | ||
script: | | ||
apk add --update bash git make | ||
cd ./osimages | ||
make -j2 ACCELERATOR=none \ | ||
lentzi90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
osimage-flatcar-1.27.2 \ | ||
osimage-flatcar-1.28.2 \ | ||
osimage-ubuntu-2204-1.28.2 \ | ||
osimage-ubuntu-2204-1.27.2 | ||
id: 'make' | ||
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:latest' | ||
waitFor: ['make'] | ||
script: | | ||
cd ./osimages | ||
make osimage-upload |
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,31 @@ | ||
index 9514c03ae..372b8dfc2 100644 | ||
--- a/images/capi/Dockerfile | ||
+++ b/images/capi/Dockerfile | ||
@@ -38,18 +38,15 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
ARG ARCH | ||
ARG PASSED_IB_VERSION | ||
|
||
-USER imagebuilder | ||
-WORKDIR /home/imagebuilder/ | ||
- | ||
-COPY --chown=imagebuilder:imagebuilder ansible ansible/ | ||
-COPY --chown=imagebuilder:imagebuilder ansible.cfg ansible.cfg | ||
-COPY --chown=imagebuilder:imagebuilder cloudinit cloudinit/ | ||
-COPY --chown=imagebuilder:imagebuilder hack hack/ | ||
-COPY --chown=imagebuilder:imagebuilder packer packer/ | ||
-COPY --chown=imagebuilder:imagebuilder Makefile Makefile | ||
-COPY --chown=imagebuilder:imagebuilder azure_targets.sh azure_targets.sh | ||
- | ||
-ENV PATH="/home/imagebuilder/.local/bin:${PATH}" | ||
+COPY ansible ansible/ | ||
+COPY ansible.cfg ansible.cfg | ||
+COPY cloudinit cloudinit/ | ||
+COPY hack hack/ | ||
+COPY packer packer/ | ||
+COPY Makefile Makefile | ||
+COPY azure_targets.sh azure_targets.sh | ||
+ | ||
+ENV PATH="/root/.local/bin:${PATH}" | ||
ENV PACKER_ARGS '' | ||
ENV PACKER_VAR_FILES '' | ||
ENV IB_VERSION "${PASSED_IB_VERSION}" |
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.
@lentzi90 #1746 (comment) you can change the value here.