forked from kubernetes-sigs/cluster-api-provider-openstack
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Mathieu Tortuyaux <[email protected]> Co-authored-by: Matthew Booth <[email protected]> Signed-off-by: Lennart Jern <[email protected]>
- Loading branch information
1 parent
5d62dd5
commit 427620d
Showing
2 changed files
with
94 additions
and
0 deletions.
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,73 @@ | ||
# 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_LOG=1 \ | ||
-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 \ | ||
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 |