Skip to content

Commit

Permalink
Merge pull request #143 from crossplane-contrib/backport-142-to-relea…
Browse files Browse the repository at this point in the history
…se-0.11

[Backport release-0.11] makefile: integrate xpkg publishing process
  • Loading branch information
muvaf authored Sep 27, 2022
2 parents 6a8c573 + 3c49736 commit e1741dd
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 98 deletions.
29 changes: 24 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,32 @@ GO111MODULE = on

# ====================================================================================
# Setup Kubernetes tools
KIND_VERSION ?= v0.14.0
KIND_NODE_IMAGE_TAG ?= v1.23.6

UP_VERSION = v0.13.0
UP_CHANNEL = stable
KIND_NODE_IMAGE_TAG ?= v1.24.0
USE_HELM3 = true
-include build/makelib/k8s_tools.mk

# ====================================================================================
# Setup Images

DOCKER_REGISTRY = crossplane
IMAGES = provider-helm provider-helm-controller
-include build/makelib/image.mk
IMAGES = provider-helm
-include build/makelib/imagelight.mk

# ====================================================================================
# Setup XPKG

XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane index.docker.io/crossplane
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane
XPKGS = provider-helm
-include build/makelib/xpkg.mk

# We force image building to happen prior to xpkg build so that we ensure image
# is present in daemon.
xpkg.build.provider-helm: do.build.images

# ====================================================================================
# Setup Local Dev
Expand Down Expand Up @@ -92,6 +107,10 @@ submodules:
go.cachedir:
@go env GOCACHE

# We must ensure up is installed in tool cache prior to build as including the
# k8s_tools machinery prior to the xpkg machinery sets UP to point to tool cache.
build.init: $(UP)

# This is for running out-of-cluster locally, and is for convenience. Running
# this make target will print out the command which was used. For more control,
# try running the binary directly with different arguments.
Expand Down
11 changes: 0 additions & 11 deletions cluster/images/provider-helm-controller/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions cluster/images/provider-helm-controller/Makefile

This file was deleted.

15 changes: 13 additions & 2 deletions cluster/images/provider-helm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
FROM BASEIMAGE
FROM gcr.io/distroless/static@sha256:1f580b0a1922c3e54ae15b0758b5747b260bd99d39d40c2edb3e7f6e2452298b

COPY package.yaml .
ARG TARGETOS
ARG TARGETARCH

# distroless does not allow root level folder creations, which helm tries to do.
ENV HELM_CACHE_HOME /tmp/helm-cache
ENV HELM_CONFIG_HOME /tmp/helm-config
ENV HELM_DATA_HOME /tmp/helm-data

ADD bin/$TARGETOS\_$TARGETARCH/provider /usr/local/bin/provider-helm

USER 65532
ENTRYPOINT ["provider-helm"]
31 changes: 19 additions & 12 deletions cluster/images/provider-helm/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
# ====================================================================================
# Setup Project

PLATFORMS := linux_amd64 linux_arm64
include ../../../build/makelib/common.mk

# ====================================================================================
# Options
IMAGE = $(BUILD_REGISTRY)/provider-helm-$(ARCH)
OSBASEIMAGE = scratch
include ../../../build/makelib/image.mk

include ../../../build/makelib/imagelight.mk

# ====================================================================================
# Targets

img.build:
@$(INFO) docker build $(IMAGE)
@$(MAKE) BUILD_ARGS="--load" img.build.shared
@$(OK) docker build $(IMAGE)

img.publish:
@$(INFO) Skipping image publish for $(IMAGE)
@echo Publish is deferred to xpkg machinery
@$(OK) Image publish skipped for $(IMAGE)

img.build.shared:
@cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL)
@cp -R ../../../package $(IMAGE_TEMP_DIR) || $(FAIL)
@cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|BASEIMAGE|$(OSBASEIMAGE)|g' Dockerfile || $(FAIL)
@cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|VERSION|$(VERSION)|g' package/crossplane.yaml || $(FAIL)
@cd $(IMAGE_TEMP_DIR) && find package -type f -name '*.yaml' -exec cat {} >> 'package.yaml' \; -exec printf '\n---\n' \; || $(FAIL)
@docker build $(BUILD_ARGS) \
--build-arg ARCH=$(ARCH) \
--build-arg TINI_VERSION=$(TINI_VERSION) \
@cp -r $(OUTPUT_DIR)/bin/ $(IMAGE_TEMP_DIR)/bin || $(FAIL)
@docker buildx build $(BUILD_ARGS) \
--platform $(IMAGE_PLATFORMS) \
-t $(IMAGE) \
$(IMAGE_TEMP_DIR) || $(FAIL)
@$(OK) docker build $(IMAGE)

img.promote:
@$(INFO) Skipping image promotion from $(FROM_IMAGE) to $(TO_IMAGE)
@echo Promote is deferred to xpkg machinery
@$(OK) Image promotion skipped for $(FROM_IMAGE) to $(TO_IMAGE)
15 changes: 6 additions & 9 deletions cluster/integration/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ eval $(make --no-print-directory -C ${projectdir} build.vars)
# ------------------------------

SAFEHOSTARCH="${SAFEHOSTARCH:-amd64}"
BUILD_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}"
PACKAGE_IMAGE="crossplane.io/inttests/${PROJECT_NAME}:${VERSION}"
CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}"
CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}"

version_tag="$(cat ${projectdir}/_output/version)"
# tag as latest version to load into kind cluster
PACKAGE_CONTROLLER_IMAGE="${DOCKER_REGISTRY}/${PROJECT_NAME}-controller:${VERSION}"
K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}"

CROSSPLANE_NAMESPACE="crossplane-system"
Expand All @@ -69,8 +65,7 @@ echo_step "setting up local package cache"
CACHE_PATH="${projectdir}/.work/inttest-package-cache"
mkdir -p "${CACHE_PATH}"
echo "created cache dir at ${CACHE_PATH}"
docker tag "${BUILD_IMAGE}" "${PACKAGE_IMAGE}"
"${UP}" xpkg xp-extract --from-daemon "${PACKAGE_IMAGE}" -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz"
"${UP}" alpha xpkg xp-extract --from-xpkg "${OUTPUT_DIR}"/xpkg/"${HOSTOS}"_"${SAFEHOSTARCH}"/"${PACKAGE_NAME}"-"${VERSION}".xpkg -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz"

# create kind cluster with extra mounts
KIND_NODE_IMAGE="kindest/node:${KIND_NODE_IMAGE_TAG}"
Expand All @@ -88,8 +83,8 @@ EOF
echo "${KIND_CONFIG}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --wait=5m --image="${KIND_NODE_IMAGE}" --config=-

# tag controller image and load it into kind cluster
docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_CONTROLLER_IMAGE}"
"${KIND}" load docker-image "${PACKAGE_CONTROLLER_IMAGE}" --name="${K8S_CLUSTER}"
docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_NAME}"
"${KIND}" load docker-image "${PACKAGE_NAME}" --name="${K8S_CLUSTER}"

echo_step "create crossplane-system namespace"
"${KUBECTL}" create ns crossplane-system
Expand Down Expand Up @@ -184,6 +179,8 @@ SA=$("${KUBECTL}" -n crossplane-system get sa -o name | grep provider-helm | sed
echo_step "install example chart"
"${KUBECTL}" apply -f examples/sample/release.yaml
"${KUBECTL}" wait --for=condition=Ready release --all --timeout=1m

echo_step "waiting for wordpress pods to be ready"
"${KUBECTL}" -n wordpress wait --for=condition=Ready pods --all --timeout=3m

echo_sub_step "check namespace label"
Expand Down
2 changes: 1 addition & 1 deletion examples/sample/release-oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
chart:
name: wordpress
repository: "oci://localhost:5000/helm-charts"
version: 9.3.19
version: 15.2.5
# pullSecretRef:
# name: oci-creds
# namespace: default
Expand Down
2 changes: 1 addition & 1 deletion examples/sample/release-with-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
chart:
name: wordpress
repository: https://charts.bitnami.com/bitnami
version: 9.3.19
version: 15.2.5
namespace: wordpress
values:
param1: value1
Expand Down
2 changes: 1 addition & 1 deletion examples/sample/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
chart:
name: wordpress
repository: https://charts.bitnami.com/bitnami
version: 15.0.18 ## To use devlopment versions, set ">0.0.0-0"
version: 15.2.5 ## To use devlopment versions, set ">0.0.0-0"
# pullSecretRef:
# name: museum-creds
# namespace: default
Expand Down
31 changes: 0 additions & 31 deletions package/crossplane.yaml

Large diffs are not rendered by default.

0 comments on commit e1741dd

Please sign in to comment.