From dad2a52b318e7facc2aafbd098ba8418f6819d0e Mon Sep 17 00:00:00 2001 From: Georgi Sabev Date: Wed, 15 Jan 2025 15:47:28 +0000 Subject: [PATCH] Use minimal cluster builder/stack/store for local dev scenario Co-authored-by: Georgi Sabev Co-authored-by: Danail Branekov --- README.helm.md | 3 -- scripts/assets/templates/kind-builder.yml | 44 ++++++++++++++++++++++ scripts/deploy-on-kind.sh | 13 +++++-- scripts/installer/install-korifi-kind.yaml | 2 - 4 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 scripts/assets/templates/kind-builder.yml diff --git a/README.helm.md b/README.helm.md index 83877be08..9019c4622 100644 --- a/README.helm.md +++ b/README.helm.md @@ -101,9 +101,6 @@ Here are all the values that can be set for the chart: - `builderReadinessTimeout` (_String_): The time that the kpack Builder will be waited for if not in ready state, berfore the build workload fails. See [`time.ParseDuration`](https://pkg.go.dev/time#ParseDuration) for details on the format, an additional `d` suffix for days is supported. - `builderRepository` (_String_): Container image repository to store the `ClusterBuilder` image. Required when `clusterBuilderName` is not provided. - `clusterBuilderName` (_String_): The name of the `ClusterBuilder` Kpack has been configured with. Leave blank to let `kpack-image-builder` create an example `ClusterBuilder`. - - `clusterStackBuildImage` (_String_): The image to use for building defined in the `ClusterStack`. Used when `clusterBuilderName` is blank. - - `clusterStackID` (_String_): The ID of the `ClusterStack`. Used when `clusterBuilderName` is blank. - - `clusterStackRunImage` (_String_): The image to use for running defined in the `ClusterStack`. Used when `clusterBuilderName` is blank. - `include` (_Boolean_): Deploy the `kpack-image-builder` component. - `replicas` (_Integer_): Number of replicas. - `resources`: [`ResourceRequirements`](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#resourcerequirements-v1-core) for the API. diff --git a/scripts/assets/templates/kind-builder.yml b/scripts/assets/templates/kind-builder.yml new file mode 100644 index 000000000..1c3012248 --- /dev/null +++ b/scripts/assets/templates/kind-builder.yml @@ -0,0 +1,44 @@ +# This is a template file! Do not apply directly! +# It can be instantiated with values from the environment +# using the envsubst command +--- +apiVersion: kpack.io/v1alpha2 +kind: ClusterStore +metadata: + name: kind-store +spec: + sources: + - image: gcr.io/paketo-buildpacks/procfile + - image: gcr.io/paketo-buildpacks/go +--- +apiVersion: kpack.io/v1alpha2 +kind: ClusterStack +metadata: + name: kind-stack +spec: + id: "io.buildpacks.stacks.jammy" + buildImage: + image: paketobuildpacks/build-jammy-base + runImage: + image: paketobuildpacks/run-jammy-base +--- +apiVersion: kpack.io/v1alpha2 +kind: ClusterBuilder +metadata: + name: kind-builder +spec: + serviceAccountRef: + name: kpack-service-account + namespace: cf + stack: + name: kind-stack + kind: ClusterStack + store: + name: kind-store + kind: ClusterStore + tag: "$BUILDER_TAG" + order: + - group: + - id: paketo-buildpacks/procfile + - group: + - id: paketo-buildpacks/go diff --git a/scripts/deploy-on-kind.sh b/scripts/deploy-on-kind.sh index c76669ce4..24a352f55 100755 --- a/scripts/deploy-on-kind.sh +++ b/scripts/deploy-on-kind.sh @@ -199,9 +199,7 @@ function deploy_korifi() { --set=controllers.taskTTL="5s" \ --set=jobTaskRunner.jobTTL="5s" \ --set=containerRepositoryPrefix="$REPOSITORY_PREFIX" \ - --set=kpackImageBuilder.clusterStackBuildImage="paketobuildpacks/build-jammy-base" \ - --set=kpackImageBuilder.clusterStackRunImage="paketobuildpacks/run-jammy-base" \ - --set=kpackImageBuilder.builderRepository="$KPACK_BUILDER_REPOSITORY" \ + --set=kpackImageBuilder.clusterBuilderName="kind-builder" \ --set=networking.gatewayClass="contour" \ --set=networking.gatewayPorts.http="32080" \ --set=networking.gatewayPorts.https="32443" \ @@ -249,6 +247,14 @@ function create_registry_secret() { --docker-password="$DOCKER_PASSWORD" } +function create_cluster_builder() { + ( + export BUILDER_TAG="$KPACK_BUILDER_REPOSITORY" + envsubst <"$SCRIPT_DIR/assets/templates/kind-builder.yml" | kubectl apply -f - + ) + kubectl wait --for=condition=ready clusterbuilder --all=true --timeout=15m +} + function main() { make -C "$ROOT_DIR" bin/yq @@ -260,6 +266,7 @@ function main() { create_namespaces create_registry_secret deploy_korifi + create_cluster_builder configure_contour } diff --git a/scripts/installer/install-korifi-kind.yaml b/scripts/installer/install-korifi-kind.yaml index 070d2cf98..3908c2da6 100644 --- a/scripts/installer/install-korifi-kind.yaml +++ b/scripts/installer/install-korifi-kind.yaml @@ -112,8 +112,6 @@ spec: --set=controllers.taskTTL="5s" \ --set=jobTaskRunner.jobTTL="5s" \ --set=containerRepositoryPrefix="localregistry-docker-registry.default.svc.cluster.local:30050/" \ - --set=kpackImageBuilder.clusterStackBuildImage="paketobuildpacks/build-jammy-base" \ - --set=kpackImageBuilder.clusterStackRunImage="paketobuildpacks/run-jammy-base" \ --set=kpackImageBuilder.builderRepository="localregistry-docker-registry.default.svc.cluster.local:30050/kpack-builder" \ --set=networking.gatewayClass="contour" \ --set=networking.gatewayPorts.http="32080" \