Skip to content

Commit

Permalink
fix(build): generate Helm repo index
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Mancioppi committed Feb 21, 2023
1 parent d2ef94c commit c97c2a4
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 42 deletions.
149 changes: 116 additions & 33 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
outputs:
do-release: steps.release-check.outputs.new-release

release:
validate-release-increment:
if: github.ref == 'refs/heads/main' && needs.check-should-release.outputs.do-release
runs-on: ubuntu-latest
needs:
Expand All @@ -50,22 +50,29 @@ jobs:
fetch-depth: 2 # We need this commit and the previous to check validity of version change
- name: Validate version change
run: ./.github/workflows/scripts/validate_version_increment.sh
- name: Export version
id: export_version
run: |
echo -n "version=$(cat VERSION)" >> ${GITHUB_OUTPUT}
outputs:
version: ${{ steps.export_version.outputs.version }}

publish-controller-ecr-image:
runs-on: ubuntu-latest
needs:
- validate-release-increment
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Install tools
run: |
make install-tools
- name: Set up Helm
run: |
sudo curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version --short
helm plugin install https://github.com/hypnoglow/helm-s3.git
- name: Set up yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -77,34 +84,110 @@ jobs:
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
- name: Read version
id: read_version
run: |
echo "version=$(cat VERSION)" >> ${GITHUB_OUTPUT}
echo "controller_image_repository=public.ecr.aws/lumigo/lumigo-kubernetes-operator" >> ${GITHUB_OUTPUT}
echo "proxy_image_repository=public.ecr.aws/lumigo/lumigo-kubernetes-telemetry-proxy" >> ${GITHUB_OUTPUT}
- name: Push container images to Amazon ECR
- name: Build and push container image to Amazon ECR
env:
CONTROLLER_IMG: ${{ steps.read_version.outputs.controller_image_repository }}:${{ steps.read_version.outputs.version }}
PROXY_IMG: ${{ steps.read_version.outputs.proxy_image_repository }}:${{ steps.read_version.outputs.version }}
CONTROLLER_IMG: public.ecr.aws/lumigo/lumigo-kubernetes-operator:${{ needs.validate-release-increment.outputs.version }}
run: |
make docker-buildx
- name: Update Helm chart defaults
make docker-buildx-manager
publish-telemetry-proxy-ecr-image:
runs-on: ubuntu-latest
needs:
- validate-release-increment
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Install tools
run: |
yq e -i '.controllerManager.manager.image.repository = "${{ steps.read_version.outputs.controller_image_repository }}"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.manager.image.tag = "${{ steps.read_version.outputs.version }}"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.telemetryProxy.image.repository = "${{ steps.read_version.outputs.proxy_image_repository }}"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.telemetryProxy.image.tag = "${{ steps.read_version.outputs.version }}"' charts/lumigo-operator/values.yaml
- name: Update Helm chart metadata
make install-tools
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
- name: Build and push container image to Amazon ECR
env:
PROXY_IMG: public.ecr.aws/lumigo/lumigo-kubernetes-telemetry-proxy:${{ needs.validate-release-increment.outputs.version }}
run: |
yq e -i '.version = "${{ steps.read_version.outputs.version }}"' charts/lumigo-operator/Chart.yaml
yq e -i '.appVersion = "${{ steps.read_version.outputs.version }}"' charts/lumigo-operator/Chart.yaml
make docker-buildx-telemetry-proxy
publish-helm-chart:
runs-on: ubuntu-latest
needs:
- validate-release-increment
- publish-controller-ecr-image
- publish-telemetry-proxy-ecr-image
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: |
git branch -r
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Publish Helm chart version
uses: helm/chart-releaser-action@v1.2.1
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: 'v{{ .Version }}'
- name: Set up Helm
run: curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Set up yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Update Helm chart metadata
run: |
yq e -i '.version = "${{ needs.validate-release-increment.outputs.version }}"' charts/lumigo-operator/Chart.yaml
yq e -i '.appVersion = "${{ needs.validate-release-increment.outputs.version }}"' charts/lumigo-operator/Chart.yaml
- name: Update Helm chart defaults
run: |
yq e -i '.controllerManager.manager.image.repository = "public.ecr.aws/lumigo/lumigo-kubernetes-operator"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.manager.image.tag = "${{ needs.validate-release-increment.outputs.version }}"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.telemetryProxy.image.repository = "public.ecr.aws/lumigo/lumigo-kubernetes-telemetry-proxy"' charts/lumigo-operator/values.yaml
yq e -i '.controllerManager.telemetryProxy.image.tag = "${{ needs.validate-release-increment.outputs.version }}"' charts/lumigo-operator/values.yaml
- name: Create release commit
id: create-release-commit
run: |
git add charts/lumigo-operator
git commit -m "v${{ needs.validate-release-increment.outputs.version }}"
git tag "v${{ needs.validate-release-increment.outputs.version }}" $(git rev-parse HEAD)
- name: Package Helm chart
run: |
helm package charts/lumigo-operator --destination packages/
- name: Calculate updated Helm index
id: prepare-helm-index-update
run: |
git checkout origin/gh-pages --quiet
helm repo index packages/ --merge index.yaml --url "https://github.com/lumigo-io/lumigo-kubernetes-operator/releases/download/v${{ needs.validate-release-increment.outputs.version }}"
mv packages/index.yaml index.yaml
git add index.yaml
git status
git commit -m "${{ needs.validate-release-increment.outputs.version }}"
echo "commit_sha=$(git rev-parse HEAD)" >> ${GITHUB_OUTPUT}
- name: Create Release
uses: ncipollo/release-action@v1.12.0
with:
name: "v${{ needs.validate-release-increment.outputs.version }}"
tag: v${{ needs.validate-release-increment.outputs.version }}
artifacts: packages/*
omitBody: true
replacesArtifacts: true
- name: Update Helm index
run: |
git push origin ${{ steps.prepare-helm-index-update.outputs.commit_sha }}:gh-pages
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Deploy the Lumigo operator with:
```sh
make docker-build docker-push
helm install lumigo deploy/helm/templates/lumigo-operator --namespace lumigo-system --create-namespace --set "controllerManager.manager.image.repository=host.docker.internal:5000/controller" --set "controllerManager.manager.image.tag=latest" --set "controllerManager.telemetryProxy.image.repository=host.docker.internal:5000/telemetr-proxy" --set "controllerManager.telemetryProxy.image.tag=latest"
helm upgrade --install lumigo charts/lumigo-operator --namespace lumigo-system --create-namespace --set "controllerManager.manager.image.repository=host.docker.internal:5000/controller" --set "controllerManager.manager.image.tag=latest" --set "controllerManager.telemetryProxy.image.repository=host.docker.internal:5000/telemetr-proxy" --set "controllerManager.telemetryProxy.image.tag=latest"
```
### Troubleshooting
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.controller
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=${BUILDPLATFORM} golang:1.19 as builder
FROM golang:1.19 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,25 @@ docker-push: ## Push docker image with the manager.
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64 #,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
- docker buildx build --push --platform=$(PLATFORMS) --tag ${CONTROLLER_IMG} -f Dockerfile.controller .
- docker buildx build --push --platform=$(PLATFORMS) --tag ${PROXY_IMG} -f Dockerfile.proxy --build-arg "lumigo_otel_collector_release=$(shell cat telemetryproxy/VERSION.otelcontibcol)" .
docker-buildx: test docker-buildx-manager docker-buildx-telemetry-proxy ## Build and push docker image for the manager for cross-platform support

.PHONY: docker-buildx-manager
docker-buildx-manager: ## Build and push docker image for the manager for cross-platform support; this target does NOT run unit tests, it is meant for CI/CD
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile.controller > Dockerfile.controller.cross
docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
docker buildx build --push --platform=$(PLATFORMS) --tag ${CONTROLLER_IMG} -f Dockerfile.controller.cross .
- docker buildx rm project-v3-builder
rm Dockerfile.controller.cross

.PHONY: docker-buildx-telemetry-proxy
docker-buildx-telemetry-proxy: ## Build and push docker image for the manager for cross-platform support
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile.proxy > Dockerfile.proxy.cross
docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
docker buildx build --push --platform=$(PLATFORMS) --tag ${PROXY_IMG} -f Dockerfile.proxy.cross --build-arg "lumigo_otel_collector_release=$(shell cat telemetryproxy/VERSION.otelcontibcol)" .
- docker buildx rm project-v3-builder
rm Dockerfile.proxy.cross

##@ Deployment

Expand Down Expand Up @@ -167,4 +183,4 @@ $(CONTROLLER_GEN): $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) $(GOCMD) install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) $(GOCMD) install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Kubernetes operator of Lumigo provides a one-click solution to monitoring Ku
Install the Lumigo operator in your Kubernets cluster with [helm](https://helm.sh/):

```sh
helm repo add lumigo https://lumigo-io.github.io/lumigo-kubernetes-operator/stable/lumigo-operator
helm repo add lumigo https://lumigo-io.github.io/lumigo-kubernetes-operator
helm install lumigo lumigo/lumigo-operator --namespace lumigo-system --create-namespace
```

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
2
2 changes: 1 addition & 1 deletion charts/lumigo-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Kubernetes operator of Lumigo provides a one-click solution to monitoring Ku
Install the Lumigo operator in your Kubernets cluster with [helm](https://helm.sh/):

```sh
helm repo add lumigo https://lumigo-io.github.io/lumigo-kubernetes-operator/stable/lumigo-operator
helm repo add lumigo https://lumigo-io.github.io/lumigo-kubernetes-operator
helm install lumigo lumigo/lumigo-operator --namespace lumigo-system --create-namespace
```

Expand Down

0 comments on commit c97c2a4

Please sign in to comment.