diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5528ecfea..b440ab14b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,6 +27,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.54 + tests: name: Unit tests runs-on: ubuntu-latest @@ -43,11 +44,17 @@ jobs: build-images: name: Build Images + outputs: + local-artifact-mirror: ${{ steps.local-artifact-mirror.outputs.image }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - uses: actions/cache@v4 + with: + fetch-depth: 0 # fetch all history so that we can get the previous tag + + - name: Cache Melange + uses: actions/cache@v4 with: path: | build/.melange-cache @@ -60,16 +67,10 @@ jobs: uses: chainguard-dev/actions/setup-melange@main - name: Build and push local-artifact-mirror image + id: local-artifact-mirror run: | - export SHORT_SHA=dev-${GITHUB_SHA::7} - export LOCAL_ARTIFACT_MIRROR_IMAGE=replicated/embedded-cluster-local-artifact-mirror-staging - export REGISTRY=docker.io - export USERNAME=${{ secrets.DOCKERHUB_USER }} - export PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} - make apko - make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}" - make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-previous-k0s" - make build-and-push-local-artifact-mirror-image VERSION="${SHORT_SHA}-upgrade" + make -C local-artifact-mirror apko build-ttl.sh + echo "image=$(cat local-artifact-mirror/build/image)" >> $GITHUB_OUTPUT buildtools: name: Build Buildtools @@ -93,6 +94,7 @@ jobs: build: name: Build runs-on: ubuntu-latest + needs: [build-images] steps: - name: Checkout uses: actions/checkout@v4 @@ -106,7 +108,7 @@ jobs: - name: Build Linux AMD64 and Output Metadata run: | export SHORT_SHA=dev-${GITHUB_SHA::7} - export LOCAL_ARTIFACT_MIRROR_IMAGE=replicated/embedded-cluster-local-artifact-mirror-staging + export LOCAL_ARTIFACT_MIRROR_IMAGE=${{ needs.build-images.outputs.local-artifact-mirror }} make -B embedded-cluster-linux-amd64 K0S_VERSION=$(make print-PREVIOUS_K0S_VERSION) K0S_BINARY_SOURCE_OVERRIDE=$(make print-PREVIOUS_K0S_BINARY_SOURCE_OVERRIDE) VERSION="${SHORT_SHA}-previous-k0s" tar -C output/bin -czvf embedded-cluster-linux-amd64-previous-k0s.tgz embedded-cluster ./output/bin/embedded-cluster version metadata > metadata-previous-k0s.json @@ -123,7 +125,7 @@ jobs: path: | output/bin/embedded-cluster - name: Publish development release - if: github.branch == 'main' + if: github.ref == 'refs/heads/main' uses: marvinpinto/action-automatic-releases@latest with: automatic_release_tag: development @@ -136,7 +138,7 @@ jobs: - name: Build CI binary run: | export SHORT_SHA=dev-${GITHUB_SHA::7} - export LOCAL_ARTIFACT_MIRROR_IMAGE=replicated/embedded-cluster-local-artifact-mirror-staging + export LOCAL_ARTIFACT_MIRROR_IMAGE=${{ needs.build-images.outputs.local-artifact-mirror }} echo "# channel release object" > e2e/kots-release-install/release.yaml echo 'channelID: "2cHXb1RCttzpR0xvnNWyaZCgDBP"' >> e2e/kots-release-install/release.yaml echo 'channelSlug: "ci"' >> e2e/kots-release-install/release.yaml @@ -374,6 +376,7 @@ jobs: - e2e - sanitize - tests + - check-images if: always() steps: # https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context diff --git a/.github/workflows/image-scan.yaml b/.github/workflows/image-scan.yaml index e02f97aa7..bc37360e5 100644 --- a/.github/workflows/image-scan.yaml +++ b/.github/workflows/image-scan.yaml @@ -5,6 +5,9 @@ on: - cron: '0 0 * * *' workflow_dispatch: {} push: + # TODO: add this once we have all images in the metadata.yaml + # paths: + # - '**/metadata.yaml' branches: - main @@ -12,8 +15,39 @@ permissions: security-events: write jobs: + + build-images: + outputs: + local-artifact-mirror: ${{ steps.local-artifact-mirror.outputs.image }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch all history so that we can get the previous tag + + - name: Cache Melange + uses: actions/cache@v4 + with: + path: | + build/.melange-cache + key: melange-cache + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Setup Melange + uses: chainguard-dev/actions/setup-melange@main + + - name: Build and push local-artifact-mirror image + id: local-artifact-mirror + run: | + make -C local-artifact-mirror apko build-ttl.sh + echo "image=$(cat local-artifact-mirror/build/image)" >> $GITHUB_OUTPUT + output-matrix: runs-on: ubuntu-latest + needs: [build-images] outputs: matrix: ${{ steps.build-matrix.outputs.matrix }} steps: @@ -27,6 +61,7 @@ jobs: - name: Build run: | + export LOCAL_ARTIFACT_MIRROR_IMAGE=${{ needs.build-images.outputs.local-artifact-mirror }} make embedded-cluster-linux-amd64 - name: List images diff --git a/.github/workflows/release-prod.yaml b/.github/workflows/release-prod.yaml index d2d63b327..006abc475 100644 --- a/.github/workflows/release-prod.yaml +++ b/.github/workflows/release-prod.yaml @@ -6,54 +6,74 @@ on: permissions: contents: write jobs: - releaser: + + get-tag: runs-on: ubuntu-latest + outputs: + tag-name: ${{ steps.get-tag.outputs.tag-name }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Extract tag name + id: get-tag run: | # remove the "refs/tags/" prefix to get the tag that was pushed export RAW_TAG=${GITHUB_REF#refs/tags/} # add a 'v' prefix to the tag if it doesn't already have one export V_TAG=$(echo "$RAW_TAG" | sed 's/^[^v]/v&/') - # store the tag name in a github environment variable for later steps - echo "TAG_NAME=${V_TAG}" >> $GITHUB_ENV - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod + # store the tag name in an output for later steps + echo "tag-name=${V_TAG}" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + build-images: + runs-on: ubuntu-latest + needs: [get-tag] + outputs: + local-artifact-mirror: ${{ steps.local-artifact-mirror.outputs.image }} + steps: + - name: Checkout + uses: actions/checkout@v4 - - uses: actions/cache@v4 + - name: Cache Melange + uses: actions/cache@v4 with: path: | build/.melange-cache key: melange-cache + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Setup Melange uses: chainguard-dev/actions/setup-melange@main - - name: Build and push local-artifact-mirror image (production) + - name: Build and push local-artifact-mirror image + id: local-artifact-mirror + env: + REGISTRY: docker.io + USERNAME: ${{ secrets.DOCKERHUB_USER }} + PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} run: | - export REGISTRY=docker.io - export USERNAME=${{ secrets.DOCKERHUB_USER }} - export PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} - make apko - make build-and-push-local-artifact-mirror-image VERSION=$TAG_NAME + make -C local-artifact-mirror apko build-and-push-local-artifact-mirror-image \ + PACKAGE_VERSION=${{ needs.get-tag.outputs.tag-name }} + echo "image=$(cat local-artifact-mirror/build/image)" >> $GITHUB_OUTPUT - - name: Build and push local-artifact-mirror image (staging) - run: | - export LOCAL_ARTIFACT_MIRROR_IMAGE=replicated/embedded-cluster-local-artifact-mirror-staging - export REGISTRY=docker.io - export USERNAME=${{ secrets.DOCKERHUB_USER }} - export PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} - make apko - make build-and-push-local-artifact-mirror-image VERSION=$TAG_NAME + release: + runs-on: ubuntu-latest + needs: [get-tag, build-images] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build and push utils image (production) run: | @@ -61,7 +81,7 @@ jobs: export USERNAME=${{ secrets.DOCKERHUB_USER }} export PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} make apko - make build-and-push-utils-image VERSION=$TAG_NAME + make build-and-push-utils-image VERSION=${{ needs.get-tag.outputs.tag-name }} - name: Build and push utils image (staging) run: | @@ -70,12 +90,15 @@ jobs: export USERNAME=${{ secrets.DOCKERHUB_USER }} export PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} make apko - make build-and-push-utils-image VERSION=$TAG_NAME + make build-and-push-utils-image VERSION=${{ needs.get-tag.outputs.tag-name }} - name: Build linux-amd64 run: | - make embedded-cluster-linux-amd64 VERSION=$TAG_NAME + make embedded-cluster-linux-amd64 \ + VERSION=${{ needs.get-tag.outputs.tag-name }} \ + LOCAL_ARTIFACT_MIRROR_IMAGE=${{ needs.build-images.outputs.local-artifact-mirror }} tar -C output/bin -czvf embedded-cluster-linux-amd64.tgz embedded-cluster + - name: Output Metadata run: | ./output/bin/embedded-cluster version metadata > metadata.json @@ -86,8 +109,9 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }} AWS_REGION: "us-east-1" run: | - export EC_VERSION="$TAG_NAME" + export EC_VERSION="${{ needs.get-tag.outputs.tag-name }}" ./scripts/cache-files.sh + - name: Cache Prod Files env: S3_BUCKET: "tf-embedded-cluster-binaries" @@ -95,8 +119,9 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.PROD_EMBEDDED_CLUSTER_UPLOAD_IAM_SECRET }} AWS_REGION: "us-east-1" run: | - export EC_VERSION="$TAG_NAME" + export EC_VERSION="${{ needs.get-tag.outputs.tag-name }}" ./scripts/cache-files.sh + - name: Publish release uses: marvinpinto/action-automatic-releases@latest with: diff --git a/Makefile b/Makefile index dfda3d52a..73adcc234 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ +SHELL := /bin/bash + +include chainguard.mk + VERSION ?= $(shell git describe --tags --dirty) +CURRENT_USER := $(if $(GITHUB_USER),$(GITHUB_USER),$(shell id -u -n)) UNAME := $(shell uname) ARCH := $(shell uname -m) APP_NAME = embedded-cluster @@ -17,15 +22,14 @@ PREVIOUS_K0S_BINARY_SOURCE_OVERRIDE = TROUBLESHOOT_VERSION = v0.97.0 KOTS_VERSION = v$(shell awk '/^version/{print $$2}' pkg/addons/adminconsole/static/metadata.yaml | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/') KOTS_BINARY_URL_OVERRIDE = -LOCAL_ARTIFACT_MIRROR_IMAGE ?= replicated/embedded-cluster-local-artifact-mirror -LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION ?= $(subst +,-,$(VERSION)) -LOCAL_ARTIFACT_MIRROR_IMAGE_LOCATION = proxy.replicated.com/anonymous/$(LOCAL_ARTIFACT_MIRROR_IMAGE):$(LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION) +# TODO: move this to a manifest file +LOCAL_ARTIFACT_MIRROR_IMAGE ?= proxy.replicated.com/anonymous/replicated/embedded-cluster-local-artifact-mirror:$(VERSION) LD_FLAGS = \ - -X github.com/replicatedhq/embedded-cluster/pkg/defaults.K0sVersion=$(K0S_VERSION) \ - -X github.com/replicatedhq/embedded-cluster/pkg/defaults.Version=$(VERSION) \ - -X github.com/replicatedhq/embedded-cluster/pkg/defaults.TroubleshootVersion=$(TROUBLESHOOT_VERSION) \ - -X github.com/replicatedhq/embedded-cluster/pkg/defaults.KubectlVersion=$(KUBECTL_VERSION) \ - -X github.com/replicatedhq/embedded-cluster/pkg/defaults.LocalArtifactMirrorImage=$(LOCAL_ARTIFACT_MIRROR_IMAGE_LOCATION) \ + -X github.com/replicatedhq/embedded-cluster/pkg/versions.K0sVersion=$(K0S_VERSION) \ + -X github.com/replicatedhq/embedded-cluster/pkg/versions.Version=$(VERSION) \ + -X github.com/replicatedhq/embedded-cluster/pkg/versions.TroubleshootVersion=$(TROUBLESHOOT_VERSION) \ + -X github.com/replicatedhq/embedded-cluster/pkg/versions.KubectlVersion=$(KUBECTL_VERSION) \ + -X github.com/replicatedhq/embedded-cluster/pkg/versions.LocalArtifactMirrorImage=$(LOCAL_ARTIFACT_MIRROR_IMAGE) \ -X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.ChartRepoOverride=$(ADMIN_CONSOLE_CHART_REPO_OVERRIDE) \ -X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KurlProxyImageOverride=$(ADMIN_CONSOLE_KURL_PROXY_IMAGE_OVERRIDE) \ -X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.KotsVersion=$(KOTS_VERSION) \ @@ -41,7 +45,7 @@ GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) .DEFAULT_GOAL := default -default: embedded-cluster-linux-amd64 +default: build-ttl.sh pkg/goods/bins/k0s: Makefile mkdir -p pkg/goods/bins @@ -77,10 +81,8 @@ pkg/goods/bins/kubectl-preflight: Makefile pkg/goods/bins/local-artifact-mirror: Makefile mkdir -p pkg/goods/bins - go build \ - -tags osusergo,netgo \ - -ldflags="-s -w -extldflags=-static" \ - -o pkg/goods/bins/local-artifact-mirror ./cmd/local-artifact-mirror + $(MAKE) -C local-artifact-mirror build GOOS=linux GOARCH=amd64 + cp local-artifact-mirror/bin/local-artifact-mirror-$(GOOS)-$(GOARCH) pkg/goods/bins/local-artifact-mirror pkg/goods/internal/bins/kubectl-kots: Makefile mkdir -p pkg/goods/internal/bins @@ -158,6 +160,13 @@ e2e-tests: embedded-release e2e-test: go test -timeout 45m -v ./e2e -run $(TEST_NAME)$ +.PHONY: build-ttl.sh +build-ttl.sh: + $(MAKE) -C local-artifact-mirror build-ttl.sh \ + IMAGE_NAME=$(CURRENT_USER)/embedded-cluster-local-artifact-mirror + make embedded-cluster-linux-amd64 \ + LOCAL_ARTIFACT_MIRROR_IMAGE=proxy.replicated.com/anonymous/$(shell cat local-artifact-mirror/build/image) + .PHONY: clean clean: rm -rf output @@ -183,78 +192,17 @@ scan: --ignore-unfixed \ ./ -.PHONY: build-local-artifact-mirror-image -build-local-artifact-mirror-image: export IMAGE ?= $(LOCAL_ARTIFACT_MIRROR_IMAGE):$(LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION) -build-local-artifact-mirror-image: export PACKAGE_VERSION ?= $(LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION) -build-local-artifact-mirror-image: export MELANGE_CONFIG = deploy/packages/local-artifact-mirror/melange.tmpl.yaml -build-local-artifact-mirror-image: export APKO_CONFIG = deploy/images/local-artifact-mirror/apko.tmpl.yaml -build-local-artifact-mirror-image: melange-build apko-build - -.PHONY: build-and-push-local-artifact-mirror-image -build-and-push-local-artifact-mirror-image: export IMAGE ?= $(LOCAL_ARTIFACT_MIRROR_IMAGE):$(LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION) -build-and-push-local-artifact-mirror-image: export PACKAGE_VERSION ?= $(LOCAL_ARTIFACT_MIRROR_IMAGE_VERSION) -build-and-push-local-artifact-mirror-image: export MELANGE_CONFIG = deploy/packages/local-artifact-mirror/melange.tmpl.yaml -build-and-push-local-artifact-mirror-image: export APKO_CONFIG = deploy/images/local-artifact-mirror/apko.tmpl.yaml -build-and-push-local-artifact-mirror-image: melange-build apko-login apko-build-and-publish - -CHAINGUARD_TOOLS_USE_DOCKER = 0 -ifeq ($(CHAINGUARD_TOOLS_USE_DOCKER),"1") -MELANGE_CACHE_DIR ?= /go/pkg/mod -APKO_CMD = docker run -v $(shell pwd):/work -w /work -v $(shell pwd)/build/.docker:/root/.docker cgr.dev/chainguard/apko -MELANGE_CMD = docker run --privileged --rm -v $(shell pwd):/work -w /work -v "$(shell go env GOMODCACHE)":${MELANGE_CACHE_DIR} cgr.dev/chainguard/melange -else -MELANGE_CACHE_DIR ?= build/.melange-cache -APKO_CMD = apko -MELANGE_CMD = melange -endif - -$(MELANGE_CACHE_DIR): - mkdir -p $(MELANGE_CACHE_DIR) - -.PHONY: apko-build -apko-build: export ARCHS ?= amd64 -apko-build: check-env-IMAGE apko-template - cd build && ${APKO_CMD} \ - build apko.yaml ${IMAGE} apko.tar \ - --arch ${ARCHS} - -.PHONY: apko-build-and-publish -apko-build-and-publish: export ARCHS ?= amd64 -apko-build-and-publish: check-env-IMAGE apko-template - cd build && ${APKO_CMD} \ - publish apko.yaml ${IMAGE} \ - --arch ${ARCHS} | tee digest - -.PHONY: apko-login -apko-login: - rm -f build/.docker/config.json - @ { [ "${PASSWORD}" = "" ] || [ "${USERNAME}" = "" ] ; } || \ - ${APKO_CMD} \ - login -u "${USERNAME}" \ - --password "${PASSWORD}" "${REGISTRY}" - -.PHONY: melange-build -melange-build: export ARCHS ?= amd64 -melange-build: $(MELANGE_CACHE_DIR) melange-template - ${MELANGE_CMD} \ - keygen build/melange.rsa - ${MELANGE_CMD} \ - build build/melange.yaml \ - --arch ${ARCHS} \ - --signing-key build/melange.rsa \ - --cache-dir=$(MELANGE_CACHE_DIR) \ - --source-dir . \ - --out-dir build/packages/ - -.PHONY: melange-template -melange-template: check-env-MELANGE_CONFIG check-env-PACKAGE_VERSION - mkdir -p build - envsubst '$${PACKAGE_VERSION}' < ${MELANGE_CONFIG} > build/melange.yaml - -.PHONY: apko-template -apko-template: check-env-APKO_CONFIG check-env-PACKAGE_VERSION - mkdir -p build - envsubst '$${PACKAGE_NAME} $${PACKAGE_VERSION} $${UPSTREAM_VERSION}' < ${APKO_CONFIG} > build/apko.yaml +.PHONY: build-utils-image +build-utils-image: export IMAGE ?= $(EMBEDDED_OPERATOR_UTILS_IMAGE):$(EMBEDDED_OPERATOR_UTILS_IMAGE_VERSION) +build-utils-image: export PACKAGE_VERSION ?= $(EMBEDDED_OPERATOR_UTILS_IMAGE_VERSION) +build-utils-image: export APKO_CONFIG = deploy/images/utils/apko.tmpl.yaml +build-utils-image: apko-build + +.PHONY: build-and-push-utils-image +build-and-push-utils-image: export IMAGE ?= $(EMBEDDED_OPERATOR_UTILS_IMAGE):$(EMBEDDED_OPERATOR_UTILS_IMAGE_VERSION) +build-and-push-utils-image: export PACKAGE_VERSION ?= $(EMBEDDED_OPERATOR_UTILS_IMAGE_VERSION) +build-and-push-utils-image: export APKO_CONFIG = deploy/images/utils/apko.tmpl.yaml +build-and-push-utils-image: apko-login apko-build-and-publish .PHONY: buildtools buildtools: @@ -267,39 +215,5 @@ cache-files: export EMBEDDED_OPERATOR_BINARY_URL_OVERRIDE cache-files: ./scripts/cache-files.sh -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -MELANGE ?= $(LOCALBIN)/melange -APKO ?= $(LOCALBIN)/apko - -# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) -ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin -else -GOBIN=$(shell go env GOBIN) -endif - -melange: $(MELANGE) -$(MELANGE): $(LOCALBIN) - go install chainguard.dev/melange@latest && \ - test -s $(GOBIN)/melange && \ - ln -sf $(GOBIN)/melange $(LOCALBIN)/melange - -apko: $(APKO) -$(APKO): $(LOCALBIN) - go install chainguard.dev/apko@latest && \ - test -s $(GOBIN)/apko && \ - ln -sf $(GOBIN)/apko $(LOCALBIN)/apko - print-%: @echo -n $($*) - -check-env-%: - @ if [ "${${*}}" = "" ]; then \ - echo "Environment variable $* not set"; \ - exit 1; \ - fi diff --git a/README.md b/README.md index ff66c44bb..6f480a616 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,23 @@ # Embedded Cluster platform -This repository houses a cluster installation prototype that utilizes the k0s platform. -It showcases an alternative approach to deploying clusters and serves as a starting point for further exploration and advancement. +Replicated Embedded Cluster allows you to distribute a Kubernetes cluster and your application together as a single appliance, making it easy for enterprise users to install, update, and manage the application and the cluster in tandem. +Embedded Cluster is based on the open source Kubernetes distribution k0s. +For more information, see the [k0s documentation](https://docs.k0sproject.io/stable/). + In Embedded Cluster, all components and functionalities are consolidated into a single binary, this binary facilitates a streamlined cluster installation process, removing the need for external dependencies (rpms, debs, etc). -Embedded Cluster includes by default the Kots Admin Console and the OpenEBS Storage provisioner. +Embedded Cluster includes by default the Kots Admin Console, the OpenEBS Storage provisioner, and Velero for backups and disaster recovery. +Additionally, it includes a Registry when deployed in air gap mode. ## Building and running With the repository checked out locally, to compile you just need to run: +```bash +$ make build-ttl.sh ``` -$ make embedded-cluster -``` + +This will build the embedded-cluster binary and push the local-artifact-mirror image to ttl.sh. The binary will be located on `output/bin/embedded-cluster`. @@ -20,31 +25,28 @@ The binary will be located on `output/bin/embedded-cluster`. To create a single node deployment you can upload the Embedded Cluster binary to a Linux x86_64 machine and run: -``` -$ ./embedded-cluster install +```bash +ubuntu@ip-172-16-10-242:~$ ./embedded-cluster install ``` ## Interacting with the cluster Once the cluster has been deployed you can open a new terminal to interact with it using `kubectl`: -``` -$ ./embedded-cluster shell -``` - -This will drop you in a new shell, this shell is configured to reach the cluster and includes shell completion: - -``` +```bash ubuntu@ip-172-16-10-242:~$ ./embedded-cluster shell __4___ - _ \ \ \ \ Welcome to embedded-cluster debug shell. + _ \ \ \ \ Welcome to embedded-cluster-smoke-test-staging-app debug shell. <'\ /_/_/_/ This terminal is now configured to access your cluster. ((____!___/) Type 'exit' (or CTRL+d) to exit. \0\0\0\0\/ Happy hacking. ~~~~~~~~~~~ -ubuntu@ip-172-16-10-242:~/.embedded-cluster/etc$ export KUBECONFIG="/home/ubuntu/.embedded-cluster/etc/kubeconfig" -ubuntu@ip-172-16-10-242:~/.embedded-cluster/etc$ export PATH="$PATH:/home/ubuntu/.embedded-cluster/bin" -ubuntu@ip-172-16-10-242:~/.embedded-cluster/etc$ source <(kubectl completion $(basename "/bin/bash")) -ubuntu@ip-172-16-10-242:~/.embedded-cluster/etc$ +ubuntu@ip-172-16-10-242:~$ export KUBECONFIG="/var/lib/k0s/pki/admin.conf" +ubuntu@ip-172-16-10-242:~$ export PATH="$PATH:/var/lib/embedded-cluster/bin" +ubuntu@ip-172-16-10-242:~$ source <(kubectl completion bash) +ubuntu@ip-172-16-10-242:~$ source /etc/bash_completion +ubuntu@ip-172-16-10-242:~$ ``` + +This will drop you in a new shell, this shell is configured to reach the cluster and includes shell completion: diff --git a/chainguard.mk b/chainguard.mk new file mode 100644 index 000000000..4f3dbef26 --- /dev/null +++ b/chainguard.mk @@ -0,0 +1,101 @@ +SHELL := /bin/bash + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +MELANGE ?= $(LOCALBIN)/melange +APKO ?= $(LOCALBIN)/apko + +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +melange: $(MELANGE) +$(MELANGE): $(LOCALBIN) + go install chainguard.dev/melange@latest && \ + test -s $(GOBIN)/melange && \ + ln -sf $(GOBIN)/melange $(LOCALBIN)/melange + +apko: $(APKO) +$(APKO): $(LOCALBIN) + go install chainguard.dev/apko@latest && \ + test -s $(GOBIN)/apko && \ + ln -sf $(GOBIN)/apko $(LOCALBIN)/apko + +CHAINGUARD_TOOLS_USE_DOCKER = 0 +ifeq ($(CHAINGUARD_TOOLS_USE_DOCKER),"1") +MELANGE_CACHE_DIR ?= /go/pkg/mod +APKO_CMD = docker run -v $(shell pwd):/work -w /work -v $(shell pwd)/build/.docker:/root/.docker cgr.dev/chainguard/apko +MELANGE_CMD = docker run --privileged --rm -v $(shell pwd):/work -w /work -v "$(shell go env GOMODCACHE)":${MELANGE_CACHE_DIR} cgr.dev/chainguard/melange +else +MELANGE_CACHE_DIR ?= build/.melange-cache +APKO_CMD = apko +MELANGE_CMD = melange +endif + +$(MELANGE_CACHE_DIR): + mkdir -p $(MELANGE_CACHE_DIR) + +.PHONY: apko-build +apko-build: ARCHS ?= amd64 +apko-build: check-env-IMAGE apko-template + cd build && ${APKO_CMD} \ + build apko.yaml ${IMAGE} apko.tar \ + --arch ${ARCHS} + +.PHONY: apko-build-and-publish +apko-build-and-publish: ARCHS ?= amd64 +apko-build-and-publish: check-env-IMAGE apko-template + cd build && ${APKO_CMD} \ + publish apko.yaml ${IMAGE} \ + --arch ${ARCHS} | tee digest + $(MAKE) apko-output-image + +.PHONY: apko-login +apko-login: + rm -f build/.docker/config.json + @ { [ "${PASSWORD}" = "" ] || [ "${USERNAME}" = "" ] ; } || \ + ${APKO_CMD} \ + login -u "${USERNAME}" \ + --password "${PASSWORD}" "${REGISTRY}" + $(MAKE) apko-output-image + +.PHONY: apko-output-image +apko-output-image: + printf "${IMAGE}@$(shell cat build/digest | awk -F'@' '{print $$2}')" > build/image + +.PHONY: melange-build +melange-build: ARCHS ?= amd64 +melange-build: MELANGE_SOURCE_DIR ?= . +melange-build: $(MELANGE_CACHE_DIR) melange-template + ${MELANGE_CMD} \ + keygen build/melange.rsa + ${MELANGE_CMD} \ + build build/melange.yaml \ + --arch ${ARCHS} \ + --signing-key build/melange.rsa \ + --cache-dir=$(MELANGE_CACHE_DIR) \ + --source-dir $(MELANGE_SOURCE_DIR) \ + --out-dir build/packages/ + +.PHONY: melange-template +melange-template: check-env-MELANGE_CONFIG check-env-PACKAGE_VERSION + mkdir -p build + envsubst '$${PACKAGE_VERSION}' < ${MELANGE_CONFIG} > build/melange.yaml + +.PHONY: apko-template +apko-template: check-env-APKO_CONFIG check-env-PACKAGE_VERSION + mkdir -p build + envsubst '$${PACKAGE_NAME} $${PACKAGE_VERSION} $${UPSTREAM_VERSION}' < ${APKO_CONFIG} > build/apko.yaml + +check-env-%: + @ if [ "${${*}}" = "" ]; then \ + echo "Environment variable $* not set"; \ + exit 1; \ + fi diff --git a/cmd/embedded-cluster/metadata.go b/cmd/embedded-cluster/metadata.go index 10cf47a6f..acf3574b2 100644 --- a/cmd/embedded-cluster/metadata.go +++ b/cmd/embedded-cluster/metadata.go @@ -17,6 +17,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/goods" "github.com/replicatedhq/embedded-cluster/pkg/helpers" "github.com/replicatedhq/embedded-cluster/pkg/release" + "github.com/replicatedhq/embedded-cluster/pkg/versions" ) var metadataCommand = &cli.Command{ @@ -48,18 +49,18 @@ func gatherVersionMetadata() (*types.ReleaseMetadata, error) { addons.Quiet(), ) - versions, err := applier.Versions(config.AdditionalCharts()) + versionsMap, err := applier.Versions(config.AdditionalCharts()) if err != nil { return nil, fmt.Errorf("unable to get versions: %w", err) } - versions["Kubernetes"] = defaults.K0sVersion - versions["Installer"] = defaults.Version - versions["Troubleshoot"] = defaults.TroubleshootVersion - versions["Kubectl"] = defaults.KubectlVersion + versionsMap["Kubernetes"] = versions.K0sVersion + versionsMap["Installer"] = versions.Version + versionsMap["Troubleshoot"] = versions.TroubleshootVersion + versionsMap["Kubectl"] = versions.KubectlVersion channelRelease, err := release.GetChannelRelease() if err == nil && channelRelease != nil { - versions[defaults.BinaryName()] = channelRelease.VersionLabel + versionsMap[defaults.BinaryName()] = channelRelease.VersionLabel } sha, err := goods.K0sBinarySHA256() @@ -70,11 +71,11 @@ func gatherVersionMetadata() (*types.ReleaseMetadata, error) { artifacts := map[string]string{ "kots": fmt.Sprintf("kots-binaries/%s.tar.gz", adminconsole.KotsVersion), "operator": fmt.Sprintf("operator-binaries/%s.tar.gz", embeddedclusteroperator.Metadata.Version), - "local-artifact-mirror-image": defaults.LocalArtifactMirrorImage, + "local-artifact-mirror-image": versions.LocalArtifactMirrorImage, } meta := types.ReleaseMetadata{ - Versions: versions, + Versions: versionsMap, K0sSHA: sha, Artifacts: artifacts, } @@ -126,7 +127,7 @@ func gatherVersionMetadata() (*types.ReleaseMetadata, error) { } meta.Images = append(meta.Images, images...) - meta.Images = append(meta.Images, defaults.LocalArtifactMirrorImage) + meta.Images = append(meta.Images, versions.LocalArtifactMirrorImage) meta.Images = helpers.UniqueStringSlice(meta.Images) sort.Strings(meta.Images) diff --git a/cmd/embedded-cluster/restore.go b/cmd/embedded-cluster/restore.go index 831395c57..df8a23460 100644 --- a/cmd/embedded-cluster/restore.go +++ b/cmd/embedded-cluster/restore.go @@ -28,6 +28,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/prompts" "github.com/replicatedhq/embedded-cluster/pkg/release" "github.com/replicatedhq/embedded-cluster/pkg/spinner" + "github.com/replicatedhq/embedded-cluster/pkg/versions" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" @@ -374,8 +375,8 @@ func isBackupRestorable(backup *velerov1.Backup, rel *release.ChannelRelease, is if backup.Annotations["kots.io/embedded-cluster"] != "true" { return false, "is not an embedded cluster backup" } - if v := strings.TrimPrefix(backup.Annotations["kots.io/embedded-cluster-version"], "v"); v != strings.TrimPrefix(defaults.Version, "v") { - return false, fmt.Sprintf("has a different embedded cluster version (%q) than the current version (%q)", v, defaults.Version) + if v := strings.TrimPrefix(backup.Annotations["kots.io/embedded-cluster-version"], "v"); v != strings.TrimPrefix(versions.Version, "v") { + return false, fmt.Sprintf("has a different embedded cluster version (%q) than the current version (%q)", v, versions.Version) } if backup.Status.Phase != velerov1.BackupPhaseCompleted { return false, fmt.Sprintf("has a status of %q", backup.Status.Phase) diff --git a/cmd/embedded-cluster/version.go b/cmd/embedded-cluster/version.go index d5e32ed4e..dfdb3f27e 100644 --- a/cmd/embedded-cluster/version.go +++ b/cmd/embedded-cluster/version.go @@ -13,6 +13,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/config" "github.com/replicatedhq/embedded-cluster/pkg/defaults" "github.com/replicatedhq/embedded-cluster/pkg/release" + "github.com/replicatedhq/embedded-cluster/pkg/versions" ) var versionCommand = &cli.Command{ @@ -25,7 +26,7 @@ var versionCommand = &cli.Command{ }, Action: func(c *cli.Context) error { opts := []addons.Option{addons.Quiet(), addons.WithoutPrompt()} - versions, err := addons.NewApplier(opts...).Versions(config.AdditionalCharts()) + applierVersions, err := addons.NewApplier(opts...).Versions(config.AdditionalCharts()) if err != nil { return fmt.Errorf("unable to get versions: %w", err) } @@ -35,16 +36,16 @@ var versionCommand = &cli.Command{ if err == nil && channelRelease != nil { writer.AppendRow(table.Row{defaults.BinaryName(), channelRelease.VersionLabel}) } - writer.AppendRow(table.Row{"Installer", defaults.Version}) - writer.AppendRow(table.Row{"Kubernetes", defaults.K0sVersion}) + writer.AppendRow(table.Row{"Installer", versions.Version}) + writer.AppendRow(table.Row{"Kubernetes", versions.K0sVersion}) keys := []string{} - for k := range versions { + for k := range applierVersions { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { - version := versions[k] + version := applierVersions[k] if !strings.HasPrefix(version, "v") { version = fmt.Sprintf("v%s", version) } diff --git a/cmd/local-artifact-mirror/pull.go b/cmd/local-artifact-mirror/pull.go index 63dd8f203..96e0542a4 100644 --- a/cmd/local-artifact-mirror/pull.go +++ b/cmd/local-artifact-mirror/pull.go @@ -9,18 +9,17 @@ import ( "os/exec" "path/filepath" + "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1" + "github.com/replicatedhq/embedded-cluster/pkg/defaults" + "github.com/replicatedhq/embedded-cluster/pkg/helpers" + "github.com/replicatedhq/embedded-cluster/pkg/kubeutils" + "github.com/replicatedhq/embedded-cluster/pkg/tgzutils" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1" - "github.com/replicatedhq/embedded-cluster/pkg/defaults" - "github.com/replicatedhq/embedded-cluster/pkg/helpers" - "github.com/replicatedhq/embedded-cluster/pkg/kubeutils" - "github.com/replicatedhq/embedded-cluster/pkg/tgzutils" ) // These constant define the expected names of the files in the registry. diff --git a/cmd/local-artifact-mirror/serve.go b/cmd/local-artifact-mirror/serve.go index 2a2badd23..ebd98c242 100644 --- a/cmd/local-artifact-mirror/serve.go +++ b/cmd/local-artifact-mirror/serve.go @@ -10,9 +10,8 @@ import ( "syscall" "time" - "github.com/urfave/cli/v2" - "github.com/replicatedhq/embedded-cluster/pkg/defaults" + "github.com/urfave/cli/v2" ) // serveCommand starts a http server that serves files from the /var/lib/embedded-cluster diff --git a/deploy/images/utils/apko.tmpl.yaml b/deploy/images/utils/apko.tmpl.yaml index 022c8e8a0..2bfb05c18 100644 --- a/deploy/images/utils/apko.tmpl.yaml +++ b/deploy/images/utils/apko.tmpl.yaml @@ -15,6 +15,3 @@ accounts: uid: 65532 gid: 65532 run-as: 65532 - -environment: - VERSION: ${PACKAGE_VERSION} diff --git a/deploy/local-artifact-mirror/Dockerfile b/deploy/local-artifact-mirror/Dockerfile deleted file mode 100644 index 1ff7ac132..000000000 --- a/deploy/local-artifact-mirror/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# this dockerfile builds an image containing the local-artifact-mirror binary -# installed on /usr/local/bin/local-artifact-mirror. -FROM golang:1.22 AS builder -WORKDIR /src -COPY go.mod go.sum ./ -RUN go mod download -COPY . . -RUN make pkg/goods/bins/local-artifact-mirror - -FROM cgr.dev/chainguard/wolfi-base:latest -COPY --from=builder /src/pkg/goods/bins/local-artifact-mirror /usr/local/bin/local-artifact-mirror -ENTRYPOINT ["/usr/local/bin/local-artifact-mirror"] diff --git a/local-artifact-mirror/.gitignore b/local-artifact-mirror/.gitignore new file mode 100644 index 000000000..d5697ecf6 --- /dev/null +++ b/local-artifact-mirror/.gitignore @@ -0,0 +1,2 @@ +build/ +bin/ diff --git a/local-artifact-mirror/Makefile b/local-artifact-mirror/Makefile new file mode 100644 index 000000000..cad226c3e --- /dev/null +++ b/local-artifact-mirror/Makefile @@ -0,0 +1,42 @@ +SHELL := /bin/bash + +-include ../chainguard.mk + +GOOS ?= $(shell go env GOOS) +GOARCH ?= $(shell go env GOARCH) + +export PACKAGE_VERSION ?= $(shell git describe --tags --dirty) +export IMAGE_NAME ?= replicated/embedded-cluster-local-artifact-mirror +export IMAGE_TAG ?= $(shell echo "$(PACKAGE_VERSION)" | sed 's/+/-/') +export IMAGE ?= $(IMAGE_NAME):$(IMAGE_TAG) + +.PHONY: build +build: + mkdir -p bin + go build \ + -tags osusergo,netgo \ + -ldflags="-s -w -extldflags=-static" \ + -o bin/local-artifact-mirror-$(GOOS)-$(GOARCH) ../cmd/local-artifact-mirror + +export MELANGE_CONFIG := deploy/melange.tmpl.yaml + +.PHONY: melange-build-local-artifact-mirror +melange-build-local-artifact-mirror: + $(MAKE) melange-build MELANGE_SOURCE_DIR=../ + +export APKO_CONFIG := deploy/apko.tmpl.yaml + +.PHONY: build-local-artifact-mirror-image +build-local-artifact-mirror-image: melange-build-local-artifact-mirror apko-build + +.PHONY: build-and-push-local-artifact-mirror-image +build-and-push-local-artifact-mirror-image: melange-build-local-artifact-mirror apko-build-and-publish + +.PHONY: build-ttl.sh +build-ttl.sh: + $(MAKE) build-and-push-local-artifact-mirror-image \ + IMAGE=ttl.sh/$(IMAGE) + +.PHONY: clean +clean: + rm -rf bin build diff --git a/deploy/images/local-artifact-mirror/apko.tmpl.yaml b/local-artifact-mirror/deploy/apko.tmpl.yaml similarity index 100% rename from deploy/images/local-artifact-mirror/apko.tmpl.yaml rename to local-artifact-mirror/deploy/apko.tmpl.yaml diff --git a/deploy/packages/local-artifact-mirror/melange.tmpl.yaml b/local-artifact-mirror/deploy/melange.tmpl.yaml similarity index 76% rename from deploy/packages/local-artifact-mirror/melange.tmpl.yaml rename to local-artifact-mirror/deploy/melange.tmpl.yaml index a00d9f012..3c8a89fb7 100644 --- a/deploy/packages/local-artifact-mirror/melange.tmpl.yaml +++ b/local-artifact-mirror/deploy/melange.tmpl.yaml @@ -21,12 +21,12 @@ pipeline: - runs: | set -exuo pipefail - rm -f pkg/goods/bins/local-artifact-mirror + rm -rf bin mkdir -p ${{targets.contextdir}}/usr/bin mkdir -p ${{targets.contextdir}}/usr/local/bin - make pkg/goods/bins/local-artifact-mirror - cp pkg/goods/bins/local-artifact-mirror ${{targets.contextdir}}/usr/bin/local-artifact-mirror + make -C local-artifact-mirror build + cp local-artifact-mirror/bin/local-artifact-mirror-$(go env GOOS)-$(go env GOARCH) ${{targets.contextdir}}/usr/bin/local-artifact-mirror # support for legacy path ln -s /usr/bin/local-artifact-mirror ${{targets.contextdir}}/usr/local/bin/local-artifact-mirror - uses: strip diff --git a/pkg/addons/adminconsole/adminconsole.go b/pkg/addons/adminconsole/adminconsole.go index fbab43f74..90248bf1a 100644 --- a/pkg/addons/adminconsole/adminconsole.go +++ b/pkg/addons/adminconsole/adminconsole.go @@ -28,6 +28,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/metrics" "github.com/replicatedhq/embedded-cluster/pkg/release" "github.com/replicatedhq/embedded-cluster/pkg/spinner" + "github.com/replicatedhq/embedded-cluster/pkg/versions" ) const ( @@ -64,7 +65,7 @@ func init() { panic(fmt.Sprintf("unable to unmarshal values: %v", err)) } - helmValues["embeddedClusterVersion"] = defaults.Version + helmValues["embeddedClusterVersion"] = versions.Version if AdminConsoleImageOverride != "" { helmValues["images"].(map[string]interface{})["kotsadm"] = AdminConsoleImageOverride diff --git a/pkg/addons/adminconsole/static/metadata.yaml b/pkg/addons/adminconsole/static/metadata.yaml index 1e23b4a9b..9bd448e21 100644 --- a/pkg/addons/adminconsole/static/metadata.yaml +++ b/pkg/addons/adminconsole/static/metadata.yaml @@ -5,7 +5,7 @@ # $ make buildtools # $ output/bin/buildtools update addon # -version: 1.112.1-build.1 +version: 1.112.2 location: oci://proxy.replicated.com/anonymous/registry.replicated.com/library/admin-console images: kotsadm/kotsadm: v1.112.1@sha256:c258cfe395b3aea134e6efde9e5ec5b19a1dadda4206905a2540ee2f9aa14e18 diff --git a/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go b/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go index 0994d3403..be5390b12 100644 --- a/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go +++ b/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go @@ -20,6 +20,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/metrics" "github.com/replicatedhq/embedded-cluster/pkg/release" "github.com/replicatedhq/embedded-cluster/pkg/spinner" + "github.com/replicatedhq/embedded-cluster/pkg/versions" kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1" "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" "gopkg.in/yaml.v2" @@ -57,8 +58,8 @@ func init() { } helmValues["kotsVersion"] = adminconsole.Metadata.Version - helmValues["embeddedClusterVersion"] = defaults.Version - helmValues["embeddedClusterK0sVersion"] = defaults.K0sVersion + helmValues["embeddedClusterVersion"] = versions.Version + helmValues["embeddedClusterK0sVersion"] = versions.K0sVersion if EmbeddedOperatorImageOverride != "" { // split ImageOverride into the image and tag @@ -173,7 +174,7 @@ func (e *EmbeddedClusterOperator) createVersionMetadataConfigmap(ctx context.Con // we trim out the prefix v from the version and then slugify it, we use // the result as a suffix for the config map name. - slugver := slug.Make(strings.TrimPrefix(defaults.Version, "v")) + slugver := slug.Make(strings.TrimPrefix(versions.Version, "v")) configmap := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("version-metadata-%s", slugver), diff --git a/pkg/defaults/defaults.go b/pkg/defaults/defaults.go index 6785d6ce6..0351a59f5 100644 --- a/pkg/defaults/defaults.go +++ b/pkg/defaults/defaults.go @@ -4,21 +4,8 @@ package defaults var ( - // Version holds the EmbeddedCluster version. - Version = "v0.0.0" - // K0sVersion holds the version of k0s binary we are embedding. this is - // set at compile time via ldflags. - K0sVersion = "0.0.0" - // TroubleshootVersion holds the version of troubleshoot and preflight - // binaries we are embedding. this is set at compile time via ldflags. - TroubleshootVersion = "0.0.0" - // KubectlVersion holds the version of kubectl binary we are embedding. - KubectlVersion = "0.0.0" // provider holds a global reference to the default provider. provider *Provider - // LocalArtifactMirrorImage holds a reference to where the lam image for - // this version of embedded-cluster is stored. Set at compile time. - LocalArtifactMirrorImage = "" ) // Holds the default no proxy values. diff --git a/pkg/highavailability/registry.go b/pkg/highavailability/registry.go index 248692e3d..554d3063e 100644 --- a/pkg/highavailability/registry.go +++ b/pkg/highavailability/registry.go @@ -3,6 +3,7 @@ package highavailability import ( "context" "fmt" + "github.com/replicatedhq/embedded-cluster/pkg/defaults" "github.com/replicatedhq/embedded-cluster/pkg/kubeutils" corev1 "k8s.io/api/core/v1" diff --git a/pkg/highavailability/seaweed.go b/pkg/highavailability/seaweed.go index 2979663b8..fcc1db4ec 100644 --- a/pkg/highavailability/seaweed.go +++ b/pkg/highavailability/seaweed.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/replicatedhq/embedded-cluster/pkg/helpers" embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1" diff --git a/pkg/metrics/reporter.go b/pkg/metrics/reporter.go index de321d09a..4373ae5af 100644 --- a/pkg/metrics/reporter.go +++ b/pkg/metrics/reporter.go @@ -13,6 +13,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/defaults" "github.com/replicatedhq/embedded-cluster/pkg/helpers" + "github.com/replicatedhq/embedded-cluster/pkg/versions" kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1" ) @@ -60,7 +61,7 @@ func ClusterID() uuid.UUID { func ReportInstallationStarted(ctx context.Context, license *kotsv1beta1.License) { Send(ctx, BaseURL(license), InstallationStarted{ ClusterID: ClusterID(), - Version: defaults.Version, + Version: versions.Version, Flags: strings.Join(os.Args[1:], " "), BinaryName: defaults.BinaryName(), Type: "centralized", diff --git a/pkg/versions/versions.go b/pkg/versions/versions.go new file mode 100644 index 000000000..1df14e6e3 --- /dev/null +++ b/pkg/versions/versions.go @@ -0,0 +1,18 @@ +// Package versions +package versions + +var ( + // Version holds the EmbeddedCluster version. + Version = "v0.0.0" + // K0sVersion holds the version of k0s binary we are embedding. this is + // set at compile time via ldflags. + K0sVersion = "0.0.0" + // TroubleshootVersion holds the version of troubleshoot and preflight + // binaries we are embedding. this is set at compile time via ldflags. + TroubleshootVersion = "0.0.0" + // KubectlVersion holds the version of kubectl binary we are embedding. + KubectlVersion = "0.0.0" + // LocalArtifactMirrorImage holds a reference to where the lam image for + // this version of embedded-cluster is stored. Set at compile time. + LocalArtifactMirrorImage = "" +)