From 34823fafd4e816c61419fac91269a95b8d1b3649 Mon Sep 17 00:00:00 2001 From: Christian Kreuzberger Date: Wed, 15 Dec 2021 10:00:28 +0100 Subject: [PATCH] chore: Add pre-release and release workflows, restructure CI test/build steps (#222) * chore: Added pre-release workflow, restructure ci and build Signed-off-by: Christian Kreuzberger * chore: added .versionrc Signed-off-by: Christian Kreuzberger * Update go mod Signed-off-by: Christian Kreuzberger * chore: added helm-chart build Signed-off-by: Christian Kreuzberger * Added release workflow Signed-off-by: Christian Kreuzberger * review: use proper release pipeline Signed-off-by: Christian Kreuzberger * Move helm charts to chart directory Signed-off-by: Christian Kreuzberger * Move release notes into CHANGELOG.md in accordance with the release pipeline Signed-off-by: Christian Kreuzberger * Changes according to review Signed-off-by: Christian Kreuzberger --- .dockerignore | 4 +- .github/actions/docker-build/action.yml | 52 ++++++++++ .github/actions/unit-tests/action.yml | 18 ++++ .github/workflows/CI.yml | 94 ++++++++----------- .github/workflows/pre-release.yml | 70 ++++++++++++++ .github/workflows/release.yml | 71 ++++++++++++++ .github/workflows/unit-tests.yml | 15 +++ .gitignore | 3 + .versionrc.json | 51 ++++++++++ CHANGELOG.md | 78 +++++++++++++++ Dockerfile | 5 - .../prometheus-service => chart}/.helmignore | 0 .../prometheus-service => chart}/Chart.yaml | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/deployment.yaml | 0 .../templates/hpa.yaml | 0 .../templates/ingress.yaml | 0 .../templates/service.yaml | 0 .../templates/serviceaccount.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../prometheus-service => chart}/values.yaml | 0 gh-actions-scripts/build_helm_chart.sh | 53 +++++++++++ go.mod | 3 +- go.sum | 6 -- releasenotes/releasenotes_V0.1.0.md | 13 --- releasenotes/releasenotes_V0.2.0.md | 12 --- releasenotes/releasenotes_V0.3.0.md | 6 -- releasenotes/releasenotes_V0.3.1.md | 5 - releasenotes/releasenotes_V0.3.2.md | 11 --- releasenotes/releasenotes_V0.3.6.md | 9 -- releasenotes/releasenotes_V0.4.0.md | 11 --- releasenotes/releasenotes_V0.5.0.md | 7 -- releasenotes/releasenotes_V0.6.0.md | 12 --- releasenotes/releasenotes_V0.6.1.md | 10 -- releasenotes/releasenotes_V0.6.2.md | 7 -- releasenotes/releasenotes_V0.7.0.md | 8 -- releasenotes/releasenotes_V0.7.1.md | 8 -- releasenotes/releasenotes_develop.md | 7 -- releasenotes/releasenotes_v0.3.3.md | 11 --- releasenotes/releasenotes_v0.3.5.md | 12 --- skaffold.yaml | 2 +- 42 files changed, 455 insertions(+), 219 deletions(-) create mode 100644 .github/actions/docker-build/action.yml create mode 100644 .github/actions/unit-tests/action.yml create mode 100644 .github/workflows/pre-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/unit-tests.yml create mode 100644 .versionrc.json create mode 100644 CHANGELOG.md rename {charts/prometheus-service => chart}/.helmignore (100%) rename {charts/prometheus-service => chart}/Chart.yaml (100%) rename {charts/prometheus-service => chart}/templates/NOTES.txt (100%) rename {charts/prometheus-service => chart}/templates/_helpers.tpl (100%) rename {charts/prometheus-service => chart}/templates/deployment.yaml (100%) rename {charts/prometheus-service => chart}/templates/hpa.yaml (100%) rename {charts/prometheus-service => chart}/templates/ingress.yaml (100%) rename {charts/prometheus-service => chart}/templates/service.yaml (100%) rename {charts/prometheus-service => chart}/templates/serviceaccount.yaml (100%) rename {charts/prometheus-service => chart}/templates/tests/test-connection.yaml (100%) rename {charts/prometheus-service => chart}/values.yaml (100%) create mode 100755 gh-actions-scripts/build_helm_chart.sh delete mode 100644 releasenotes/releasenotes_V0.1.0.md delete mode 100644 releasenotes/releasenotes_V0.2.0.md delete mode 100644 releasenotes/releasenotes_V0.3.0.md delete mode 100644 releasenotes/releasenotes_V0.3.1.md delete mode 100644 releasenotes/releasenotes_V0.3.2.md delete mode 100644 releasenotes/releasenotes_V0.3.6.md delete mode 100644 releasenotes/releasenotes_V0.4.0.md delete mode 100644 releasenotes/releasenotes_V0.5.0.md delete mode 100644 releasenotes/releasenotes_V0.6.0.md delete mode 100644 releasenotes/releasenotes_V0.6.1.md delete mode 100644 releasenotes/releasenotes_V0.6.2.md delete mode 100644 releasenotes/releasenotes_V0.7.0.md delete mode 100644 releasenotes/releasenotes_V0.7.1.md delete mode 100644 releasenotes/releasenotes_develop.md delete mode 100644 releasenotes/releasenotes_v0.3.3.md delete mode 100644 releasenotes/releasenotes_v0.3.5.md diff --git a/.dockerignore b/.dockerignore index a5bc8fe..72a9016 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,6 @@ README.md skaffold.yaml reviewdog.yml charts/ -deploy/ \ No newline at end of file +deploy/ +.github/ +installer/ diff --git a/.github/actions/docker-build/action.yml b/.github/actions/docker-build/action.yml new file mode 100644 index 0000000..d59d79e --- /dev/null +++ b/.github/actions/docker-build/action.yml @@ -0,0 +1,52 @@ +name: 'Docker Build Push' +description: 'Docker build and Push' +inputs: + TAGS: + description: "List of tags to be pushed, e.g., keptncontrib/my-service:1.2.3" + required: true + VERSION: + description: "Version/Tag that the image should be published with" + required: true + REGISTRY_USER: + default: '' + REGISTRY_PASSWORD: + default: '' + GITHUB_TOKEN: + default: '' +runs: + using: "composite" + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + if: ${{ inputs.REGISTRY_USER != '' }} + with: + username: ${{ inputs.REGISTRY_USER }} + password: ${{ inputs.REGISTRY_PASSWORD }} + + - name: Login to GitHub Container Registry + if: ${{ inputs.GITHUB_TOKEN != '' }} + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ inputs.GITHUB_TOKEN }} + + - name: Load CI Environment from .ci_env + id: load_ci_env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .ci_env + + - id: docker_build_image + name: "Docker Build" + uses: docker/build-push-action@v2 + with: + context: . + tags: ${{ inputs.TAGS }} + build-args: | + version=${{ inputs.VERSION }} + push: true + pull: true # do we need this diff --git a/.github/actions/unit-tests/action.yml b/.github/actions/unit-tests/action.yml new file mode 100644 index 0000000..64cc295 --- /dev/null +++ b/.github/actions/unit-tests/action.yml @@ -0,0 +1,18 @@ +name: 'Unit Tests' +description: 'Run unit tests using go' +inputs: + GO_VERSION: + default: "1.16" +env: + GO111MODULE: "on" + GOPROXY: "https://proxy.golang.org" +runs: + using: "composite" + steps: + - name: Install Go + uses: actions/setup-go@v2.1.4 + with: + go-version: ${{ inputs.GO_VERSION }} + - name: Test + shell: bash + run: go test -race -v ./... diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5294626..d8cfe05 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -90,18 +90,28 @@ jobs: echo "::set-output name=TIME::$(date +'%H%M')" echo "::set-output name=DATETIME::$(date +'%Y%m%d')$(date +'%H%M')" + #### + # unit tests + #### + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Unit tests + uses: ./.github/actions/unit-tests + ############################################################################ - # Unit tests # + # Build Docker Image # ############################################################################ - unit-tests: - name: Unit Tests - needs: prepare_ci_run + docker_build: + needs: [prepare_ci_run] + name: Docker Build runs-on: ubuntu-20.04 + env: + VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} + DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - name: Checkout Code uses: actions/checkout@v2.4.0 @@ -111,23 +121,24 @@ jobs: with: env-file: .ci_env - - name: Test - run: go test -coverprofile=coverage.txt -covermode=atomic -v ./... - working-directory: . + - name: Docker Build + uses: ./.github/actions/docker-build + with: + TAGS: | + ${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} + ${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}.${{ env.DATETIME }} + VERSION: ${{ env.VERSION }} + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} - ############################################################################ - # Build Docker Image # - ############################################################################ - docker_build: - needs: [prepare_ci_run, unit-tests] - name: Docker Build + helm_chart_build: + needs: [prepare_ci_run, docker_build] + name: Build Helm Charts runs-on: ubuntu-20.04 env: - BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} - DATETIME: ${{ needs.prepare_ci_run.outputs.DATE }}${{ needs.prepare_ci_run.outputs.TIME }} - GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} + DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} steps: - name: Checkout Code uses: actions/checkout@v2.4.0 @@ -138,40 +149,13 @@ jobs: with: env-file: .ci_env - - id: docker_login - name: Docker Login - # only run docker login on pushes; also for PRs, but only if this is not a fork - if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository) - # note: GH does not allow to access secrets for PRs from a forked repositories due to security reasons - # that's fine, but it means we can't push images to dockerhub - uses: docker/login-action@v1.10.0 - with: - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Build Helm Charts + id: build_helm_charts + run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}.${DATETIME}" "${IMAGE}" - - id: docker_build - name: Docker Build - uses: keptn/gh-action-build-docker-image@master - with: - VERSION: ${{ env.VERSION }} - IMAGE_NAME: "${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}" - DATETIME: ${{ env.DATETIME }} - - - id: create_docker_build_report - name: Create Docker Build Report - run: | - echo "The following Docker Images have been built: " > docker_build_report_final.txt - cat docker_build_report.txt >> docker_build_report_final.txt || echo "* No images have been built or uploaded" >> docker_build_report_final.txt - echo "---" - cat docker_build_report_final.txt - - - id: report_docker_build_to_pr - # Comment the docker build report to the PR - # This only works for PRs coming from inside of the repo, not from forks - name: Report Docker Build to PR - if: (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.repository) - uses: marocchino/sticky-pull-request-comment@v2.2.0 + - name: Upload Helm Chart as an artifact + id: upload_helm_chart + uses: actions/upload-artifact@v2 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - path: docker_build_report_final.txt - recreate: true + name: helm-charts + path: installer/*.tgz diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..0cf12ca --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,70 @@ +name: Create Pre-Release +on: + workflow_dispatch: +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Unit tests + uses: ./.github/actions/unit-tests + + pre-release: + needs: test + name: Pre-Release + uses: keptn/gh-automation/.github/workflows/pre-release-integration.yml@v1.2.0 + + docker_build: + needs: [pre-release] + name: Docker Build + runs-on: ubuntu-20.04 + env: + VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} + steps: + - name: Checkout Code + uses: actions/checkout@v2.4.0 + + - name: Load CI Environment from .ci_env + id: load_ci_env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .ci_env + + - name: Docker Build + uses: ./.github/actions/docker-build + with: + TAGS: | + ${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} + ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} + VERSION: ${{ env.VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + + helm_chart_build: + needs: [pre-release, docker_build] + name: Build Helm Charts + runs-on: ubuntu-20.04 + env: + VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} + steps: + - name: Checkout Code + uses: actions/checkout@v2.4.0 + + - name: Load CI Environment from .ci_env + id: load_ci_env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .ci_env + + - name: Build Helm Charts + id: build_helm_charts + run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" + + - name: Upload Helm Chart as release asset + env: + RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload "$RELEASE_TAG" installer/*.tgz diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..96652ee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Create Release +on: + workflow_dispatch: +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Unit tests + uses: ./.github/actions/unit-tests + + release: + needs: test + name: Release + uses: keptn/gh-automation/.github/workflows/release-integration.yml@v1.2.0 + + docker_build: + needs: [release] + name: Docker Build + runs-on: ubuntu-20.04 + env: + VERSION: ${{ needs.release.outputs.RELEASE_TAG }} + steps: + - name: Checkout Code + uses: actions/checkout@v2.4.0 + + - name: Load CI Environment from .ci_env + id: load_ci_env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .ci_env + + - name: Docker Build + uses: ./.github/actions/docker-build + with: + TAGS: | + ${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} + ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} + VERSION: ${{ env.VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + + helm_chart_build: + needs: [release, docker_build] + + name: Build Helm Charts + runs-on: ubuntu-20.04 + env: + VERSION: ${{ needs.release.outputs.RELEASE_TAG }} + steps: + - name: Checkout Code + uses: actions/checkout@v2.4.0 + + - name: Load CI Environment from .ci_env + id: load_ci_env + uses: c-py/action-dotenv-to-setenv@v3 + with: + env-file: .ci_env + + - name: Build Helm Charts + id: build_helm_charts + run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" + + - name: Upload Helm Chart as release asset + env: + RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload "$RELEASE_TAG" installer/*.tgz diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..b46df53 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,15 @@ +name: Unit Tests +on: + workflow_dispatch: # run CI when triggered manually + workflow_call: # run when called from another workflow +defaults: + run: + shell: bash +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Unit tests + uses: ./.github/actions/unit-tests diff --git a/.gitignore b/.gitignore index 22d96fc..74f2d7e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ remediation.yaml /.idea /*.iml + +# ignore installer folder (packaged helm chart) +installer/ diff --git a/.versionrc.json b/.versionrc.json new file mode 100644 index 0000000..9a42680 --- /dev/null +++ b/.versionrc.json @@ -0,0 +1,51 @@ +{ + "tagPrefix": "", + "preMajor": true, + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Other" + }, + { + "type": "docs", + "section": "Docs" + }, + { + "type": "perf", + "section": "Performance" + }, + { + "type": "build", + "hidden": true + }, + { + "type": "ci", + "hidden": true + }, + { + "type": "refactor", + "section": "Refactoring" + }, + { + "type": "revert", + "hidden": true + }, + { + "type": "style", + "hidden": true + }, + { + "type": "test", + "hidden": true + } + ] +} + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..26d136f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,78 @@ +# Changelog +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +### [0.7.1](https://github.com/keptn-contrib/prometheus-service/compare/0.7.0...0.7.1) (2021-11-04) + +This release enhances prometheus-service to use the distributor of Keptn 0.10.0. + +### New Features + +- Distributor of Keptn 0.10.0 is used +- Updated to keptn/go-utils 0.10.0 + +### [0.7.0](https://github.com/keptn-contrib/prometheus-service/compare/0.6.2...0.7.0) (2021-10-11) + +This release conducts adoptions to support the auto-remediation use case with Keptn. + +### New Features + +- Allow environment variable for configuration-service #180 +- Adaptations to support the auto-remediation use case #177 + +### [0.6.2](https://github.com/keptn-contrib/prometheus-service/compare/0.6.1...0.6.2) (2021-09-03) + +This release enhances prometheus-service to use the `go-utils` package of Keptn 0.9.0. + +### New Features + +- `go-utils` package of Keptn 0.9.0 is used + +### [0.6.1](https://github.com/keptn-contrib/prometheus-service/compare/0.6.0...0.6.1) (2021-06-18) + +This release enhances prometheus-service to use the distributor of Keptn 0.8.4. + +### New Features + +- Distributor of Keptn 0.8.4 is used + +### Known Limitations +- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) + + +### [0.6.0](https://github.com/keptn-contrib/prometheus-service/compare/0.5.0...0.6.0) (2021-06-07) + +This release merges the functionality of the `prometheus-sli-service` into the `prometheus-service`. As a result, it is not required to deploy the `prometheus-sli-service` for fetching SLI metrics. + +:warning: The repository https://github.com/keptn-contrib/prometheus-sli-service is changed to read-only and will be archived. Further development of this functionality will happen here: https://github.com/keptn-contrib/prometheus-service + +### New Features + +- Adding Prometheus SLI functionalities to promtheus-services [#132](https://github.com/keptn-contrib/prometheus-service/pull/132) + +### Known Limitations +- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) + + +### [0.5.0](https://github.com/keptn-contrib/prometheus-service/compare/0.4.0...0.5.0) (2021-04-14) + +### New Features +- Adding support for connecting external prometheus server and alert manager [#117](https://github.com/keptn-contrib/prometheus-service/pull/117) + +### Known Limitations +- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) + + +### Older Releases + +You can find release notes of older releases here: + +* [0.4.0](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.4.0) +* [0.3.6](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.6) +* [0.3.5](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.5) +* [0.3.4](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.4) +* [0.3.3](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.3) +* [0.3.2](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.2) +* [0.3.1](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.1) +* [0.3.0](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.3.0) +* [0.2.0](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.2.0) +* [0.1.0](https://github.com/keptn-contrib/prometheus-service/releases/tag/0.1.0) diff --git a/Dockerfile b/Dockerfile index 027d259..677921d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,10 +54,5 @@ COPY --from=builder /go/src/github.com/keptn-contrib/prometheus-service/promethe # required for external tools to detect this as a go binary ENV GOTRACEBACK=all -# KEEP THE FOLLOWING LINES COMMENTED OUT!!! (they will be included within the CI build) -#build-uncomment ADD MANIFEST / -#build-uncomment COPY entrypoint.sh / -#build-uncomment ENTRYPOINT ["/entrypoint.sh"] - # Run the web service on container startup. CMD ["/prometheus-service"] diff --git a/charts/prometheus-service/.helmignore b/chart/.helmignore similarity index 100% rename from charts/prometheus-service/.helmignore rename to chart/.helmignore diff --git a/charts/prometheus-service/Chart.yaml b/chart/Chart.yaml similarity index 100% rename from charts/prometheus-service/Chart.yaml rename to chart/Chart.yaml diff --git a/charts/prometheus-service/templates/NOTES.txt b/chart/templates/NOTES.txt similarity index 100% rename from charts/prometheus-service/templates/NOTES.txt rename to chart/templates/NOTES.txt diff --git a/charts/prometheus-service/templates/_helpers.tpl b/chart/templates/_helpers.tpl similarity index 100% rename from charts/prometheus-service/templates/_helpers.tpl rename to chart/templates/_helpers.tpl diff --git a/charts/prometheus-service/templates/deployment.yaml b/chart/templates/deployment.yaml similarity index 100% rename from charts/prometheus-service/templates/deployment.yaml rename to chart/templates/deployment.yaml diff --git a/charts/prometheus-service/templates/hpa.yaml b/chart/templates/hpa.yaml similarity index 100% rename from charts/prometheus-service/templates/hpa.yaml rename to chart/templates/hpa.yaml diff --git a/charts/prometheus-service/templates/ingress.yaml b/chart/templates/ingress.yaml similarity index 100% rename from charts/prometheus-service/templates/ingress.yaml rename to chart/templates/ingress.yaml diff --git a/charts/prometheus-service/templates/service.yaml b/chart/templates/service.yaml similarity index 100% rename from charts/prometheus-service/templates/service.yaml rename to chart/templates/service.yaml diff --git a/charts/prometheus-service/templates/serviceaccount.yaml b/chart/templates/serviceaccount.yaml similarity index 100% rename from charts/prometheus-service/templates/serviceaccount.yaml rename to chart/templates/serviceaccount.yaml diff --git a/charts/prometheus-service/templates/tests/test-connection.yaml b/chart/templates/tests/test-connection.yaml similarity index 100% rename from charts/prometheus-service/templates/tests/test-connection.yaml rename to chart/templates/tests/test-connection.yaml diff --git a/charts/prometheus-service/values.yaml b/chart/values.yaml similarity index 100% rename from charts/prometheus-service/values.yaml rename to chart/values.yaml diff --git a/gh-actions-scripts/build_helm_chart.sh b/gh-actions-scripts/build_helm_chart.sh new file mode 100755 index 0000000..2040ce8 --- /dev/null +++ b/gh-actions-scripts/build_helm_chart.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# shellcheck disable=SC2181 + +VERSION=$1 # e.g., 0.7.2-next.0 +APP_VERSION=$2, # e.g., 0.7.2-next.0+1234 +IMAGE=$3 # e.g., prometheus-service + +if [ $# -ne 3 ]; then + echo "Usage: $0 VERSION APP_VERSION IMAGE" + exit +fi + +if [ -z "$VERSION" ]; then + echo "No Version set, exiting..." + exit 1 +fi + +if [ -z "$APP_VERSION" ]; then + echo "No Image Tag set, defaulting to version" + APP_VERSION=$VERSION +fi + + +# replace "appVersion: latest" with "appVersion: $VERSION" in all Chart.yaml files +# find . -name Chart.yaml -exec sed -i -- "s/appVersion: latest/appVersion: ${APP_VERSION}/g" {} \; +# find . -name Chart.yaml -exec sed -i -- "s/version: latest/version: ${VERSION}/g" {} \; + +mkdir installer/ + +# #################### +# HELM CHART +# #################### +BASE_PATH=. +CHARTS_PATH=chart + +helm package ${BASE_PATH}/${CHARTS_PATH} --app-version "$APP_VERSION" --version "$VERSION" +if [ $? -ne 0 ]; then + echo "Error packaging installer, exiting..." + exit 1 +fi + +mv "${IMAGE}-${VERSION}.tgz" "installer/${IMAGE}-${VERSION}.tgz" + +#verify the chart +helm template "installer/${IMAGE}-${VERSION}.tgz" --dry-run > /dev/null + +if [ $? -ne 0 ]; then + echo "::error Helm Chart for ${IMAGE} has templating errors -exiting" + exit 1 +fi + +echo "Generated files:" +echo " - installer/${IMAGE}-${VERSION}.tgz" diff --git a/go.mod b/go.mod index d917e5e..e5e7a6d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/keptn-contrib/prometheus-service -go 1.13 +go 1.16 require ( cloud.google.com/go v0.44.1 // indirect @@ -17,7 +17,6 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/keptn/go-utils v0.10.0 github.com/mitchellh/mapstructure v1.2.2 // indirect - github.com/onsi/ginkgo v1.10.2 // indirect github.com/prometheus/alertmanager v0.21.0 github.com/prometheus/common v0.10.0 github.com/prometheus/prometheus v0.0.0-20200326161412-ae041f97cfc6 diff --git a/go.sum b/go.sum index 1df0779..8360332 100644 --- a/go.sum +++ b/go.sum @@ -348,7 +348,6 @@ github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.8.3 h1:MWYcmct5EtKz0efYooPcL0yNkem+7kWxqXDi/UIh+8k= github.com/hashicorp/serf v0.8.3/go.mod h1:UpNcs7fFbpKIyZaUuSW6EPiH+eZC7OuyFD+wc1oal+k= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -468,11 +467,8 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= -github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -848,7 +844,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify/fsnotify.v1 v1.4.7 h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo= gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= @@ -856,7 +851,6 @@ gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/releasenotes/releasenotes_V0.1.0.md b/releasenotes/releasenotes_V0.1.0.md deleted file mode 100644 index 17bb72f..0000000 --- a/releasenotes/releasenotes_V0.1.0.md +++ /dev/null @@ -1,13 +0,0 @@ -# Release Notes 0.1.0 - -This service is used for setting up configuring prometheus monitoring rules -Additionally, this service is responsible for accepting messages sent by thePrometheus Alerting Manager and converting -them into Keptn events. - -## New Features -- - -## Fixed Issues -- - -## Known Limitations diff --git a/releasenotes/releasenotes_V0.2.0.md b/releasenotes/releasenotes_V0.2.0.md deleted file mode 100644 index cae29b4..0000000 --- a/releasenotes/releasenotes_V0.2.0.md +++ /dev/null @@ -1,12 +0,0 @@ -# Release Notes 0.2.0 - -## New Features -- Get infos for evaluation-done event[#875](https://github.com/keptn/keptn/issues/875) - - -## Fixed Issues -- Verify validation of remediation action [#850](https://github.com/keptn/keptn/issues/850) -- Set time in CloudEvent [#851](https://github.com/keptn/keptn/issues/851) -- Fixed issue with websocket communication [#847](https://github.com/keptn/keptn/issues/847) - -## Known Limitations diff --git a/releasenotes/releasenotes_V0.3.0.md b/releasenotes/releasenotes_V0.3.0.md deleted file mode 100644 index e555e64..0000000 --- a/releasenotes/releasenotes_V0.3.0.md +++ /dev/null @@ -1,6 +0,0 @@ -# Release Notes 0.3.0 - -## New Features -- Adapted to new SLO.yaml file format used in Keptn >=0.6.0 [#1042](https://github.com/keptn/keptn/issues/1042) -- Enable usage of custom SLI queries defined in config map [#1018](https://github.com/keptn/keptn/issues/1018) - diff --git a/releasenotes/releasenotes_V0.3.1.md b/releasenotes/releasenotes_V0.3.1.md deleted file mode 100644 index 6baf02c..0000000 --- a/releasenotes/releasenotes_V0.3.1.md +++ /dev/null @@ -1,5 +0,0 @@ -# Release Notes 0.3.1 - -## New Features - -- Minor changes related to the alerting rule setup for self healing use cases [#1185](https://github.com/keptn/keptn/issues/1185) diff --git a/releasenotes/releasenotes_V0.3.2.md b/releasenotes/releasenotes_V0.3.2.md deleted file mode 100644 index 902f8c7..0000000 --- a/releasenotes/releasenotes_V0.3.2.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release Notes 0.3.2 - -This version contains minor fixes related to the handling of events coming from the Prometheus Alerting Manager. - -## New Features - -## Fixed Issues - -- Don't generate `sh.keptn.events.problem.open` events from alerts with the state `resolved` [#40](https://github.com/keptn-contrib/prometheus-service/issues/40) - -## Known Limitations diff --git a/releasenotes/releasenotes_V0.3.6.md b/releasenotes/releasenotes_V0.3.6.md deleted file mode 100644 index 3d6a0f2..0000000 --- a/releasenotes/releasenotes_V0.3.6.md +++ /dev/null @@ -1,9 +0,0 @@ -# Release Notes 0.3.6 - -## New Features - -- Make namespace of prometheus-service deployment configurable - -## Fixed Issues - -## Known Limitations diff --git a/releasenotes/releasenotes_V0.4.0.md b/releasenotes/releasenotes_V0.4.0.md deleted file mode 100644 index b6fd1dc..0000000 --- a/releasenotes/releasenotes_V0.4.0.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release Notes 0.4.0 - -## New Features -- Configurable scrape path [#69](https://github.com/keptn-contrib/prometheus-service/issues/69) - -## Fixed Issues -- Update to CloudEvents 1.0 [#63](https://github.com/keptn-contrib/prometheus-service/issues/63) -- Removed Websocket Communication [#70](https://github.com/keptn-contrib/prometheus-service/issues/70) - -## Known Limitations -- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) diff --git a/releasenotes/releasenotes_V0.5.0.md b/releasenotes/releasenotes_V0.5.0.md deleted file mode 100644 index 3a74045..0000000 --- a/releasenotes/releasenotes_V0.5.0.md +++ /dev/null @@ -1,7 +0,0 @@ -# Release Notes 0.5.0 - -## New Features -- Adding support for connecting external prometheus server and alert manager [#117](https://github.com/keptn-contrib/prometheus-service/pull/117) - -## Known Limitations -- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) diff --git a/releasenotes/releasenotes_V0.6.0.md b/releasenotes/releasenotes_V0.6.0.md deleted file mode 100644 index 765f10c..0000000 --- a/releasenotes/releasenotes_V0.6.0.md +++ /dev/null @@ -1,12 +0,0 @@ -# Release Notes - -This release merges the functionality of the `prometheus-sli-service` into the `prometheus-service`. As a result, it is not required to deploy the `prometheus-sli-service` for fetching SLI metrics. - -:warning: The repository https://github.com/keptn-contrib/prometheus-sli-service is changed to read-only and will be archived. Further development of this functionality will happen here: https://github.com/keptn-contrib/prometheus-service - -## New Features - -- Adding Prometheus SLI functionalities to promtheus-services [#132](https://github.com/keptn-contrib/prometheus-service/pull/132) - -## Known Limitations -- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) diff --git a/releasenotes/releasenotes_V0.6.1.md b/releasenotes/releasenotes_V0.6.1.md deleted file mode 100644 index c2fa538..0000000 --- a/releasenotes/releasenotes_V0.6.1.md +++ /dev/null @@ -1,10 +0,0 @@ -# Release Notes - -This release enhances prometheus-service to use the distributor of Keptn 0.8.4. - -## New Features - -- Distributor of Keptn 0.8.4 is used - -## Known Limitations -- A know limitation is that the same keptn context is calculated for different problems [#60](https://github.com/keptn-contrib/prometheus-service/issues/60) diff --git a/releasenotes/releasenotes_V0.6.2.md b/releasenotes/releasenotes_V0.6.2.md deleted file mode 100644 index 3eaba76..0000000 --- a/releasenotes/releasenotes_V0.6.2.md +++ /dev/null @@ -1,7 +0,0 @@ -# Release Notes - -This release enhances prometheus-service to use the `go-utils` package of Keptn 0.9.0. - -## New Features - -- `go-utils` package of Keptn 0.9.0 is used \ No newline at end of file diff --git a/releasenotes/releasenotes_V0.7.0.md b/releasenotes/releasenotes_V0.7.0.md deleted file mode 100644 index 5dbf022..0000000 --- a/releasenotes/releasenotes_V0.7.0.md +++ /dev/null @@ -1,8 +0,0 @@ -# Release Notes - -This release conducts adoptions to support the auto-remediation use case with Keptn. - -## New Features - -- Allow environment variable for configuration-service #180 -- Adaptations to support the auto-remediation use case #177 diff --git a/releasenotes/releasenotes_V0.7.1.md b/releasenotes/releasenotes_V0.7.1.md deleted file mode 100644 index 0321f0c..0000000 --- a/releasenotes/releasenotes_V0.7.1.md +++ /dev/null @@ -1,8 +0,0 @@ -# Release Notes - -This release enhances prometheus-service to use the distributor of Keptn 0.10.0. - -## New Features - -- Distributor of Keptn 0.10.0 is used -- Updated to keptn/go-utils 0.10.0 diff --git a/releasenotes/releasenotes_develop.md b/releasenotes/releasenotes_develop.md deleted file mode 100644 index 0c910c2..0000000 --- a/releasenotes/releasenotes_develop.md +++ /dev/null @@ -1,7 +0,0 @@ -# Release Notes - -## New Features - -## Fixed Issues - -## Known Limitations diff --git a/releasenotes/releasenotes_v0.3.3.md b/releasenotes/releasenotes_v0.3.3.md deleted file mode 100644 index c53412c..0000000 --- a/releasenotes/releasenotes_v0.3.3.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release Notes 0.3.2 - -This version contains minor fixes related to the handling of events coming from the Prometheus Alerting Manager. - -## New Features -- Moved from dep to Go modules -- Use the correct URL for the Keptn API endpoint [#1510](https://github.com/keptn/keptn/issues/1510) - -## Fixed Issues - -## Known Limitations diff --git a/releasenotes/releasenotes_v0.3.5.md b/releasenotes/releasenotes_v0.3.5.md deleted file mode 100644 index 1358da6..0000000 --- a/releasenotes/releasenotes_v0.3.5.md +++ /dev/null @@ -1,12 +0,0 @@ -# Release Notes 0.3.5 - -This version contains minor fixes related to the handling of events coming from the Prometheus Alerting Manager. - -## New Features - -- Added `ProblemURL to problem event payload` [#1694](https://github.com/keptn/keptn/issues/1694) -- Added required RBAC permissions for prometheus-service - -## Fixed Issues - -## Known Limitations diff --git a/skaffold.yaml b/skaffold.yaml index f32c2e6..94fc9bb 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -14,5 +14,5 @@ deploy: # helm: # releases: # - name: prometheus-service - # chartPath: charts/prometheus-service + # chartPath: chart/prometheus-service # image: solidnerd/prometheus-service # no tag present!