diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..55d9de5316 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,23 @@ +documentation: + - docs/**/* + - "**/*.md" + +operator: + - operator/**/* + +scheduler: + - scheduler/**/* + +metrics-operator: + - metrics-operator/**/* + +cert-manager: + - klt-cert-manager/**/* + +ops: + - .github/**/* + - netlify.toml + - .markdownlint-cli2.yml + +helm: + - helm/**/* diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000000..1411ead30c --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,26 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - "pinned" + - "security" + - "future" + - "help wanted" + - "integrations" + - "known issue" + - "known-limitation" + - "Epic" + - "area:security" +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: true +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/markdown-checks.yaml b/.github/workflows/markdown-checks.yaml index e00fc8929e..7032a2ff1b 100644 --- a/.github/workflows/markdown-checks.yaml +++ b/.github/workflows/markdown-checks.yaml @@ -90,3 +90,4 @@ jobs: echo "" echo "CRD docs are up to date!" fi + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 505bbd6951..c32eced1b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,8 @@ jobs: packages: write id-token: write env: - IMAGE_TAG: ghcr.io/keptn/${{ matrix.config.name }}:${{ needs.release-please.outputs.tag_name }} + IMAGE_NAME: ghcr.io/keptn/${{ matrix.config.name }} + IMAGE_TAG: ${{ needs.release-please.outputs.tag_name }} steps: - name: Checkout uses: actions/checkout@v3 @@ -78,16 +79,17 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Cosign - uses: sigstore/cosign-installer@v2.8.1 + uses: sigstore/cosign-installer@v3.0.1 - name: Build Docker Image + id: docker_build_image uses: docker/build-push-action@v4 with: context: ${{ matrix.config.folder }} platforms: linux/amd64,linux/arm64 target: production tags: | - ${{ env.IMAGE_TAG }} + ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} build-args: | GIT_HASH=${{ env.GIT_SHA }} RELEASE_VERSION=dev-${{ env.DATETIME }} @@ -99,15 +101,20 @@ jobs: cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }} cache-to: type=gha,scope=${{ github.ref_name }}-${{ matrix.config.name }} - - name: Sign container images + - name: Sign container image env: - COSIGN_EXPERIMENTAL: 1 - run: cosign sign ${{ env.IMAGE_TAG }} + IMAGE_DIGEST: ${{ steps.docker_build_image.outputs.digest }} + run: | + cosign sign --yes ${{ env.IMAGE_NAME }}@${{ env.IMAGE_DIGEST }} + cosign verify \ + --certificate-identity-regexp="https://github.com/keptn/lifecycle-toolkit/.*" \ + --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ + ${{ env.IMAGE_NAME }}@${{ env.IMAGE_DIGEST }} - name: Generate SBOM uses: anchore/sbom-action@v0.13.3 with: - image: ${{ env.IMAGE_TAG }} + image: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} artifact-name: sbom-${{ matrix.config.name }} output-file: ./sbom-${{ matrix.config.name }}.spdx.json diff --git a/.github/workflows/security-scans.yml b/.github/workflows/security-scans.yml index 64d20905fd..66548ef348 100644 --- a/.github/workflows/security-scans.yml +++ b/.github/workflows/security-scans.yml @@ -192,7 +192,7 @@ jobs: path: images - name: Trivy image scan - uses: aquasecurity/trivy-action@0.9.1 + uses: aquasecurity/trivy-action@0.9.2 with: input: "images/${{ matrix.image }}-image.tar/${{ matrix.image }}-image.tar" severity: 'CRITICAL,HIGH' diff --git a/.github/workflows/set-date.yml b/.github/workflows/set-date.yml index 39e690f32c..647105ac26 100644 --- a/.github/workflows/set-date.yml +++ b/.github/workflows/set-date.yml @@ -1,8 +1,8 @@ -name: Set the End Date in the project +name: Set the Date in the project on: issues: - types: [closed] + types: [assigned, closed] jobs: set_date: runs-on: ubuntu-22.04 @@ -38,8 +38,9 @@ jobs: } }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV - echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV - + echo 'START_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start Date") | .id' project_data.json) >> $GITHUB_ENV + echo 'END_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV + - name: Get date run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV @@ -58,9 +59,36 @@ jobs: }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')" echo 'ITEM_ID='$item_id >> $GITHUB_ENV + - name: Set Start Date + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + if: github.event.action == 'assigned' + run: | + gh api graphql -f query=' + mutation ( + $project: ID! + $item: ID! + $date_field: ID! + $date_value: Date! + ) { + set_start_date: updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $date_field + value: { + date: $date_value + } + }) { + projectV2Item { + id + } + } + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$START_DATE_FIELD_ID -f date_value=$DATE + - name: Set End Date env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + if: github.event.action == 'closed' run: | gh api graphql -f query=' mutation ( @@ -81,5 +109,5 @@ jobs: id } } - }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$END_DATE_FIELD_ID -f date_value=$DATE diff --git a/.github/workflows/update-labels.yml b/.github/workflows/update-labels.yml new file mode 100644 index 0000000000..c1567890e2 --- /dev/null +++ b/.github/workflows/update-labels.yml @@ -0,0 +1,15 @@ +name: Set PR Labels + +on: + pull_request_target: +jobs: + set-labels: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-22.04 + steps: + - name: Update Labels + uses: actions/labeler@v4 + with: + sync-labels: true diff --git a/.github/workflows/yaml-checks.yaml b/.github/workflows/yaml-checks.yaml new file mode 100644 index 0000000000..455c9137da --- /dev/null +++ b/.github/workflows/yaml-checks.yaml @@ -0,0 +1,30 @@ +name: YAML checks + +on: + push: + branches: + - 'main' + - '[0-9]+.[1-9][0-9]*.x' + - 'epic/*' + paths: + - '**.yaml' + - '**.yml' + - '.yamllint' + pull_request: + branches: + - 'main' + - '[0-9]+.[1-9][0-9]*.x' + - 'epic/*' + paths: + - '**.yaml' + - '**.yml' + - '.yamllint' +jobs: + yamllint: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Lint YAML files + run: make yamllint + diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 55e529dacd..8663d4006c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{".":"0.6.0"} +{".":"0.7.0"} diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000000..7f42d4f930 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,12 @@ +sonar.projectKey=keptn_lifecycle-toolkit +sonar.projectName=lifecycle-toolkit +sonar.cpd.exclusions=**/test_*.go,\ + scheduler/test/e2e/fake/**/*.go,\ + operator/apis/lifecycle/v1alpha1/**/*.go,\ + operator/apis/lifecycle/v1alpha2/**/*.go,\ + metrics-operator/api/v1alpha1/**/*.go,\ + **/zz_generated.deepcopy.go,\ + **/fake/**/*.go +sonar.go.exclusions=**/vendor/**,\ + **/*_test.go,\ + **/fake/**/*.go diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000000..20418d5b8d --- /dev/null +++ b/.yamllint @@ -0,0 +1,37 @@ +extends: default + +rules: + braces: + level: warning + max-spaces-inside: 1 + brackets: + level: warning + max-spaces-inside: 1 + colons: + level: warning + commas: + level: warning + comments: disable + comments-indentation: disable + document-end: disable + document-start: disable + empty-lines: + level: warning + hyphens: + level: warning + indentation: + level: warning + spaces: consistent + indent-sequences: consistent + key-duplicates: + level: warning + line-length: + level: warning + max: 150 + new-line-at-end-of-file: + level: warning + new-lines: + level: warning + trailing-spaces: disable + truthy: disable + diff --git a/CHANGELOG.md b/CHANGELOG.md index a9debc1436..cd2aead2b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,128 @@ # Changelog +## [0.7.0](https://github.com/keptn/lifecycle-toolkit/compare/v0.6.0...v0.7.0) (2023-03-16) + + +### ⚠ BREAKING CHANGES + +* The different components of KLT have been renamed and use a new container image repository. For more information, please look at https://github.com/keptn/lifecycle-toolkit/issues/960 +* The handling of the CRD lifecycle and metrics has been split into two different operators + +### Features + +* adapt examples to use KeptnMetric and KeptnMetricsProvider ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* add CRD docs auto generator tooling ([#884](https://github.com/keptn/lifecycle-toolkit/issues/884)) ([5f63d9a](https://github.com/keptn/lifecycle-toolkit/commit/5f63d9a28a30a7022799d6debb365baadd72dd9b)) +* add load test metrics ([#831](https://github.com/keptn/lifecycle-toolkit/issues/831)) ([2fa1a02](https://github.com/keptn/lifecycle-toolkit/commit/2fa1a02df06656d510cc2ddd2c868e37eb42970f)) +* add YAMLLint ([#935](https://github.com/keptn/lifecycle-toolkit/issues/935)) ([48476bd](https://github.com/keptn/lifecycle-toolkit/commit/48476bd44f694ce2132b71ec92aed8259ae7fc2b)) +* added the metrics-operator ([5153a05](https://github.com/keptn/lifecycle-toolkit/commit/5153a058d6eb30b6455941ee1d76dd09f98d6689)) +* added the metrics-operator ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **cert-manager:** support certificate injection for all matching resources based on label selector ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* fill in chart README ([#987](https://github.com/keptn/lifecycle-toolkit/issues/987)) ([2321180](https://github.com/keptn/lifecycle-toolkit/commit/23211800f2b897d1b146ad97d33b0e5f1994ad06)) +* **helm-chart:** split documentation from value files ([#876](https://github.com/keptn/lifecycle-toolkit/issues/876)) ([c366739](https://github.com/keptn/lifecycle-toolkit/commit/c36673943e7ff54e2921fe6b21ad531603f367aa)) +* improve naming and use new repository ([bd49357](https://github.com/keptn/lifecycle-toolkit/commit/bd493578df8825a52ec0f027583341a80b3c90f6)) +* introduce lifecycle.keptn.sh/v1alpha3 API version ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** added conversion webhook for KeptnMetric CRDs ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** allow KeptnMetrics to be placed in any namespace ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** implement metric functionality ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** introduce KeptnMetricsProvider CRD ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** introduce migration from KeptnEvaluationProvider to KeptnMetricsProvider ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **operator:** accept LogLevels for all controllers ([#790](https://github.com/keptn/lifecycle-toolkit/issues/790)) ([d175486](https://github.com/keptn/lifecycle-toolkit/commit/d175486fc10832458ebb95b17356fee4a2ccc1d7)) +* **operator:** adapt KeptnEvaluationDefinition to reflect changes in KeptnMetric and KeptnMetricsProvider ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* remove kube-rbac-proxy ([#909](https://github.com/keptn/lifecycle-toolkit/issues/909)) ([7d2621b](https://github.com/keptn/lifecycle-toolkit/commit/7d2621b70cdfd817aa9e1a408f4ed2841aef833b)) +* use helmify to release our helm chart ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) + + +### Bug Fixes + +* adapted patch for mutating webhook to correctly add release namespace to exclusions ([#1044](https://github.com/keptn/lifecycle-toolkit/issues/1044)) ([d7cfc17](https://github.com/keptn/lifecycle-toolkit/commit/d7cfc171603cc85711e6d49b6c9cd857f312fc1b)) +* added metric-operator prefix to related ClusterRole and ClusterRoleBindings ([#1042](https://github.com/keptn/lifecycle-toolkit/issues/1042)) ([92d16a3](https://github.com/keptn/lifecycle-toolkit/commit/92d16a3c6be57b823be17f6ac3a37134d1840438)) +* fix cosign image signing after breaking changes ([#1047](https://github.com/keptn/lifecycle-toolkit/issues/1047)) ([e5abf85](https://github.com/keptn/lifecycle-toolkit/commit/e5abf85726f6a78673ba63a564c5274926726aa7)) +* fix examples ([#1053](https://github.com/keptn/lifecycle-toolkit/issues/1053)) ([6f5c105](https://github.com/keptn/lifecycle-toolkit/commit/6f5c1059d427aca97513c606b224810f9446aefc)) +* fix markdown issues in main ([#963](https://github.com/keptn/lifecycle-toolkit/issues/963)) ([ef35387](https://github.com/keptn/lifecycle-toolkit/commit/ef3538703ed87895828809c0204975015fc691be)) +* fix some sonarcloud settings ([#1018](https://github.com/keptn/lifecycle-toolkit/issues/1018)) ([a40a8d3](https://github.com/keptn/lifecycle-toolkit/commit/a40a8d36458b880a468b8714c9fcfbb403776704)) +* helm chart generation and helm pipeline ([#975](https://github.com/keptn/lifecycle-toolkit/issues/975)) ([444ba74](https://github.com/keptn/lifecycle-toolkit/commit/444ba745f7e120b7cba95291d06485002edb5f9e)) +* helm chart generation fixes ([#977](https://github.com/keptn/lifecycle-toolkit/issues/977)) ([85e9d0e](https://github.com/keptn/lifecycle-toolkit/commit/85e9d0eb3da630aa4cf636dfbcb411205de24bd8)) +* htmltest error for newly created documents ([#1010](https://github.com/keptn/lifecycle-toolkit/issues/1010)) ([4bf2919](https://github.com/keptn/lifecycle-toolkit/commit/4bf2919655b05890fc8803336091eaa8752fcae7)) +* include namespace creation in release manifest ([#855](https://github.com/keptn/lifecycle-toolkit/issues/855)) ([d7a2b48](https://github.com/keptn/lifecycle-toolkit/commit/d7a2b486dd90ff173edbab49ff59988d58cc53c1)) +* **metrics-operator:** adapt metric types from v1alpha1 ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* **metrics-operator:** use correct port for serving metrics api ([#954](https://github.com/keptn/lifecycle-toolkit/issues/954)) ([d29ab64](https://github.com/keptn/lifecycle-toolkit/commit/d29ab64c6d295239586537c8002040d480fe17cd)) +* move conversion webhooks to hub version API (v1alpha3) ([#992](https://github.com/keptn/lifecycle-toolkit/issues/992)) ([b2bb268](https://github.com/keptn/lifecycle-toolkit/commit/b2bb2685809abe7909a31518833236db8931f4c1)) +* **operator:** compute deployment interval on deployment endtime ([#842](https://github.com/keptn/lifecycle-toolkit/issues/842)) ([140b2f2](https://github.com/keptn/lifecycle-toolkit/commit/140b2f28e1effd7877401bbbb8678d76a0ccab63)) +* **operator:** invalid import of metrics ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* remove missing 404 bug ([#1006](https://github.com/keptn/lifecycle-toolkit/issues/1006)) ([e8c0f38](https://github.com/keptn/lifecycle-toolkit/commit/e8c0f389e65c74f55e482ccb96127e31d475931d)) +* remove required from release docs yaml parameters ([#952](https://github.com/keptn/lifecycle-toolkit/issues/952)) ([57cc938](https://github.com/keptn/lifecycle-toolkit/commit/57cc9389955576f3c708a6ec0352abe0dde2367c)) +* wrong link in the local-setup ([#916](https://github.com/keptn/lifecycle-toolkit/issues/916)) ([de89309](https://github.com/keptn/lifecycle-toolkit/commit/de89309070e26cd76c5d964d9dc3a46f95897ddb)) + + +### Dependency Updates + +* update aquasecurity/trivy-action action to v0.9.2 ([#985](https://github.com/keptn/lifecycle-toolkit/issues/985)) ([6c79514](https://github.com/keptn/lifecycle-toolkit/commit/6c795141316cd463094607e6794002fb57beb8b6)) +* update busybox docker tag to v1.36.0 ([#1023](https://github.com/keptn/lifecycle-toolkit/issues/1023)) ([83c1e15](https://github.com/keptn/lifecycle-toolkit/commit/83c1e1557f937d2719ba5febeb27f1defd8fa351)) +* update curlimages/curl docker tag to v7.88.1 ([#1024](https://github.com/keptn/lifecycle-toolkit/issues/1024)) ([e89264d](https://github.com/keptn/lifecycle-toolkit/commit/e89264ddd5bce4d06224ee2e762cddeb36b3e2d7)) +* update dawidd6/action-download-artifact action to v2.26.0 ([#903](https://github.com/keptn/lifecycle-toolkit/issues/903)) ([8c4ba83](https://github.com/keptn/lifecycle-toolkit/commit/8c4ba83cc3a1864b70379151f90b271eb39f39dc)) +* update dependency argoproj/argo-cd to v2.6.2 ([#871](https://github.com/keptn/lifecycle-toolkit/issues/871)) ([9c813ac](https://github.com/keptn/lifecycle-toolkit/commit/9c813ac8a74be7c1ebe9c5eacd973273ed9ef3c8)) +* update dependency argoproj/argo-cd to v2.6.3 ([#965](https://github.com/keptn/lifecycle-toolkit/issues/965)) ([4fc984f](https://github.com/keptn/lifecycle-toolkit/commit/4fc984f495c47ec24ad45e2e6d8f411c0b7bff1c)) +* update dependency golangci/golangci-lint to v1.51.2 ([#765](https://github.com/keptn/lifecycle-toolkit/issues/765)) ([7b182fa](https://github.com/keptn/lifecycle-toolkit/commit/7b182fac52faee7e2be0917c4732ccf7d26fe924)) +* update golang docker tag to v1.20.1 ([#844](https://github.com/keptn/lifecycle-toolkit/issues/844)) ([489f7f9](https://github.com/keptn/lifecycle-toolkit/commit/489f7f9100d97c79b57446db6ef1df957aa6b996)) +* update golang.org/x/exp digest to 5e25df0 ([#833](https://github.com/keptn/lifecycle-toolkit/issues/833)) ([17c8185](https://github.com/keptn/lifecycle-toolkit/commit/17c81853b19f2af6057013c91c2d3a1c8f611f37)) +* update klakegg/hugo docker tag to v0.107.0 ([#969](https://github.com/keptn/lifecycle-toolkit/issues/969)) ([018937b](https://github.com/keptn/lifecycle-toolkit/commit/018937b306af473874c09c4afb35af34c3d66ed4)) +* update kubernetes packages (patch) ([#966](https://github.com/keptn/lifecycle-toolkit/issues/966)) ([7ba66c9](https://github.com/keptn/lifecycle-toolkit/commit/7ba66c936d9d9b8271c1f0b5a7d6966cb167d1af)) +* update module github.com/onsi/ginkgo/v2 to v2.8.1 ([#867](https://github.com/keptn/lifecycle-toolkit/issues/867)) ([4c36b48](https://github.com/keptn/lifecycle-toolkit/commit/4c36b483ecacfb8639d26cde4cc0cf88bbb34826)) +* update module github.com/onsi/gomega to v1.27.0 ([#872](https://github.com/keptn/lifecycle-toolkit/issues/872)) ([5b68118](https://github.com/keptn/lifecycle-toolkit/commit/5b6811856f24cd35e19a0af074dd689c8d176655)) +* update module github.com/onsi/gomega to v1.27.1 ([#887](https://github.com/keptn/lifecycle-toolkit/issues/887)) ([4d2d0ed](https://github.com/keptn/lifecycle-toolkit/commit/4d2d0edc26bb0df43d89900cbd8324101de729ed)) +* update module github.com/open-feature/flagd to v0.3.6 ([#810](https://github.com/keptn/lifecycle-toolkit/issues/810)) ([5d431b0](https://github.com/keptn/lifecycle-toolkit/commit/5d431b0e4099a1338bd949f8d2a67acdd6fdd9cd)) +* update module github.com/open-feature/flagd to v0.3.7 ([#868](https://github.com/keptn/lifecycle-toolkit/issues/868)) ([8ed6455](https://github.com/keptn/lifecycle-toolkit/commit/8ed645573c3582952dd1519cd9aaf2ff336ace90)) +* update module github.com/open-feature/go-sdk to v1.3.0 ([#767](https://github.com/keptn/lifecycle-toolkit/issues/767)) ([576a353](https://github.com/keptn/lifecycle-toolkit/commit/576a353326bf8dd60f3cf04e44342b86325a7bb2)) +* update module github.com/prometheus/common to v0.40.0 ([#907](https://github.com/keptn/lifecycle-toolkit/issues/907)) ([d90355d](https://github.com/keptn/lifecycle-toolkit/commit/d90355d54c5af8ca4ce3d3fc9036e966dba65314)) +* update module github.com/spf13/afero to v1.9.4 ([#911](https://github.com/keptn/lifecycle-toolkit/issues/911)) ([36cfe90](https://github.com/keptn/lifecycle-toolkit/commit/36cfe909611edc168824a7f570bed73f4c019264)) +* update module k8s.io/klog/v2 to v2.90.1 ([#982](https://github.com/keptn/lifecycle-toolkit/issues/982)) ([90052bc](https://github.com/keptn/lifecycle-toolkit/commit/90052bc059af2d67f1835fe5ba72b5fa3eb77941)) +* update sigstore/cosign-installer action to v3 ([#973](https://github.com/keptn/lifecycle-toolkit/issues/973)) ([e92259a](https://github.com/keptn/lifecycle-toolkit/commit/e92259a26da97f5b9f3e8cdcdb8797e254430abf)) + + +### Docs + +* adapt KeptnEvaluationDefinition and introduce KeptnMetricsProvider ([#944](https://github.com/keptn/lifecycle-toolkit/issues/944)) ([d56bfa4](https://github.com/keptn/lifecycle-toolkit/commit/d56bfa4bceb8b5bb6040fa7410ddfa745440cf7f)) +* adapt metrics documentation and example ([#941](https://github.com/keptn/lifecycle-toolkit/issues/941)) ([82488ec](https://github.com/keptn/lifecycle-toolkit/commit/82488ec782c56295708c6f509d9d5be3f0b33fda)) +* add "Intro to KLT"; edit "Getting Started" ([#785](https://github.com/keptn/lifecycle-toolkit/issues/785)) ([27932ff](https://github.com/keptn/lifecycle-toolkit/commit/27932ff7de4418bb314065a1b62ae401b80133b1)) +* add cert-manager to jaeger installation script ([#1020](https://github.com/keptn/lifecycle-toolkit/issues/1020)) ([6dc6cee](https://github.com/keptn/lifecycle-toolkit/commit/6dc6ceefe4b6aa9191229be77d2f97466d32f07a)) +* add CONTRIBUTING.md file for docs ([#758](https://github.com/keptn/lifecycle-toolkit/issues/758)) ([17fd319](https://github.com/keptn/lifecycle-toolkit/commit/17fd319cbd494c8663179f625ddde05d2279c3a3)) +* add docs publishing information ([#949](https://github.com/keptn/lifecycle-toolkit/issues/949)) ([4351e18](https://github.com/keptn/lifecycle-toolkit/commit/4351e18c4097370520e63e48b947200a210f5380)) +* add htmltest verification for documentation ([#932](https://github.com/keptn/lifecycle-toolkit/issues/932)) ([f342ccc](https://github.com/keptn/lifecycle-toolkit/commit/f342ccc0775eb41139ba0d679526dd95127bdfe8)) +* add KLT components diagram ([#1016](https://github.com/keptn/lifecycle-toolkit/issues/1016)) ([dcf49cf](https://github.com/keptn/lifecycle-toolkit/commit/dcf49cfd0f90b5a648f14aa10c7bc4820acbf1ed)) +* add Netlify configuration and advanced build ([#892](https://github.com/keptn/lifecycle-toolkit/issues/892)) ([81cd1f2](https://github.com/keptn/lifecycle-toolkit/commit/81cd1f2d1fd11e451269e580e10ea57cfbadff71)) +* added more detailed explanation of how to make use of secrets in KeptnTasks ([#959](https://github.com/keptn/lifecycle-toolkit/issues/959)) ([06fa5fd](https://github.com/keptn/lifecycle-toolkit/commit/06fa5fd8a5d4134ea185e8909a6c2968f200bbda)) +* change Development url ([#923](https://github.com/keptn/lifecycle-toolkit/issues/923)) ([335722d](https://github.com/keptn/lifecycle-toolkit/commit/335722dabb44a7d9b5d82d8b78e4e0f022462123)) +* enhance contributors guide ([#866](https://github.com/keptn/lifecycle-toolkit/issues/866)) ([60bd934](https://github.com/keptn/lifecycle-toolkit/commit/60bd934058c34cb7e654f631c5dbe63ed2439606)) +* fix broken link in README.md ([#913](https://github.com/keptn/lifecycle-toolkit/issues/913)) ([09a4f94](https://github.com/keptn/lifecycle-toolkit/commit/09a4f94055ae3c75682b084cfd62f87ea90203f8)) +* improve netlify build ([#920](https://github.com/keptn/lifecycle-toolkit/issues/920)) ([39a002d](https://github.com/keptn/lifecycle-toolkit/commit/39a002d343df6248fe8caea78298f180e1260a09)) +* initial list of related technologies of Keptn ([#795](https://github.com/keptn/lifecycle-toolkit/issues/795)) ([d4bd002](https://github.com/keptn/lifecycle-toolkit/commit/d4bd00262bdaa86458bc4c0eac459cc5575dec35)) +* migrator for KeptnEvaluationProvider -> KeptnMetricsProvider ([#945](https://github.com/keptn/lifecycle-toolkit/issues/945)) ([5bac785](https://github.com/keptn/lifecycle-toolkit/commit/5bac7858e87ef0b825adad0b0ff35bf6ae75d412)) +* set up directories for contribution guide ([#1004](https://github.com/keptn/lifecycle-toolkit/issues/1004)) ([a3aa4e5](https://github.com/keptn/lifecycle-toolkit/commit/a3aa4e5b2d76443559727da1752921196ccffac4)) +* update README and CONTRIBUTING instructions ([#991](https://github.com/keptn/lifecycle-toolkit/issues/991)) ([e42b750](https://github.com/keptn/lifecycle-toolkit/commit/e42b750a64f3681efdfa64dd55fe3ade61f53c53)) +* use helm charts instead of manifests + document KeptnConfig CRD ([#747](https://github.com/keptn/lifecycle-toolkit/issues/747)) ([338c0fa](https://github.com/keptn/lifecycle-toolkit/commit/338c0fa2042ef74cb253d49ce050c2f61ea24f95)) +* website build improvements ([#806](https://github.com/keptn/lifecycle-toolkit/issues/806)) ([03ce732](https://github.com/keptn/lifecycle-toolkit/commit/03ce732d0cc72988c49b012df70c776cfdc8eb06)) + + +### Other + +* add Hugo caching ([#958](https://github.com/keptn/lifecycle-toolkit/issues/958)) ([b2f24fe](https://github.com/keptn/lifecycle-toolkit/commit/b2f24fe4448edd24a3711e522caf393464ee877d)) +* added sonar-project.properties file and adapted codecov settings ([#989](https://github.com/keptn/lifecycle-toolkit/issues/989)) ([ca1c6ba](https://github.com/keptn/lifecycle-toolkit/commit/ca1c6bad8e9f6983c2a781ea761201cabeeff954)) +* adjust manifest limits ([#891](https://github.com/keptn/lifecycle-toolkit/issues/891)) ([32ce1b0](https://github.com/keptn/lifecycle-toolkit/commit/32ce1b01ea71fc0d52f5848144af6675289a39f0)) +* close issues and PRs if they get stale ([#1041](https://github.com/keptn/lifecycle-toolkit/issues/1041)) ([89e03c2](https://github.com/keptn/lifecycle-toolkit/commit/89e03c21476cc6cd98ca6e1c1bef95384c8495f4)) +* fix golangci-lint errors ([#905](https://github.com/keptn/lifecycle-toolkit/issues/905)) ([a133fdd](https://github.com/keptn/lifecycle-toolkit/commit/a133fdd99515765642d354c3a0cea51408333d99)) +* improve Makefiles usage ([#921](https://github.com/keptn/lifecycle-toolkit/issues/921)) ([2761a4d](https://github.com/keptn/lifecycle-toolkit/commit/2761a4dad36f452b2dd575ab5ec1572b68602165)) +* improve markdownlint ([#946](https://github.com/keptn/lifecycle-toolkit/issues/946)) ([d5d1675](https://github.com/keptn/lifecycle-toolkit/commit/d5d1675010cf0d3b8b506ef0a24c19d284d67727)) +* move to new theme repo for docs ([74903a4](https://github.com/keptn/lifecycle-toolkit/commit/74903a481b69d3eb36c67652ea48b495b4f9fb3d)) +* **operator:** remove KeptnMetric and KeptnEvaluationProvider from klt operator ([91e57ca](https://github.com/keptn/lifecycle-toolkit/commit/91e57cadba32fce6d873bc480408f90bcb8964d9)) +* polish examples and integration tests ([#956](https://github.com/keptn/lifecycle-toolkit/issues/956)) ([72d3c9e](https://github.com/keptn/lifecycle-toolkit/commit/72d3c9ee086c203431120f6899a274180882fac4)) +* release 0.7.0 ([#843](https://github.com/keptn/lifecycle-toolkit/issues/843)) ([bade181](https://github.com/keptn/lifecycle-toolkit/commit/bade181b735c7e069c510424ad5350476e41eeba)) +* remove generated fake folder from sonar checks ([#1021](https://github.com/keptn/lifecycle-toolkit/issues/1021)) ([ec4ccb9](https://github.com/keptn/lifecycle-toolkit/commit/ec4ccb976117f88fc70afbdadd0b8c93da81edff)) +* remove golang exp dependency ([#919](https://github.com/keptn/lifecycle-toolkit/issues/919)) ([c5c3fdf](https://github.com/keptn/lifecycle-toolkit/commit/c5c3fdfc822f8da629c1114f78ce31861e4c286a)) +* run CI also on epic branches ([#853](https://github.com/keptn/lifecycle-toolkit/issues/853)) ([a2f7cce](https://github.com/keptn/lifecycle-toolkit/commit/a2f7cce17a7622ca8d5cbd9daaacc711d96b2660)) +* set new documentation approach live ([#1007](https://github.com/keptn/lifecycle-toolkit/issues/1007)) ([f3511f1](https://github.com/keptn/lifecycle-toolkit/commit/f3511f1f5efec86fb1c86a6c7e39790d662417f9)) +* switch to registry.k8s.io in yaml files in prometheus example ([#870](https://github.com/keptn/lifecycle-toolkit/issues/870)) ([909a1d6](https://github.com/keptn/lifecycle-toolkit/commit/909a1d6fd8788545e6d7cbee1351c7d574e1f39c)) +* upgraded metrics operator to go 1.19 ([#1017](https://github.com/keptn/lifecycle-toolkit/issues/1017)) ([c2238fa](https://github.com/keptn/lifecycle-toolkit/commit/c2238fa2765bf5295720c9777e80f16f2b3ee289)) + ## [0.6.0](https://github.com/keptn/lifecycle-toolkit/compare/v0.5.0...v0.6.0) (2023-02-14) diff --git a/Makefile b/Makefile index a0b34b1b25..48e034eb95 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ KUSTOMIZE_VERSION?=v4.5.7 HELM_VERSION ?= v3.11.1 CHART_VERSION = v0.5.0 # x-release-please-version +# renovate: datasource=docker depName=cytopia/yamllint +YAMLLINT_VERSION ?= alpine-1-0.14 # RELEASE_REGISTRY is the container registry to push # into. @@ -112,3 +114,6 @@ build-deploy-dev-environment: build-deploy-certmanager build-deploy-operator bui include docs/Makefile + +yamllint: + @docker run --rm -t -v $(PWD):/data cytopia/yamllint:$(YAMLLINT_VERSION) .github docs diff --git a/README.md b/README.md index a2a566becc..e96271255b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ For installing the Lifecycle Toolkit via manifests use: ```shell -kubectl apply -f https://github.com/keptn/lifecycle-toolkit/releases/download/v0.6.0/manifest.yaml +kubectl apply -f https://github.com/keptn/lifecycle-toolkit/releases/download/v0.7.0/manifest.yaml ``` diff --git a/codecov.yml b/codecov.yml index ef0d48ff17..435cf7f81c 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,12 +10,13 @@ coverage: threshold: 1% # allow patch ignore: - - "**/*.yaml" # ignore all yaml files (Kubernetes manifests, etc...) - - "**/*.yml" # same as above - - "**/*.md" # ignore all markdown files, those are not relevant for building/testing - - "**/Dockerfile" # ignore Dockerfiles, those are build with GH Actions - - "**/*.sh" # ignore shell scripts - - "**/test_utils.go" # test utils don't need to be covered + - "**/*.yaml" # ignore all yaml files (Kubernetes manifests, etc...) + - "**/*.yml" # same as above + - "**/*.md" # ignore all markdown files, those are not relevant for building/testing + - "**/Dockerfile" # ignore Dockerfiles, those are build with GH Actions + - "**/*.sh" # ignore shell scripts + - "**/test_utils.go" # test utils don't need to be covered + - "**/zz_generated.deepcopy.go" # auto-generated deepcopy files for CRD structs comment: layout: "diff, files, flags" diff --git a/dashboards/grafana/configmap/grafana-dashboard-keptn-applications.yaml b/dashboards/grafana/configmap/grafana-dashboard-keptn-applications.yaml index 6f80a019ea..ce93f95834 100644 --- a/dashboards/grafana/configmap/grafana-dashboard-keptn-applications.yaml +++ b/dashboards/grafana/configmap/grafana-dashboard-keptn-applications.yaml @@ -623,7 +623,7 @@ data: "operation": "AppPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "keptn.deployment.app.name=$Application" } ], diff --git a/dashboards/grafana/configmap/grafana-dashboard-keptn-workloads.yaml b/dashboards/grafana/configmap/grafana-dashboard-keptn-workloads.yaml index 9a3287a183..a882d3e8da 100644 --- a/dashboards/grafana/configmap/grafana-dashboard-keptn-workloads.yaml +++ b/dashboards/grafana/configmap/grafana-dashboard-keptn-workloads.yaml @@ -486,7 +486,7 @@ data: "operation": "$Workload/WorkloadPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "" } ], diff --git a/dashboards/grafana/grafana_dashboard_applications.json b/dashboards/grafana/grafana_dashboard_applications.json index a1fc41288f..16bec45608 100644 --- a/dashboards/grafana/grafana_dashboard_applications.json +++ b/dashboards/grafana/grafana_dashboard_applications.json @@ -620,7 +620,7 @@ "operation": "AppPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "keptn.deployment.app.name=$Application" } ], diff --git a/dashboards/grafana/grafana_dashboard_workloads.json b/dashboards/grafana/grafana_dashboard_workloads.json index 78a0a0d8d8..57ae2f56a6 100644 --- a/dashboards/grafana/grafana_dashboard_workloads.json +++ b/dashboards/grafana/grafana_dashboard_workloads.json @@ -483,7 +483,7 @@ "operation": "$Workload/WorkloadPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "" } ], diff --git a/dashboards/grafana/import/grafana_dashboard_applications.json b/dashboards/grafana/import/grafana_dashboard_applications.json index 8b324c1bd7..848d19767f 100644 --- a/dashboards/grafana/import/grafana_dashboard_applications.json +++ b/dashboards/grafana/import/grafana_dashboard_applications.json @@ -621,7 +621,7 @@ "operation": "AppPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "keptn.deployment.app.name=$Application" } ], diff --git a/dashboards/grafana/import/grafana_dashboard_workloads.json b/dashboards/grafana/import/grafana_dashboard_workloads.json index ba2354d4b1..3328154a3d 100644 --- a/dashboards/grafana/import/grafana_dashboard_workloads.json +++ b/dashboards/grafana/import/grafana_dashboard_workloads.json @@ -484,7 +484,7 @@ "operation": "$Workload/WorkloadPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "" } ], diff --git a/docs/.htmltest.yml b/docs/.htmltest.yml index 9c51db1436..9f9ba77c85 100644 --- a/docs/.htmltest.yml +++ b/docs/.htmltest.yml @@ -6,4 +6,7 @@ IgnoreDirs: IgnoreURLs: - "linkedin.com" - "localhost" + # our edit links in the sidebar might not work for newly created pages + - "github.com/keptn/lifecycle-toolkit/tree/main" + - "github.com/keptn/lifecycle-toolkit/edit/main" StripQueryString: false diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 1b73b2988b..3de55be06c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -76,10 +76,9 @@ To set up a local Docsy build: * [Install on Linux](https://docs.docker.com/desktop/install/linux-install/) * [Install on Windows](https://docs.docker.com/desktop/install/windows-install/) -1. Clone and build the Keptn Docsy repo: +1. Build the Keptn Docsy repo: ```console - make clone make build ``` diff --git a/docs/Makefile b/docs/Makefile index f44bd4da71..500f04f68d 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ VOLUMES := -v $(ROOT_DIR):/src HUGO_VERSION := 0.107.0 IMAGE := klakegg/hugo:$(HUGO_VERSION)-ext PORT := 1314 -DOCKER_CMD := docker run --rm -t -e HUGO_CACHEDIR=/src/tmp/.hugo +DOCKER_CMD := docker run --rm -t -e HUGO_CACHEDIR=/src/tmp/.hugo -e HUGOxPARAMSxGITHUB_REPO="" .PHONY: build server clean shell diff --git a/docs/README.md b/docs/README.md index 1363298951..1d7cb4cbf3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,8 +10,6 @@ from or from Operators; + KLTComponents-->Scheduler + Operators-->Lifecycle-Operator + Operators-->Metrics-Operator +style KLTComponents fill:#006bb8,stroke:#fff,stroke-width:px,color:#fff +style Operators fill:#d8e6f4,stroke:#fff,stroke-width:px,color:#006bb8 +style Scheduler fill:#d8e6f4,stroke:#fff,stroke-width:px,color:#006bb8 +style Lifecycle-Operator fill:#d8e6f4,stroke:#fff,stroke-width:px,color:#006bb8 +style Metrics-Operator fill:#d8e6f4,stroke:#fff,stroke-width:px,color:#006bb8 +``` + +**Keptn's Lifecycle Operator** is +a Kubernetes [operator](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) +that automates the deployment and management +of the Keptn Lifecycle Controller components in a Kubernetes cluster. +The Keptn Lifecycle Operator contains several controllers for **Keptn CRDs** +and a **Mutating Webhook**. + +Here's a brief overview: + +**Keptn CRDs:** Keptn Lifecycle Operator contains +several controllers that manage and reconcile different types of Keptn CRDs +such as the Project Controller, Service Controller, and Stage Controller. + +**Mutating Webhook:** automatically injects Keptn labels +and annotations into Kubernetes resources, +such as deployments and services. +These labels and annotations are used to enable Keptn's automation +and monitoring capabilities. + +**Keptn's Lifecycle Metrics Operator** +collects, processes, and analyzes metrics data from a variety of sources. +Once collected, this data, can be used to generate a variety of reports +and dashboards that provide insights into the health and performance of the application and infrastructure. + +**Keptn's Lifecycle Scheduler** replaces the +[Kubernetes scheduler](https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/) +to allow users to schedule events and tasks to occur +at specific times during the application lifecycle. +The Lifecycle Scheduler can trigger events such as +deployment, testing, and remediation at specific times or intervals. +The Keptn Scheduler guarantees that Pods are initiated only after +the Pre-Deployment checks are completed. diff --git a/docs/content/en/docs/concepts/architecture/working/_index.md b/docs/content/en/docs/concepts/architecture/working/_index.md new file mode 100644 index 0000000000..b292d8ecfc --- /dev/null +++ b/docs/content/en/docs/concepts/architecture/working/_index.md @@ -0,0 +1,9 @@ +--- +title: Lifecycle Toolkit Working +linktitle: How it works +description: Understand How Keptn Lifecycle Toolkit Works +weight: 80 +cascade: +--- + +### How Keptn Lifecycle Toolkit Works? diff --git a/docs/content/en/docs/crd-ref/_index.md b/docs/content/en/docs/crd-ref/_index.md index 1755a50620..e4d3b656b4 100644 --- a/docs/content/en/docs/crd-ref/_index.md +++ b/docs/content/en/docs/crd-ref/_index.md @@ -17,18 +17,18 @@ We welcome your input!** Each CRD is an object of an API library. Keptn APIs follow the Kubernetes API versioning scheme. -and is itself composed of objects and sub-objects. +and are themselves composed of objects and sub-objects. +By introducing CRDs, Keptn is extending the base Kubernetes API with new objects and functionality. +Keptn APIs follow API versioning conventions recommended by Kubernetes. For more information, see the Kubernetes documentation: * [API Overview](https://kubernetes.io/docs/reference/using-api/) -* [Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#:~:text=A%20resource%20is%20an%20endpoint,in%20a%20default%20Kubernetes%20installation.) +* [Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) * [API versioning](https://kubernetes.io/docs/reference/using-api/#api-versioning) * [Understanding Kubernetes Objects](https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/) - - diff --git a/docs/content/en/docs/getting-started.md b/docs/content/en/docs/getting-started.md index 7315e37174..0a614cef2f 100644 --- a/docs/content/en/docs/getting-started.md +++ b/docs/content/en/docs/getting-started.md @@ -5,32 +5,12 @@ description: Learn how to use the Keptn Lifecycle Toolkit. weight: 15 --- -`kubectl create -f deployment.yaml` will "blindly" deploy workloads, but who needs to be notified that this deployment -is about to happen? Is your infrastructure ready? Do your downstream services meet their SLOs? Can your infrastructure -handle the deployment? -After the deployment, beyond the standard k8s probes, how can you integrate with other tooling to automatically test the -deployment? How do you know the deployment is meeting its SLOs? Has the deployment caused any issues downstream? Who -needs to know that the deployment was successful (or unsuccessful)? +This page gives instructions for installing the Keptn Lifecycle Toolkit +and running a simple Keptn application to familiarize yourself +with how KLT works. -The Keptn Lifecycle Toolkit (KLT) "wraps" a standard Kubernetes deployment and provides both workload (single service) -tests and SLO evaluations. Multiple workloads can also be logically grouped (and evaluated) as a single cohesive unit: a -Keptn Application. In other words, an application is a collection of multiple workloads. - -The Keptn Lifecycle Toolkit is a tool and vendor-neutral mechanism - it does not depend on particular GitOps tooling - -ArgoCD, Flux, Gitlab or others - KLT works with them all. - -The Keptn Lifecycle Toolkit emits signals at every stage (k8s events, OpenTelemetry metrics and traces) to ensure your -deployments are observable. - -Available steps (applicable to both workload and application entities): - -* Pre-Deployment Tasks: e.g. checking for dependant services, checking if the cluster is ready for the deployment, etc. -* Pre-Deployment Evaluations: e.g. evaluate metrics before your application gets deployed (e.g. layout of the cluster) -* Post-Deployment Tasks: e.g. trigger a test, trigger a deployment to another cluster, etc. -* Post-Deployment Evaluations: e.g. evaluate the deployment, evaluate the test results, etc. - -## What you will learn here +You will learn how to do the following: * Use the Keptn Lifecycle Toolkit to control the deployment of your application * Connect the lifecycle-toolkit to Prometheus @@ -39,34 +19,45 @@ Available steps (applicable to both workload and application entities): ## Prerequisites +You need the following to complete this exercise: + * A Kubernetes cluster >= Kubernetes 1.24 - * If you don't have one, we recommend [Kubernetes-in-Docker(KinD)](https://kind.sigs.k8s.io/docs/user/quick-start/) - to set up your local development environment + * If you don't have one, we recommend + [Kubernetes-in-Docker(KinD)](https://kind.sigs.k8s.io/docs/user/quick-start/) + to set up your local development environment + * kubectl installed on your system * See () for more information ## Check Kubernetes Version -Run the following and ensure both client and server versions are greater than or equal to v1.24. +Run the following and ensure that both client and server versions +are running Kubernetes versions greater than or equal to v1.24. ```shell kubectl version --short ``` -The output should look like this. In this example, both client and server are at v1.24.0 so the Keptn Lifecycle Toolkit -will work. +The output should look like this. +In this example, both client and server are at v1.24.0 +so the Keptn Lifecycle Toolkit will work. {{% readfile file="./snippets/tasks/k8s_version_output.md" markdown="true" %}} -## Install the Keptn Lifecycle Toolkit - {{% readfile file="./snippets/tasks/install.md" markdown="true" %}} ## Check out the Getting Started Repository -For the further progress of this guide, we need a sample application as well as some helpers which make it easier for -your to set up your environment. These things can be found in our Getting Started repository which can be checked out as -follows: +This exercise uses a sample application and some helpers +that make it easier for you to set up your environment. +These can be found in our Getting Started repository. +Use the following command to check out this repository: + +For the further progress of this guide, +we need a sample application as well as some helpers +which make it easier foryour to set up your environment. +These things can be found in our Getting Started repository +which can be checked out as follows: ```shell git clone https://github.com/keptn-sandbox/lifecycle-toolkit-examples.git @@ -75,14 +66,22 @@ cd lifecycle-toolkit-examples ## Install the required observability features -The Keptn Lifecycle Toolkit emits OpenTelemetry data as standard but the toolkit does not come pre-bundled with -Observability backend tooling. This is deliberate as it provides flexibility for you to bring your own Observability -backend which consumes this emitted data. +The Keptn Lifecycle Toolkit emits OpenTelemetry data as standard +but the toolkit does not come pre-bundled with Observability backend tooling. +This is deliberate as it provides flexibility +for you to bring your own Observability backend +that consumes this emitted data. + +In order to use the observability features of the lifecycle toolkit, +we need a monitoring and tracing backend. + +In this guide, we use: -In order to use the observability features of the lifecycle toolkit, we need a monitoring and tracing backend. +* [Prometheus](https://prometheus.io/) for Metrics +* [Jaeger](https://jaegertracing.io) for Traces +* [Grafana](https://github.com/grafana/) for Dashboarding -In this guide, we will use [Prometheus](https://prometheus.io/) for Metrics, [Jaeger](https://jaegertracing.io) for -Traces and [Grafana](https://github.com/grafana/) for Dashboarding. +Install these with the following commands: ```shell make install-observability @@ -91,22 +90,30 @@ make restart-lifecycle-toolkit ## The Demo Application -For this demonstration, we use a slightly modified version -of [the PodTatoHead](https://github.com/podtato-head/podtato-head). +For this demonstration, we use a slightly modified version of +[the PodTatoHead](https://github.com/podtato-head/podtato-head) application. ![img.png](assets/podtatohead.png) -Over time, we will evolve this application from a simple manifest to a Keptn-managed application. We will install it -first with kubectl and add pre- as well as post-deployment tasks. For this, we will check if the entry service is -available before the other ones get scheduled. Afterward, we will add evaluations to ensure that our infrastructure is -in a good shape before we deploy the application. Finally, we will evolve to a GitOps driven deployment and will notify -an external webhook service when the deployment has finished. +Over time, we will evolve this application +from a simple manifest to a Keptn-managed application: + +* We install it with **kubectl** + then add pre- and post-deployment tasks. + * For this, we check if the entry service is available + before the other services are scheduled. +* We then add evaluations to ensure + that our infrastructure is in good shape before we deploy the application. +* Finally, we evolve to a GitOps driven deployment + and notify an external webhook service when the deployment has finished. ## Install the Demo Application (Version 1) -In the first version of the Demo application, the Keptn Lifecycle Toolkit evaluates metrics provided by prometheus and -checks if a specified amount of CPUs is available before deploying the application +In the first version of the Demo application, +the Keptn Lifecycle Toolkit evaluates metrics provided by Prometheus +and checks if the specified amount of CPUs are available +before deploying the application To install it, simply apply the manifest: @@ -118,46 +125,58 @@ You can watch the progress of the deployment as follows: ### Watch workload state -When the Lifecycle Toolkit detects workload labels ("app.kubernetes.io/name" and "keptn.sh/workload") on a resource, a -KeptnWorkloadInstance (kwi) resource will be created. Using this resource you can watch the progress of the deployment. +When the Lifecycle Toolkit detects workload labels +("app.kubernetes.io/name" or "keptn.sh/workload") on a resource, +a KeptnWorkloadInstance (kwi) resource is created. +Using this resource you can watch the progress of the deployment. ```shell kubectl get keptnworkloadinstances -n podtato-kubectl ``` -This will show the current status of the Workloads and in which phase they are at the moment. You can get more detailed -information about the workloads by describing one of the resources: +This shows the current status of the Workloads +and in which phase they are at the moment. +You can get more detailed information about the workloads +by describing one of the resources: ```shell kubectl describe keptnworkloadinstances podtato-head-podtato-head-entry -n podtato-kubectl ``` -Note that there are more detailed information in the event stream of the object. - -### Watch application state - -Although you didn't specify an application in your manifest, the Lifecycle Toolkit assumed that this is a single-service -application and created an ApplicationVersion (kav) resource for you. +Note that the event stream of the object contains more detailed information. + -Using `kubectl get keptnappversions -n podtato-kubectl` you can see state of these resources. +
+Watch application state +Although you didn't specify an application in your manifest, +the Lifecycle Toolkit assumes that this is a single-service application +and creates an ApplicationVersion (kav) resource for you. -### Watch pods +Using `kubectl get keptnappversions -n podtato-kubectl`, +you can see the state of these resources. +
-Obviously, you should see that the pods are starting normally. You can watch the state of the pods using: +
+Watch pods +Obviously, you should see that the pods are starting normally. +You can watch the state of the pods using: ```shell kubectl get pods -n podtato-kubectl ``` -Furthermore, you can port-forward the podtato-head service to your local machine and access the application via your -browser: +Furthermore, you can port-forward the podtato-head service +to your local machine and access the application via your browser: ```shell make port-forward-grafana ``` -In your browser (, Log in with the user 'admin' and the password 'admin'), you can open the -Dashboard `Keptn Applications` and see the current state of the application which should be similar to the following: +In your browser (), +log in with the user `admin` and the password `admin`). +You can open the Dashboard `Keptn Applications` +and see the current state of the application, +which should be similar to the following: ![grafana.png](assets/grafana.png) @@ -169,26 +188,34 @@ In this screen you get the following information: * Deployment Time per Version * The link to the Trace of the deployment -After some time (~60 seconds), you should see one more failed deployment in your dashboard. You can click on the link to -the trace and see the reason for the failure: +After some time (~60 seconds), +you should see one more failed deployment in your dashboard. +You can click on the link to the trace and see the reason for the failure: ![trace-failed.png](assets/trace-failed.png) -In this case, we see the name of the failed pre-deployment evaluation and the reason for the failure. In this case, the -minimum amount of CPUs is not met. This is a problem we can solve by changing the treshold in the evaluation file. +In this case, we see the name of the failed pre-deployment evaluation +and the reason for the failure. +In this case, the minimum amount of CPUs is not met. +This is a problem we can solve by changing the threshold in the evaluation file. ## Install the Demo Application (Version 2) -To achieve this, we changed the operator in the evaluation file (sample-app/version-2/app-pre-deploy-eval) from `<` -to `>` and applied the new manifest: +To achieve this, we changed the operator in the evaluation file +(sample-app/version-2/app-pre-deploy-eval) from `<` to `>` +and applied the new manifest: ```shell kubectl apply -f sample-app/version-2 ``` -After this, you can inspect the new state of the application using the same commands as before. You should see that the -deployment is now successful and that the trace is also updated. You should also see in the Grafana Dashboards that the -deployment was successful. +After this, you can inspect the new state of the application +using the same commands as before. +You should see that the deployment is now successful +and that the trace is also updated. +You should also see in the Grafana Dashboards +that the deployment was successful. -Congratulations! You successfully deployed the first application using the Keptn Lifecycle Toolkit! +Congratulations! You have successfully deployed an application +using the Keptn Lifecycle Toolkit! diff --git a/docs/content/en/docs/intro-klt.md b/docs/content/en/docs/intro-klt.md new file mode 100644 index 0000000000..46a88b2d60 --- /dev/null +++ b/docs/content/en/docs/intro-klt.md @@ -0,0 +1,100 @@ +--- +title: Introduction to the Keptn Lifecycle Toolkit +linktitle: Introduction to the Keptn Lifecycle Toolkit +description: Understand the Keptn Lifecycle Toolkit +weight: 05 +cascade: + github_subdir: "docs/content/en/docs" + path_base_for_github_subdir: "/content/en/docs-dev" +--- + +The Keptn Lifecycle Toolkit (KLT) implements observability +for deployments that are implemented with standard GitOps tools +such as ArgoCD, Flux, and Gitlab +and brings application awareness to your Kubernetes cluster. + +These standard GitOps deployment tools +do an excellent job at deploying applications +but do not handle all issues +that are required to ensure that your deployment is usable. +The Keptn Lifecycle Toolkit "wraps" a standard Kubernetes GitOps deployment +with the capability to automatically handle issues +before and after the actual deployment. + +Pre-deployment issues: + +* Send appropriate notifications that this deployment is about to happen +* Check that downstream services meet their SLOs +* Verify that your infrastructure is ready +* Ensure that your infrastructure + has the resources necessary for a successful deployment + +Post-deployment issues: + +* Integrate with tooling beyond the standard Kubernetes probes +* Automatically test the deployment +* Ensure that the deployment is meeting its SLOs +* Identify any downstream issues that may be caused by this deployment +* Send appropriate notifications about whether the deployment was successful or unsuccessful + +KLT can evaluate both workload (single service) tests +and SLO evaluations before and after the actual deployment. +Multiple workloads can also be logically grouped and evaluated +as a single cohesive unit called a `KeptnApp`. +In other words, a `KeptnApp` is a collection of multiple workloads. + +KLT is tool- and vendor neutral and does not depend on particular GitOps tooling. +KLT emits signals at every stage +(Kubernetes events, OpenTelemetry metrics and traces) +to ensure that your deployments are observable. +It supports the following steps: + +* Pre-Deployment Tasks: e.g. checking for dependant services, + setting the cluster to be ready for the deployment, etc. +* Pre-Deployment Evaluations: e.g. evaluate metrics + before your application gets deployed (e.g. layout of the cluster) +* Post-Deployment Tasks: e.g. trigger a test, + trigger a deployment to another cluster, etc. +* Post-Deployment Evaluations: e.g. evaluate the deployment, + evaluate the test results, etc. + +All of these things can be executed for a workload or for a KeptnApp, +which is a collection of multiple workloads. + +## Compare Keptn Lifecycle Toolkit and Keptn LTS + +The Keptn Lifecycle Controller (KLT) is a Keptn subproject +whose design reflects lessons we learned while developing Keptn LTS. +KLT recognizes that tools such as Argo and Flux +are very good at deploying applications. +However, these deployment tools do not provide +pre-deployment and post-deployment evaluations and actions; +this is what KLT adds. + +Keptn LTS is a long-term support release +that can deploy applications on platforms other than Kubernetes, +can accomodate complex scoring algorithms for SLO evaluations, +and can implement remediations (self-healing) for problems discovered +on the production site. + +In a December 2022 Keptn Community meeting, +we discussed the differences and similarities +between Keptn and the Keptn Lifecycle Toolkit +to help you decide which best fits your needs. +View the recording: +[Compare Keptn V1 and the Keptn Lifecycle Toolkit](https://www.youtube.com/watch?v=0nCbrG_RFos) + +## Overviews of Keptn Lifecycle Toolkit + +A number of presentations are available to give an overview +of the Keptn Lifecycle Toolkit: + +* [What is keptn, how it works, and how to get started!](https://www.dynatrace.com/news/blog/what-is-keptn-how-it-works-and-how-to-get-started/) + +* [Observability and Orchestration of your Deployment](https://www.youtube.com/watch?v=0nCbrG_RFos) + +* [Keptn Lifecycle Toolkit Demo Tutorial on k3s, with ArgoCD for GitOps, OTel, Prometheus and Grafana](https://www.youtube.com/watch?v=6J_RzpmXoCc) + +* The "IsItObservable Tutorial for KLT" will be released to YouTube soon. +* You can explore the [GitHub repository](https://github.com/isItObservable/keptn-lifecycle-Toolkit) +* that accompanies this video in the meantime. diff --git a/docs/content/en/docs/snippets/tasks/install.md b/docs/content/en/docs/snippets/tasks/install.md index ab027e76c3..159f8e5652 100644 --- a/docs/content/en/docs/snippets/tasks/install.md +++ b/docs/content/en/docs/snippets/tasks/install.md @@ -1,8 +1,8 @@ # Installation Instructions -## Install version 0.6.0 and above +## Install version 0.7.0 and above -In version 0.6.0 and later, you can install the Lifecycle Toolkit using helm charts, +In version 0.7.0 and later, you can install the Lifecycle Toolkit using helm charts, or manifests. For installing the Lifecycle Toolkit via Helm chart: @@ -52,9 +52,9 @@ kubectl wait --for=condition=Available deployment/lifecycle-operator -n keptn-li The Lifecycle Toolkit and its dependencies are now installed and ready to use. > **Note:** -Installation of the Lifecycle Toolkit version 0.5.0 and lower is not supported via helm charts. +Installation of the Lifecycle Toolkit version 0.6.0 and lower is not supported via helm charts. -## Install version 0.5.0 and earlier +## Install version 0.6.0 and earlier You must first install *cert-manager* with the following commands: diff --git a/docs/go.mod b/docs/go.mod index bb69a32b84..030dccb2c9 100644 --- a/docs/go.mod +++ b/docs/go.mod @@ -2,6 +2,7 @@ module github.com/keptn/keptn-lifecycle-toolkit/docs go 1.19 -require github.com/keptn-sandbox/lifecycle-toolkit-docs v0.0.0-20230209144724-01b35a6cfc44 // indirect= - -require github.com/google/docsy/dependencies v0.6.0 // indirect +require ( + github.com/google/docsy/dependencies v0.6.0 // indirect + github.com/keptn/docs-tooling v0.0.1 // indirect +) diff --git a/docs/go.sum b/docs/go.sum index 5c1a30a6eb..a2d5d4a360 100644 --- a/docs/go.sum +++ b/docs/go.sum @@ -1,6 +1,6 @@ github.com/FortAwesome/Font-Awesome v0.0.0-20220831210243-d3a7818c253f/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo= github.com/google/docsy/dependencies v0.6.0 h1:BFXDCINbp8ZuUGl/mrHjMfhCg+b1YX+hVLAA5fGW7Pc= github.com/google/docsy/dependencies v0.6.0/go.mod h1:EDGc2znMbGUw0RW5kWwy2oGgLt0iVXBmoq4UOqstuNE= -github.com/keptn-sandbox/lifecycle-toolkit-docs v0.0.0-20230209144724-01b35a6cfc44 h1:sKOYLKoh17pIouIO3G03C7lBfxSLTSxTfv4d/tWy280= -github.com/keptn-sandbox/lifecycle-toolkit-docs v0.0.0-20230209144724-01b35a6cfc44/go.mod h1:G40ZMFR7InR/tEEHwZ3yiSafww+CU2jf7xxQ0wQjV1M= +github.com/keptn/docs-tooling v0.0.1 h1:J9OvIp1Xhkwpp4aiIZ0sKzEeoMY5CsWhfkQv8ruxlwA= +github.com/keptn/docs-tooling v0.0.1/go.mod h1:6nzm4ykIXyoxsJo3gFsaNWbpycj4pG03lOwE3x927eo= github.com/twbs/bootstrap v4.6.2+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0= diff --git a/examples/Makefile b/examples/Makefile index ba340fd038..44fff9e7cc 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -80,3 +80,4 @@ restart-lifecycle-toolkit: kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" lifecycle-operator --watch kubectl rollout restart deployment -n "$(TOOLKIT_NAMESPACE)" scheduler -n keptn-lifecycle-toolkit-system kubectl rollout status deployment -n "$(TOOLKIT_NAMESPACE)" scheduler --watch + diff --git a/examples/sample-app/base/manifest.yaml b/examples/sample-app/base/manifest.yaml index bf7e9b98d7..fe5a6959ae 100644 --- a/examples/sample-app/base/manifest.yaml +++ b/examples/sample-app/base/manifest.yaml @@ -25,7 +25,7 @@ spec: terminationGracePeriodSeconds: 5 initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] containers: - name: server diff --git a/examples/support/observability/Makefile b/examples/support/observability/Makefile index f95262e596..ce26a4e4ff 100644 --- a/examples/support/observability/Makefile +++ b/examples/support/observability/Makefile @@ -5,7 +5,7 @@ PODTATO_NAMESPACE ?= podtato-kubectl GRAFANA_PORT_FORWARD ?= 3000 .PHONY: install -install: +install: install-cert-manager @echo "-----------------------------------" @echo "Create Namespace and install Jaeger" @echo "-----------------------------------" @@ -52,6 +52,14 @@ install: @echo "- Port-Forward Grafana: make port-forward-grafana" @echo "#######################################################" +.PHONY: install-cert-manager +install-cert-manager: + @echo "-----------------------------------" + @echo "Create Namespace and install CertManager" + @echo "-----------------------------------" + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml + kubectl wait --for=condition=Available deployment/cert-manager-webhook -n cert-manager --timeout=60s + .PHONY: port-forward-jaeger port-forward-jaeger: @echo "" diff --git a/examples/support/observability/assets/podtatohead-deployment-evaluation/manifest.yaml b/examples/support/observability/assets/podtatohead-deployment-evaluation/manifest.yaml index 76c9ee1572..d0552cd510 100644 --- a/examples/support/observability/assets/podtatohead-deployment-evaluation/manifest.yaml +++ b/examples/support/observability/assets/podtatohead-deployment-evaluation/manifest.yaml @@ -29,11 +29,11 @@ spec: terminationGracePeriodSeconds: 5 initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] containers: - name: server - image: ghcr.io/podtato-head/entry:latest + image: ghcr.io/podtato-head/entry:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -86,7 +86,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/hat:latest + image: ghcr.io/podtato-head/hat:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -135,7 +135,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-leg:latest + image: ghcr.io/podtato-head/left-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -184,7 +184,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-arm:latest + image: ghcr.io/podtato-head/left-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -233,7 +233,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-leg:latest + image: ghcr.io/podtato-head/right-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -282,7 +282,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-arm:latest + image: ghcr.io/podtato-head/right-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 diff --git a/examples/support/observability/config/prometheus/grafana-dashboard-keptn-applications.yaml b/examples/support/observability/config/prometheus/grafana-dashboard-keptn-applications.yaml index 6f80a019ea..ce93f95834 100644 --- a/examples/support/observability/config/prometheus/grafana-dashboard-keptn-applications.yaml +++ b/examples/support/observability/config/prometheus/grafana-dashboard-keptn-applications.yaml @@ -623,7 +623,7 @@ data: "operation": "AppPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "keptn.deployment.app.name=$Application" } ], diff --git a/examples/support/observability/config/prometheus/grafana-dashboard-keptn-workloads.yaml b/examples/support/observability/config/prometheus/grafana-dashboard-keptn-workloads.yaml index 9a3287a183..a882d3e8da 100644 --- a/examples/support/observability/config/prometheus/grafana-dashboard-keptn-workloads.yaml +++ b/examples/support/observability/config/prometheus/grafana-dashboard-keptn-workloads.yaml @@ -486,7 +486,7 @@ data: "operation": "$Workload/WorkloadPreDeployTasks", "queryType": "search", "refId": "A", - "service": "keptn-lifecycle-operator", + "service": "lifecycle-operator", "tags": "" } ], diff --git a/helm/chart/Chart.yaml b/helm/chart/Chart.yaml index 2fc5f96601..f0a2a61597 100644 --- a/helm/chart/Chart.yaml +++ b/helm/chart/Chart.yaml @@ -27,7 +27,7 @@ annotations: artifacthub.io/operator: "true" artifacthub.io/operatorCapabilities: "Full Lifecycle" -kubeVersion: ">= 1.24.0" +kubeVersion: ">= 1.24.0-0" # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives diff --git a/helm/overlay/kustomization.yaml b/helm/overlay/kustomization.yaml index 81ec36c9bc..0221bfcab0 100644 --- a/helm/overlay/kustomization.yaml +++ b/helm/overlay/kustomization.yaml @@ -21,5 +21,27 @@ patches: - '{{ .Release.Namespace }}' target: kind: MutatingWebhookConfiguration - name: "(mutating-webhook-configuration)" + name: "(lifecycle-mutating-webhook-configuration)" + + - patch: | + - op: replace + path: '/spec/service/namespace' + value: '{{ .Release.Namespace }}' + - op: replace + path: '/spec/service/name' + value: '{{ include "chart.fullname" . }}-metrics-operator-service' + target: + kind: APIService + name: "(v1beta2.custom.metrics.k8s.io)" + + - patch: | + - op: replace + path: '/spec/service/namespace' + value: '{{ .Release.Namespace }}' + - op: replace + path: '/spec/service/name' + value: '{{ include "chart.fullname" . }}-metrics-operator-service' + target: + kind: APIService + name: "(v1beta1.custom.metrics.k8s.io)" diff --git a/klt-cert-manager/go.mod b/klt-cert-manager/go.mod index 6f56e2d5b3..a0414225c1 100644 --- a/klt-cert-manager/go.mod +++ b/klt-cert-manager/go.mod @@ -7,10 +7,10 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.1 - k8s.io/api v0.26.1 - k8s.io/apiextensions-apiserver v0.26.1 - k8s.io/apimachinery v0.26.1 - k8s.io/client-go v0.26.1 + k8s.io/api v0.26.2 + k8s.io/apiextensions-apiserver v0.26.2 + k8s.io/apimachinery v0.26.2 + k8s.io/client-go v0.26.2 sigs.k8s.io/controller-runtime v0.14.4 ) @@ -50,11 +50,11 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/term v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/term v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect golang.org/x/time v0.3.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -62,7 +62,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/component-base v0.26.1 // indirect + k8s.io/component-base v0.26.2 // indirect k8s.io/klog/v2 v2.80.1 // indirect k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect diff --git a/klt-cert-manager/go.sum b/klt-cert-manager/go.sum index e77683f936..9efa7331b6 100644 --- a/klt-cert-manager/go.sum +++ b/klt-cert-manager/go.sum @@ -354,8 +354,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 h1:Frnccbp+ok2GkUS2tC84yAq/U9Vg+0sIO7aRL3T4Xnc= -golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -414,12 +414,12 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -427,8 +427,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -593,16 +593,16 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= -k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg= -k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= -k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= -k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= -k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= -k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE= -k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4= -k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU= +k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= +k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= +k8s.io/apiextensions-apiserver v0.26.2 h1:/yTG2B9jGY2Q70iGskMf41qTLhL9XeNN2KhI0uDgwko= +k8s.io/apiextensions-apiserver v0.26.2/go.mod h1:Y7UPgch8nph8mGCuVk0SK83LnS8Esf3n6fUBgew8SH8= +k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= +k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= +k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= +k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= +k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= +k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4= k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= diff --git a/metrics-operator/config/metrics/role.yaml b/metrics-operator/config/metrics/role.yaml index 24cb504c5a..c293029159 100644 --- a/metrics-operator/config/metrics/role.yaml +++ b/metrics-operator/config/metrics/role.yaml @@ -1,7 +1,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: server-resources + name: metrics-operator-server-resources rules: - apiGroups: - custom.metrics.k8s.io diff --git a/metrics-operator/config/metrics/role_binding.yaml b/metrics-operator/config/metrics/role_binding.yaml index bbf9645796..322a8dd3e4 100644 --- a/metrics-operator/config/metrics/role_binding.yaml +++ b/metrics-operator/config/metrics/role_binding.yaml @@ -15,11 +15,11 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: hpa-controller-keptn-metrics + name: metrics-operator-hpa-controller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: server-resources + name: metrics-operator-server-resources subjects: - kind: ServiceAccount name: horizontal-pod-autoscaler diff --git a/metrics-operator/go.mod b/metrics-operator/go.mod index a693340627..55c35a5700 100644 --- a/metrics-operator/go.mod +++ b/metrics-operator/go.mod @@ -1,26 +1,26 @@ module github.com/keptn/lifecycle-toolkit/metrics-operator -go 1.18 +go 1.19 require ( github.com/benbjohnson/clock v1.3.0 github.com/go-logr/logr v1.2.3 github.com/gorilla/mux v1.8.0 github.com/kelseyhightower/envconfig v1.4.0 - github.com/open-feature/go-sdk v1.1.0 + github.com/open-feature/go-sdk v1.3.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.14.0 github.com/prometheus/common v0.39.0 github.com/spf13/afero v1.9.3 github.com/stretchr/testify v1.8.1 - k8s.io/api v0.26.1 - k8s.io/apiextensions-apiserver v0.26.1 - k8s.io/apimachinery v0.26.1 - k8s.io/apiserver v0.26.1 - k8s.io/client-go v0.26.1 - k8s.io/component-base v0.26.1 - k8s.io/klog/v2 v2.90.0 - k8s.io/metrics v0.26.1 + k8s.io/api v0.26.2 + k8s.io/apiextensions-apiserver v0.26.2 + k8s.io/apimachinery v0.26.2 + k8s.io/apiserver v0.26.2 + k8s.io/client-go v0.26.2 + k8s.io/component-base v0.26.2 + k8s.io/klog/v2 v2.90.1 + k8s.io/metrics v0.26.2 sigs.k8s.io/controller-runtime v0.14.4 sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230116101851-63817c8ac8f2 ) @@ -32,7 +32,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cenkalti/backoff/v4 v4.2.0 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -90,7 +90,7 @@ require ( go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.1.0 // indirect - golang.org/x/net v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.3.0 // indirect golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect golang.org/x/sys v0.5.0 // indirect @@ -106,7 +106,7 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/kms v0.26.1 // indirect + k8s.io/kms v0.26.2 // indirect k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect diff --git a/metrics-operator/go.sum b/metrics-operator/go.sum index 4a0cb559fd..e8cae9c05e 100644 --- a/metrics-operator/go.sum +++ b/metrics-operator/go.sum @@ -69,8 +69,8 @@ github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -293,8 +293,8 @@ github.com/onsi/ginkgo/v2 v2.8.1 h1:xFTEVwOFa1D/Ty24Ws1npBWkDYEV9BqZrsDxVrVkrrU= github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= github.com/onsi/gomega v1.27.0 h1:QLidEla4bXUuZVFa4KX6JHCsuGgbi85LC/pCHrt/O08= github.com/onsi/gomega v1.27.0/go.mod h1:i189pavgK95OSIipFBa74gC2V4qrQuvjuyGEr3GmbXA= -github.com/open-feature/go-sdk v1.1.0 h1:JOOa0AleJFUvnWoF9KWdLqYosi5fDIRBDzPYZPr5qgM= -github.com/open-feature/go-sdk v1.1.0/go.mod h1:R8QJmLdSHFaRdrWtwmp5bVK35Q+O/cEGtYaiy6NM6kc= +github.com/open-feature/go-sdk v1.3.0 h1:SiIS0ElVZTjbmHZB1/5Fm5mBRIqoYD+c2jVdw+D+Qok= +github.com/open-feature/go-sdk v1.3.0/go.mod h1:hEOzRFh23MH+IZttR9+zyf5jBzotxxxcCjnk/wBH2H0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -331,7 +331,7 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= @@ -495,8 +495,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -786,26 +786,26 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= -k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg= -k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= -k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= -k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= -k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/apiserver v0.26.1 h1:6vmnAqCDO194SVCPU3MU8NcDgSqsUA62tBUSWrFXhsc= -k8s.io/apiserver v0.26.1/go.mod h1:wr75z634Cv+sifswE9HlAo5FQ7UoUauIICRlOE+5dCg= -k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= -k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE= -k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4= -k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU= -k8s.io/klog/v2 v2.90.0 h1:VkTxIV/FjRXn1fgNNcKGM8cfmL1Z33ZjXRTVxKCoF5M= -k8s.io/klog/v2 v2.90.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kms v0.26.1 h1:JE0n4J4+8/Z+egvXz2BTJeJ9ecsm4ZSLKF7ttVXXm/4= -k8s.io/kms v0.26.1/go.mod h1:ReC1IEGuxgfN+PDCIpR6w8+XMmDE7uJhxcCwMZFdIYc= +k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= +k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= +k8s.io/apiextensions-apiserver v0.26.2 h1:/yTG2B9jGY2Q70iGskMf41qTLhL9XeNN2KhI0uDgwko= +k8s.io/apiextensions-apiserver v0.26.2/go.mod h1:Y7UPgch8nph8mGCuVk0SK83LnS8Esf3n6fUBgew8SH8= +k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= +k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= +k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o= +k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8= +k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= +k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= +k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= +k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= +k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= +k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/kms v0.26.2 h1:GM1gg3tFK3OUU/QQFi93yGjG3lJT8s8l3Wkn2+VxBLM= +k8s.io/kms v0.26.2/go.mod h1:69qGnf1NsFOQP07fBYqNLZklqEHSJF024JqYCaeVxHg= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= -k8s.io/metrics v0.26.1 h1:iB+QdMLa2V70a7zb0XYEcaUpPM0y+p4fZN0UtxcPHLk= -k8s.io/metrics v0.26.1/go.mod h1:fMeLXmK/xgvckFG63GJ0kDjFiQH7P0Dpi5Lvhlo5DXE= +k8s.io/metrics v0.26.2 h1:2gUvUWWnHPdE2tyA5DvyHC8HGryr+izhY9i5dzLP06s= +k8s.io/metrics v0.26.2/go.mod h1:PX1wm9REV9hSGuw9GcXTFNDgab1KRXck3mNeiLYbRho= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/metrics-operator/pkg/metrics/server.go b/metrics-operator/pkg/metrics/server.go index 4ebb7af6c7..b91df11d86 100644 --- a/metrics-operator/pkg/metrics/server.go +++ b/metrics-operator/pkg/metrics/server.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "net/http" - "os" "strconv" "strings" "sync" @@ -16,8 +15,10 @@ import ( "github.com/gorilla/mux" metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" "github.com/open-feature/go-sdk/pkg/openfeature" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" + k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" @@ -27,8 +28,6 @@ type Metrics struct { gauges map[string]prometheus.Gauge } -var metrics Metrics - var instance *serverManager var smOnce sync.Once @@ -38,13 +37,13 @@ type serverManager struct { ofClient *openfeature.Client exposeMetrics bool k8sClient client.Client + metrics Metrics } // StartServerManager starts a server manager to expose metrics and runs until // the context is cancelled (i.e. an env variable gets changes and pod is restarted) func StartServerManager(ctx context.Context, client client.Client, ofClient *openfeature.Client, exposeMetrics bool, interval time.Duration) { smOnce.Do(func() { - metrics.gauges = make(map[string]prometheus.Gauge) instance = &serverManager{ ticker: clock.New().Ticker(interval), ofClient: ofClient, @@ -108,6 +107,9 @@ func (m *serverManager) setup() error { klog.Infof("Keptn Metrics server enabled: %v", serverEnabled) if serverEnabled && m.server == nil { + + m.metrics.gauges = make(map[string]prometheus.Gauge) + klog.Infof("serving Prometheus metrics at localhost:9999/metrics") klog.Infof("serving KeptnMetrics at localhost:9999/api/v1/metrics/{namespace}/{metric}") @@ -142,10 +144,15 @@ func (m *serverManager) returnMetric(w http.ResponseWriter, r *http.Request) { namespace := vars["namespace"] metric := vars["metric"] - metricObj := metricsapi.KeptnMetric{} - err := m.k8sClient.Get(context.Background(), types.NamespacedName{Name: metric, Namespace: namespace}, &metricObj) + metricObj := &metricsapi.KeptnMetric{} + err := m.k8sClient.Get(context.Background(), types.NamespacedName{Name: metric, Namespace: namespace}, metricObj) if err != nil { fmt.Println("failed to list keptn-metrics: " + err.Error()) + //nolint:errorlint + if status, ok := err.(k8serrors.APIStatus); ok || errors.As(err, &status) { + w.WriteHeader(int(status.Status().Code)) + } + return } data := map[string]string{ @@ -157,8 +164,9 @@ func (m *serverManager) returnMetric(w http.ResponseWriter, r *http.Request) { err = json.NewEncoder(w).Encode(data) if err != nil { fmt.Println("failed to encode data") - os.Exit(1) + w.WriteHeader(http.StatusUnprocessableEntity) } + } func (m *serverManager) recordMetrics() { @@ -174,15 +182,15 @@ func (m *serverManager) recordMetrics() { } for _, metric := range list.Items { normName := normalizeMetricName(metric.Name) - if _, ok := metrics.gauges[normName]; !ok { - metrics.gauges[normName] = prometheus.NewGauge(prometheus.GaugeOpts{ + if _, ok := m.metrics.gauges[normName]; !ok { + m.metrics.gauges[normName] = prometheus.NewGauge(prometheus.GaugeOpts{ Name: normName, Help: metric.Name, }) - prometheus.MustRegister(metrics.gauges[normName]) + prometheus.MustRegister(m.metrics.gauges[normName]) } val, _ := strconv.ParseFloat(metric.Status.Value, 64) - metrics.gauges[normName].Set(val) + m.metrics.gauges[normName].Set(val) } <-time.After(10 * time.Second) } diff --git a/metrics-operator/pkg/metrics/server_test.go b/metrics-operator/pkg/metrics/server_test.go index b4877fdcdf..7764ca72bb 100644 --- a/metrics-operator/pkg/metrics/server_test.go +++ b/metrics-operator/pkg/metrics/server_test.go @@ -4,9 +4,11 @@ import ( "bytes" "context" "net/http" + "os" "testing" "time" + "github.com/benbjohnson/clock" metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" "github.com/open-feature/go-sdk/pkg/openfeature" "github.com/stretchr/testify/require" @@ -15,8 +17,40 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" ) +func TestMain(m *testing.M) { + err := metricsapi.AddToScheme(scheme.Scheme) + if err != nil { + panic("BAD SCHEME!") + } + code := m.Run() + os.Exit(code) +} + +func TestMetricServer_disabledServer(t *testing.T) { + + tInstance := &serverManager{ + ticker: clock.New().Ticker(3 * time.Second), + ofClient: openfeature.NewClient("klt-test"), + exposeMetrics: false, + k8sClient: fake.NewClientBuilder().WithScheme(scheme.Scheme).Build(), + } + tInstance.start(context.Background()) + + var err error + require.Eventually(t, func() bool { + cli := &http.Client{} + req, _ := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://localhost:9999/metrics", nil) + _, err = cli.Do(req) + return err != nil + }, 30*time.Second, 3*time.Second) + + require.Contains(t, err.Error(), "connection refused") + +} + func TestMetricServer_happyPath(t *testing.T) { - metric := metricsapi.KeptnMetric{ + + var metric = metricsapi.KeptnMetric{ ObjectMeta: v1.ObjectMeta{ Name: "sample-metric", Namespace: "keptn-lifecycle-toolkit-system", @@ -28,25 +62,34 @@ func TestMetricServer_happyPath(t *testing.T) { Query: "query", FetchIntervalSeconds: 5, }, + Status: metricsapi.KeptnMetricStatus{ + Value: "12", + RawValue: nil, + LastUpdated: v1.Time{ + Time: time.Now(), + }, + }, } - - err := metricsapi.AddToScheme(scheme.Scheme) - require.Nil(t, err) k8sClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(&metric).Build() - ctx, cancel := context.WithCancel(context.Background()) - - StartServerManager(ctx, k8sClient, openfeature.NewClient("klt-test"), true, 3*time.Second) + tInstance := &serverManager{ + ticker: clock.New().Ticker(3 * time.Second), + ofClient: openfeature.NewClient("klt-test"), + exposeMetrics: true, + k8sClient: k8sClient, + } + tInstance.start(context.Background()) require.Eventually(t, func() bool { - return instance.server != nil - }, 10*time.Second, time.Second) + return tInstance.server != nil + }, 30*time.Second, time.Second) var resp *http.Response + var err error require.Eventually(t, func() bool { cli := &http.Client{} - req, err2 := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost:9999/metrics", nil) + req, err2 := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://localhost:9999/metrics", nil) require.Nil(t, err2) resp, err = cli.Do(req) return err == nil @@ -61,41 +104,50 @@ func TestMetricServer_happyPath(t *testing.T) { require.Contains(t, newStr, "# TYPE sample_metric gauge") - cancel() - require.Eventually(t, func() bool { - return instance.server == nil + cli := &http.Client{} + req, _ := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://localhost:9999/api/v1/metrics/keptn-lifecycle-toolkit-system/sample-metric", nil) + resp, err = cli.Do(req) + return err == nil }, 10*time.Second, time.Second) + + defer resp.Body.Close() + + buf = new(bytes.Buffer) + _, err = buf.ReadFrom(resp.Body) + require.Nil(t, err) + newStr = buf.String() + + require.Contains(t, newStr, "\"metric\":\"sample-metric\",\"namespace\":\"keptn-lifecycle-toolkit-system\",\"value\":\"12\"") } -func TestMetricServer_disabledServer(t *testing.T) { - err2 := metricsapi.AddToScheme(scheme.Scheme) - require.Nil(t, err2) - k8sClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).Build() +func TestMetricServer_noMetric(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + k8sClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).Build() - StartServerManager(ctx, k8sClient, openfeature.NewClient("klt-test"), false, 3*time.Second) + tInstance := &serverManager{ + ticker: clock.New().Ticker(3 * time.Second), + ofClient: openfeature.NewClient("klt-test"), + exposeMetrics: true, + k8sClient: k8sClient, + } + tInstance.start(context.Background()) require.Eventually(t, func() bool { - return instance.server == nil - }, 30*time.Second, 3*time.Second) + return tInstance.server != nil + }, 30*time.Second, time.Second) + var resp *http.Response var err error - require.Eventually(t, func() bool { cli := &http.Client{} - req, err2 := http.NewRequestWithContext(ctx, http.MethodGet, "http://localhost:9999/metrics", nil) - require.Nil(t, err2) - _, err = cli.Do(req) - return err != nil - }, 30*time.Second, 3*time.Second) - - require.Contains(t, err.Error(), "connection refused") + req, _ := http.NewRequestWithContext(context.TODO(), http.MethodGet, "http://localhost:9999/api/v1/metrics/default/sample", nil) + resp, err = cli.Do(req) + return err == nil + }, 10*time.Second, time.Second) - cancel() + defer resp.Body.Close() + stat := resp.StatusCode + require.Equal(t, 404, stat) - require.Eventually(t, func() bool { - return instance.server == nil - }, 30*time.Second, 3*time.Second) } diff --git a/netlify.toml b/netlify.toml index 96a14b2bec..73e13b6eb6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -10,6 +10,11 @@ ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../netlify.toml" HUGO_VERSION = "0.107.0" HUGO_ENABLEGITINFO = "true" +# On netlify our branch will always be the one we are currently building for +# important information regarding naming +# https://gohugo.io/getting-started/configuration/#configure-with-environment-variables +HUGOxPARAMSxGITHUB_BRANCH="$BRANCH" + [context.deploy-preview] HUGO_ENV = "development" diff --git a/operator/Makefile b/operator/Makefile index 7aca23d765..32feeac99d 100644 --- a/operator/Makefile +++ b/operator/Makefile @@ -97,7 +97,24 @@ test: manifests fmt vet generate envtest ## Run tests. .PHONY: component-test component-test: manifests generate envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/... -v -timeout 30m -coverprofile cover.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/app/... -v -timeout 30m -coverprofile cover-app.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/appversion/... -v -timeout 30m -coverprofile cover-appversion.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnappversion/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/evaluation/... -v -timeout 30m -coverprofile cover-evaluation.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnevaluation/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/load/... -v -timeout 30m + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/task/... -v -timeout 30m -coverprofile cover-task.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntask/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/taskdefinition/... -v -timeout 30m -coverprofile cover-taskdefinition.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntaskdefinition/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/workload/... -v -timeout 30m -coverprofile cover-workload.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkload/..." + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./test/component/workloadinstance/... -v -timeout 30m -coverprofile cover-workloadinstance.out -coverpkg "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkloadinstance/..." + sed -i '/mode: set/d' "cover-app.out" + sed -i '/mode: set/d' "cover-appversion.out" + sed -i '/mode: set/d' "cover-evaluation.out" + sed -i '/mode: set/d' "cover-task.out" + sed -i '/mode: set/d' "cover-taskdefinition.out" + sed -i '/mode: set/d' "cover-workload.out" + sed -i '/mode: set/d' "cover-workloadinstance.out" + echo "mode: set" > cover.out + cat cover-app.out cover-appversion.out cover-evaluation.out cover-task.out cover-taskdefinition.out cover-workload.out cover-workloadinstance.out >> cover.out + rm cover-app.out cover-appversion.out cover-evaluation.out cover-task.out cover-taskdefinition.out cover-workload.out cover-workloadinstance.out .PHONY: performance-test performance-test: manifests generate envtest ## Run tests. diff --git a/operator/config/manager/kustomization.yaml b/operator/config/manager/kustomization.yaml index dfab72a370..fd5d42e9da 100644 --- a/operator/config/manager/kustomization.yaml +++ b/operator/config/manager/kustomization.yaml @@ -1,5 +1,6 @@ resources: - manager.yaml +- service.yaml generatorOptions: disableNameSuffixHash: true configMapGenerator: diff --git a/operator/config/manager/manager.yaml b/operator/config/manager/manager.yaml index 44d1906285..d6bf1b9203 100644 --- a/operator/config/manager/manager.yaml +++ b/operator/config/manager/manager.yaml @@ -70,7 +70,7 @@ spec: - name: OTEL_COLLECTOR_URL value: otel-collector:4317 - name: FUNCTION_RUNNER_IMAGE - value: ghcr.keptn.sh/keptn/functions-runtime:v0.6.0 #x-release-please-version + value: ghcr.keptn.sh/keptn/functions-runtime:v0.7.0 #x-release-please-version - name: KEPTN_APP_CONTROLLER_LOG_LEVEL value: "0" - name: KEPTN_APP_VERSION_CONTROLLER_LOG_LEVEL diff --git a/operator/config/manager/service.yaml b/operator/config/manager/service.yaml new file mode 100644 index 0000000000..98e38111e3 --- /dev/null +++ b/operator/config/manager/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: lifecycle-operator-metrics-service + namespace: system +spec: + ports: + - name: metrics + protocol: TCP + port: 2222 + targetPort: metrics + selector: + control-plane: lifecycle-operator diff --git a/operator/go.mod b/operator/go.mod index 934899b3ad..24f1d8530e 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -24,11 +24,11 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.34.0 go.opentelemetry.io/otel/trace v1.11.2 google.golang.org/grpc v1.52.3 - k8s.io/api v0.26.1 - k8s.io/apiextensions-apiserver v0.26.1 - k8s.io/apimachinery v0.26.1 - k8s.io/apiserver v0.26.1 - k8s.io/client-go v0.26.1 + k8s.io/api v0.26.2 + k8s.io/apiextensions-apiserver v0.26.2 + k8s.io/apimachinery v0.26.2 + k8s.io/apiserver v0.26.2 + k8s.io/client-go v0.26.2 sigs.k8s.io/controller-runtime v0.14.4 ) @@ -89,7 +89,7 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/component-base v0.26.1 // indirect + k8s.io/component-base v0.26.2 // indirect k8s.io/klog/v2 v2.90.0 // indirect k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect diff --git a/operator/go.sum b/operator/go.sum index eac71f5ea9..02f7a41c0b 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -652,18 +652,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= -k8s.io/api v0.26.1/go.mod h1:xd/GBNgR0f707+ATNyPmQ1oyKSgndzXij81FzWGsejg= -k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= -k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= -k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= -k8s.io/apimachinery v0.26.1/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74= -k8s.io/apiserver v0.26.1 h1:6vmnAqCDO194SVCPU3MU8NcDgSqsUA62tBUSWrFXhsc= -k8s.io/apiserver v0.26.1/go.mod h1:wr75z634Cv+sifswE9HlAo5FQ7UoUauIICRlOE+5dCg= -k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= -k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE= -k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4= -k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU= +k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= +k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= +k8s.io/apiextensions-apiserver v0.26.2 h1:/yTG2B9jGY2Q70iGskMf41qTLhL9XeNN2KhI0uDgwko= +k8s.io/apiextensions-apiserver v0.26.2/go.mod h1:Y7UPgch8nph8mGCuVk0SK83LnS8Esf3n6fUBgew8SH8= +k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= +k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= +k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o= +k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8= +k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= +k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= +k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= +k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= k8s.io/klog/v2 v2.90.0 h1:VkTxIV/FjRXn1fgNNcKGM8cfmL1Z33ZjXRTVxKCoF5M= k8s.io/klog/v2 v2.90.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= diff --git a/operator/test/component/app/app_suite_test.go b/operator/test/component/app/app_suite_test.go new file mode 100644 index 0000000000..a4f3d11558 --- /dev/null +++ b/operator/test/component/app/app_suite_test.go @@ -0,0 +1,56 @@ +package app_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestApp(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "App Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnapp.KeptnAppReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-app-controller"), + Log: GinkgoLogr, + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.app-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/app/app_test.go b/operator/test/component/app/app_test.go new file mode 100644 index 0000000000..abd596b116 --- /dev/null +++ b/operator/test/component/app/app_test.go @@ -0,0 +1,101 @@ +package app_test + +import ( + "fmt" + + klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apiserver/pkg/storage/names" +) + +var _ = Describe("App", Ordered, func() { + var ( + name string + namespace string + version string + ) + BeforeEach(func() { // list var here they will be copied for every spec + name = names.SimpleNameGenerator.GenerateName("my-app-") + namespace = "default" // namespaces are not deleted in the api so be careful + // when creating you can use ignoreAlreadyExists(err error) + version = "1.0.0" + }) + Describe("Creation of AppVersion from a new App", func() { + var ( + instance *klcv1alpha3.KeptnApp + ) + + BeforeEach(func() { + instance = createInstanceInCluster(name, namespace, version) + fmt.Println("created ", instance.Name) + }) + + Context("with a new App CRD", func() { + + It("should update the spans", func() { + By("creating a new app version") + common.AssertResourceUpdated(ctx, k8sClient, instance) + assertAppSpan(instance, spanRecorder) + fmt.Println("spanned ", instance.Name) + }) + + }) + AfterEach(func() { + // Remember to clean up the cluster after each test + common.DeleteAppInCluster(ctx, k8sClient, instance) + // Reset span recorder after each spec + common.ResetSpanRecords(tracer, spanRecorder) + }) + + }) +}) + +func assertAppSpan(instance *klcv1alpha3.KeptnApp, spanRecorder *sdktest.SpanRecorder) { + By("Comparing spans") + var spans []otelsdk.ReadOnlySpan + Eventually(func() bool { + spans = spanRecorder.Ended() + return len(spans) >= 3 + }, "10s").Should(BeTrue()) + + Expect(spans[0].Name()).To(Equal(fmt.Sprintf("%s-%s-%d", instance.Name, instance.Spec.Version, instance.Generation))) + Expect(spans[0].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) + Expect(spans[0].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) + + Expect(spans[1].Name()).To(Equal("create_app_version")) + Expect(spans[1].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) + Expect(spans[1].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) + + Expect(spans[2].Name()).To(Equal("reconcile_app")) + Expect(spans[2].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) + Expect(spans[2].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) +} + +func createInstanceInCluster(name string, namespace string, version string) *klcv1alpha3.KeptnApp { + instance := &klcv1alpha3.KeptnApp{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + Generation: 1, + }, + Spec: klcv1alpha3.KeptnAppSpec{ + Version: version, + Workloads: []klcv1alpha3.KeptnWorkloadRef{ + { + Name: "app-wname", + Version: "2.0", + }, + }, + }, + } + By("Invoking Reconciling for Create") + + Expect(k8sClient.Create(ctx, instance)).Should(Succeed()) + return instance +} diff --git a/operator/test/component/appcontroller_test.go b/operator/test/component/appcontroller_test.go deleted file mode 100644 index 3f1e1bfd8d..0000000000 --- a/operator/test/component/appcontroller_test.go +++ /dev/null @@ -1,179 +0,0 @@ -package component - -import ( - "fmt" - - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" - apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apiserver/pkg/storage/names" -) - -// clean example of component test (E2E test/ integration test can be achieved adding a real cluster) -// App controller creates AppVersion when a new App CRD is added -// span for creation and reconcile are correct -// container must be ordered to have the before all setup -// this way the container spec check is not randomized, so we can make -// assertions on spans number and traces -var _ = Describe("KeptnAppController", Ordered, func() { - var ( - name string - namespace string - version string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider - ) - - BeforeAll(func() { - //setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptnapp.KeptnAppReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-app-controller"), - Log: GinkgoLogr, - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) // we can register multiple time the same controller - // so that they have a different span/trace - - //for a fake controller you can also use - //controller, err := controller.New("app-controller", cm, controller.Options{ - // Reconciler: reconcile.Func( - // func(_ context.Context, request reconcile.Request) (reconcile.Result, error) { - // reconciled <- request - // return reconcile.Result{}, nil - // }), - //}) - //Expect(err).NotTo(HaveOccurred()) - }) - - BeforeEach(func() { // list var here they will be copied for every spec - name = names.SimpleNameGenerator.GenerateName("my-app-") - namespace = "default" // namespaces are not deleted in the api so be careful - // when creating you can use ignoreAlreadyExists(err error) - version = "1.0.0" - }) - Describe("Creation of AppVersion from a new App", func() { - var ( - instance *klcv1alpha3.KeptnApp - ) - - BeforeEach(func() { - instance = createInstanceInCluster(name, namespace, version) - fmt.Println("created ", instance.Name) - }) - - Context("with a new App CRD", func() { - - It("should update the spans", func() { - By("creating a new app version") - assertResourceUpdated(instance) - assertAppSpan(instance, spanRecorder) - fmt.Println("spanned ", instance.Name) - }) - - }) - AfterEach(func() { - // Remember to clean up the cluster after each test - deleteAppInCluster(instance) - // Reset span recorder after each spec - resetSpanRecords(tracer, spanRecorder) - }) - - }) -}) - -func deleteAppInCluster(instance *klcv1alpha3.KeptnApp) { - By("Cleaning Up KeptnApp CRD ") - err := k8sClient.Delete(ctx, instance) - logErrorIfPresent(err) -} - -func assertResourceUpdated(instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { - - appVersion := getAppVersion(instance) - - By("Comparing expected app version") - Expect(appVersion.Spec.AppName).To(Equal(instance.Name)) - Expect(appVersion.Spec.Version).To(Equal(instance.Spec.Version)) - Expect(appVersion.Spec.Workloads).To(Equal(instance.Spec.Workloads)) - - return appVersion -} - -func getAppVersion(instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { - appvName := types.NamespacedName{ - Namespace: instance.Namespace, - Name: fmt.Sprintf("%s-%s-%d", instance.Name, instance.Spec.Version, instance.Generation), - } - - appVersion := &klcv1alpha3.KeptnAppVersion{} - By("Retrieving Created app version") - Eventually(func() error { - return k8sClient.Get(ctx, appvName, appVersion) - }, "20s").Should(Succeed()) - - return appVersion -} - -func assertAppSpan(instance *klcv1alpha3.KeptnApp, spanRecorder *sdktest.SpanRecorder) { - By("Comparing spans") - var spans []otelsdk.ReadOnlySpan - Eventually(func() bool { - spans = spanRecorder.Ended() - return len(spans) >= 3 - }, "10s").Should(BeTrue()) - - Expect(spans[0].Name()).To(Equal(fmt.Sprintf("%s-%s-%d", instance.Name, instance.Spec.Version, instance.Generation))) - Expect(spans[0].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) - Expect(spans[0].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) - - Expect(spans[1].Name()).To(Equal("create_app_version")) - Expect(spans[1].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) - Expect(spans[1].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) - - Expect(spans[2].Name()).To(Equal("reconcile_app")) - Expect(spans[2].Attributes()).To(ContainElement(apicommon.AppName.String(instance.Name))) - Expect(spans[2].Attributes()).To(ContainElement(apicommon.AppVersion.String(instance.Spec.Version))) -} - -func createInstanceInCluster(name string, namespace string, version string) *klcv1alpha3.KeptnApp { - instance := &klcv1alpha3.KeptnApp{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - Generation: 1, - }, - Spec: klcv1alpha3.KeptnAppSpec{ - Version: version, - Workloads: []klcv1alpha3.KeptnWorkloadRef{ - { - Name: "app-wname", - Version: "2.0", - }, - }, - }, - } - By("Invoking Reconciling for Create") - - Expect(k8sClient.Create(ctx, instance)).Should(Succeed()) - return instance -} diff --git a/operator/test/component/appversion/appversion_suite_test.go b/operator/test/component/appversion/appversion_suite_test.go new file mode 100644 index 0000000000..090b1bb21c --- /dev/null +++ b/operator/test/component/appversion/appversion_suite_test.go @@ -0,0 +1,59 @@ +package appversion_test + +import ( + "context" + "os" + "testing" + + controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnappversion" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestAppversion(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Appversion Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnappversion.KeptnAppVersionReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-appversion-controller"), + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + SpanHandler: &controllercommon.SpanHandler{}, + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.appversion-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/appversioncontroller_test.go b/operator/test/component/appversion/appversion_test.go similarity index 74% rename from operator/test/component/appversioncontroller_test.go rename to operator/test/component/appversion/appversion_test.go index 75b04dd44b..e657882680 100644 --- a/operator/test/component/appversioncontroller_test.go +++ b/operator/test/component/appversion/appversion_test.go @@ -1,4 +1,4 @@ -package component +package appversion_test import ( "context" @@ -7,13 +7,9 @@ import ( klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnappversion" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -21,47 +17,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -// clean example of component test (E2E test/ integration test can be achieved adding a real cluster) -// App controller creates AppVersion when a new App CRD is added -// span for creation and reconcile are correct -// container must be ordered to have the before all setup -// this way the container spec check is not randomized, so we can make -// assertions on spans number and traces -var _ = Describe("KeptnAppVersionController", Ordered, func() { +var _ = Describe("Appversion", Ordered, func() { var ( - appName string - namespace string - version string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider + appName string + namespace string + version string ) - BeforeAll(func() { - //setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptnappversion.KeptnAppVersionReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-appversion-controller"), - Log: GinkgoLogr, - Meters: initKeptnMeters(), - SpanHandler: &controllercommon.SpanHandler{}, - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) // we can register multiple time the same controller - // so that they have a different span/trace - }) - BeforeEach(func() { // list var here they avll be copied for every spec appName = names.SimpleNameGenerator.GenerateName("test-appversion-reconciler-") namespace = "default" // namespaces are not deleted in the api so be careful @@ -206,9 +168,9 @@ var _ = Describe("KeptnAppVersionController", Ordered, func() { AfterEach(func() { // Remember to clean up the cluster after each test err := k8sClient.Delete(ctx, av) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) // Reset span recorder after each spec - resetSpanRecords(tracer, spanRecorder) + common.ResetSpanRecords(tracer, spanRecorder) }) }) diff --git a/operator/test/component/common.go b/operator/test/component/common.go deleted file mode 100644 index 466b151bad..0000000000 --- a/operator/test/component/common.go +++ /dev/null @@ -1,43 +0,0 @@ -package component - -import ( - apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/unit" - "go.opentelemetry.io/otel/sdk/metric" - "go.opentelemetry.io/otel/trace" -) - -func initKeptnMeters() apicommon.KeptnMeters { - provider := metric.NewMeterProvider() - meter := provider.Meter("keptn/task") - deploymentCount, _ := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) - deploymentDuration, _ := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit(unit.Unit("s"))) - taskCount, _ := meter.SyncInt64().Counter("keptn.task.count", instrument.WithDescription("a simple counter for Keptn Tasks")) - taskDuration, _ := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn Tasks"), instrument.WithUnit(unit.Unit("s"))) - appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) - appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit(unit.Unit("s"))) - evaluationCount, _ := meter.SyncInt64().Counter("keptn.evaluation.count", instrument.WithDescription("a simple counter for Keptn Evaluations")) - evaluationDuration, _ := meter.SyncFloat64().Histogram("keptn.evaluation.duration", instrument.WithDescription("a histogram of duration for Keptn Evaluations"), instrument.WithUnit(unit.Unit("s"))) - - meters := apicommon.KeptnMeters{ - TaskCount: taskCount, - TaskDuration: taskDuration, - DeploymentCount: deploymentCount, - DeploymentDuration: deploymentDuration, - AppCount: appCount, - AppDuration: appDuration, - EvaluationCount: evaluationCount, - EvaluationDuration: evaluationDuration, - } - return meters -} - -type tracerFactory struct { - tracer trace.TracerProvider -} - -func (f *tracerFactory) GetTracer(name string) controllercommon.ITracer { - return f.tracer.Tracer(name) -} diff --git a/operator/test/component/common/common.go b/operator/test/component/common/common.go new file mode 100644 index 0000000000..bb4d513cb7 --- /dev/null +++ b/operator/test/component/common/common.go @@ -0,0 +1,224 @@ +package common + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + "time" + + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" + apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" + controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" + . "github.com/onsi/ginkgo/v2" + ginkgotypes "github.com/onsi/ginkgo/v2/types" + . "github.com/onsi/gomega" + "github.com/onsi/gomega/gexec" + "go.opentelemetry.io/otel/metric/instrument" + "go.opentelemetry.io/otel/metric/unit" + "go.opentelemetry.io/otel/sdk/metric" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + "go.opentelemetry.io/otel/trace" + v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" +) + +func InitKeptnMeters() apicommon.KeptnMeters { + provider := metric.NewMeterProvider() + meter := provider.Meter("keptn/task") + deploymentCount, _ := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) + deploymentDuration, _ := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit(unit.Unit("s"))) + taskCount, _ := meter.SyncInt64().Counter("keptn.task.count", instrument.WithDescription("a simple counter for Keptn Tasks")) + taskDuration, _ := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn Tasks"), instrument.WithUnit(unit.Unit("s"))) + appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) + appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit(unit.Unit("s"))) + evaluationCount, _ := meter.SyncInt64().Counter("keptn.evaluation.count", instrument.WithDescription("a simple counter for Keptn Evaluations")) + evaluationDuration, _ := meter.SyncFloat64().Histogram("keptn.evaluation.duration", instrument.WithDescription("a histogram of duration for Keptn Evaluations"), instrument.WithUnit(unit.Unit("s"))) + + meters := apicommon.KeptnMeters{ + TaskCount: taskCount, + TaskDuration: taskDuration, + DeploymentCount: deploymentCount, + DeploymentDuration: deploymentDuration, + AppCount: appCount, + AppDuration: appDuration, + EvaluationCount: evaluationCount, + EvaluationDuration: evaluationDuration, + } + return meters +} + +type TracerFactory struct { + Tracer trace.TracerProvider +} + +func (f *TracerFactory) GetTracer(name string) controllercommon.ITracer { + return f.Tracer.Tracer(name) +} + +func IgnoreAlreadyExists(err error) error { + if apierrors.IsAlreadyExists(err) { + return nil + } + return err +} + +func LogErrorIfPresent(err error) { + if err != nil { + GinkgoLogr.Error(err, "Something went wrong while cleaning up the test environment") + } +} + +func ResetSpanRecords(tp *otelsdk.TracerProvider, spanRecorder *sdktest.SpanRecorder) { + GinkgoLogr.Info("Removing ", fmt.Sprint(len(spanRecorder.Ended())), " spans") + tp.UnregisterSpanProcessor(spanRecorder) + spanRecorder = sdktest.NewSpanRecorder() + tp.RegisterSpanProcessor(spanRecorder) +} + +func MakeKLTDefaultNamespace(k8sClient client.Client, name string) *v1.Namespace { + ns := &v1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + } + + _ = k8sClient.Create(context.TODO(), ns) + + return ns +} + +func DeleteAppInCluster(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) { + By("Cleaning Up KeptnApp CRD ") + err := k8sClient.Delete(ctx, instance) + LogErrorIfPresent(err) +} + +func AssertResourceUpdated(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { + + appVersion := GetAppVersion(ctx, k8sClient, instance) + + By("Comparing expected app version") + Expect(appVersion.Spec.AppName).To(Equal(instance.Name)) + Expect(appVersion.Spec.Version).To(Equal(instance.Spec.Version)) + Expect(appVersion.Spec.Workloads).To(Equal(instance.Spec.Workloads)) + + return appVersion +} + +func GetAppVersion(ctx context.Context, k8sClient client.Client, instance *klcv1alpha3.KeptnApp) *klcv1alpha3.KeptnAppVersion { + appvName := types.NamespacedName{ + Namespace: instance.Namespace, + Name: fmt.Sprintf("%s-%s-%d", instance.Name, instance.Spec.Version, instance.Generation), + } + + appVersion := &klcv1alpha3.KeptnAppVersion{} + By("Retrieving Created app version") + Eventually(func() error { + return k8sClient.Get(ctx, appvName, appVersion) + }, "20s").Should(Succeed()) + + return appVersion +} + +func InitSuite() (context.Context, ctrl.Manager, *otelsdk.TracerProvider, *sdktest.SpanRecorder, client.Client, context.CancelFunc) { + var ( + cfg *rest.Config + k8sClient client.Client + testEnv *envtest.Environment + ctx context.Context + k8sManager ctrl.Manager + spanRecorder *sdktest.SpanRecorder + tracer *otelsdk.TracerProvider + cancel context.CancelFunc + ) + + logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) + ctx, cancel = context.WithCancel(context.TODO()) + By("bootstrapping test environment") + + if os.Getenv("USE_EXISTING_CLUSTER") == "true" { + t := true + testEnv = &envtest.Environment{ + UseExistingCluster: &t, + } + } else { + GinkgoLogr.Info("Setting up fake test env") + testEnv = &envtest.Environment{ + CRDDirectoryPaths: []string{ + filepath.Join("..", "..", "..", "config", "crd", "bases"), + filepath.Join("..", "..", "..", "..", "metrics-operator", "config", "crd", "bases"), + }, + ErrorIfCRDPathMissing: true, + } + } + var err error + // cfg is defined in this file globally. + cfg, err = testEnv.Start() + Expect(err).NotTo(HaveOccurred()) + Expect(cfg).NotTo(BeNil()) + + // +kubebuilder:scaffold:scheme + err = klcv1alpha3.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + err = metricsapi.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) + + k8sManager, err = ctrl.NewManager(cfg, ctrl.Options{ + Scheme: scheme.Scheme, + }) + Expect(err).ToNot(HaveOccurred()) + + go func() { + defer GinkgoRecover() + err = k8sManager.Start(ctx) + Expect(err).ToNot(HaveOccurred(), "failed to run manager") + gexec.KillAndWait(4 * time.Second) + + // Teardown the test environment once controller is finished. + // Otherwise, from Kubernetes 1.21+, teardown timeouts waiting on + // kube-apiserver to return + err := testEnv.Stop() + Expect(err).ToNot(HaveOccurred()) + }() + + By("Creating the Controller") + + spanRecorder = sdktest.NewSpanRecorder() + tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) + + return ctx, k8sManager, tracer, spanRecorder, k8sClient, cancel +} + +func WriteReport(specReport ginkgotypes.SpecReport, f *os.File) { + path := strings.Split(specReport.FileName(), "/") + testFile := path[len(path)-1] + if specReport.ContainerHierarchyTexts != nil { + testFile = specReport.ContainerHierarchyTexts[0] + } + fmt.Fprintf(f, "%s %s ", testFile, specReport.LeafNodeText) + switch specReport.State { + case ginkgotypes.SpecStatePassed: + fmt.Fprintf(f, "%s\n", "✓") + case ginkgotypes.SpecStateFailed: + fmt.Fprintf(f, "%s\n", "✕") + default: + fmt.Fprintf(f, "%s\n", specReport.State) + } +} diff --git a/operator/test/component/evaluation/evaluation_suite_test.go b/operator/test/component/evaluation/evaluation_suite_test.go new file mode 100644 index 0000000000..3002574c2c --- /dev/null +++ b/operator/test/component/evaluation/evaluation_suite_test.go @@ -0,0 +1,64 @@ +package evaluation_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnevaluation" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + v1 "k8s.io/api/core/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestEvaluation(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Evaluation Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder + ns *v1.Namespace +) + +const KLTnamespace = "keptnlifecycle" + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnevaluation.KeptnEvaluationReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-evaluation-controller"), + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + TracerFactory: &common.TracerFactory{Tracer: tracer}, + Namespace: KLTnamespace, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + + ns = common.MakeKLTDefaultNamespace(k8sClient, KLTnamespace) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.evaluation-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/evaluationcontroller_test.go b/operator/test/component/evaluation/evaluation_test.go similarity index 81% rename from operator/test/component/evaluationcontroller_test.go rename to operator/test/component/evaluation/evaluation_test.go index 31b3146b70..a83c77f6b8 100644 --- a/operator/test/component/evaluationcontroller_test.go +++ b/operator/test/component/evaluation/evaluation_test.go @@ -1,65 +1,30 @@ -package component +package evaluation_test import ( "context" - "os" "time" metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnevaluation" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apiserver/pkg/storage/names" ) -const KLTnamespace = "keptnlifecycle" - -var _ = Describe("KeptnEvaluationController", Ordered, func() { +var _ = Describe("Evaluation", Ordered, func() { var ( evaluationName string evaluationDefinitionName string metricName string namespaceName string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider ns *v1.Namespace ) - BeforeAll(func() { - // setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - _ = os.Setenv("FUNCTION_RUNNER_IMAGE", "my-image") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptnevaluation.KeptnEvaluationReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-evaluation-controller"), - Log: GinkgoLogr, - Meters: initKeptnMeters(), - TracerFactory: &tracerFactory{tracer: tracer}, - Namespace: KLTnamespace, - }} - setupManager(controllers) // we can register multiple time the same controller - ns = makeKLTDefaultNamespace(KLTnamespace) - }) - BeforeEach(func() { // list var here they will be copied for every spec evaluationName = names.SimpleNameGenerator.GenerateName("test-evaluation-") evaluationDefinitionName = names.SimpleNameGenerator.GenerateName("my-evaldefinition-") @@ -139,7 +104,7 @@ var _ = Describe("KeptnEvaluationController", Ordered, func() { }, "30s").Should(Succeed()) err = k8sClient.Delete(context.TODO(), metric) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) It("KeptnEvaluationController Metric status does not exist", func() { @@ -175,7 +140,7 @@ var _ = Describe("KeptnEvaluationController", Ordered, func() { }, "30s").Should(Succeed()) err := k8sClient.Delete(context.TODO(), metric) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) It("KeptnEvaluationController Metric does not exist", func() { By("Create EvaluationDefiniton") @@ -207,13 +172,13 @@ var _ = Describe("KeptnEvaluationController", Ordered, func() { }) AfterEach(func() { err := k8sClient.Delete(context.TODO(), evaluationDefinition) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) err = k8sClient.Delete(context.TODO(), evaluation) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) AfterAll(func() { err := k8sClient.Delete(context.TODO(), ns) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) }) }) @@ -285,16 +250,3 @@ func makeEvaluation(name string, namespaceName string, evaluationDefinition stri return eval } - -func makeKLTDefaultNamespace(name string) *v1.Namespace { - ns := &v1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - }, - } - - err := k8sClient.Create(context.TODO(), ns) - Expect(err).To(BeNil()) - - return ns -} diff --git a/operator/test/component/load/load_suite_test.go b/operator/test/component/load/load_suite_test.go new file mode 100644 index 0000000000..5db48ac95c --- /dev/null +++ b/operator/test/component/load/load_suite_test.go @@ -0,0 +1,56 @@ +package load_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestLoad(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Load Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnapp.KeptnAppReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("load-app-controller"), + Log: GinkgoLogr, + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.load-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/load_test.go b/operator/test/component/load/load_test.go similarity index 57% rename from operator/test/component/load_test.go rename to operator/test/component/load/load_test.go index b0c8013923..0e0eaf9861 100644 --- a/operator/test/component/load_test.go +++ b/operator/test/component/load/load_test.go @@ -1,4 +1,4 @@ -package component +package load_test import ( "fmt" @@ -8,12 +8,9 @@ import ( "time" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnapp" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -24,37 +21,14 @@ type Metric struct { const LOAD = 100 -var _ = Describe("[Feature:Performance] Load KeptnAppController", Ordered, func() { +var _ = Describe("Load", Ordered, func() { var ( - apps []*klcv1alpha3.KeptnApp //Shelf is declared here - appVersions []*klcv1alpha3.KeptnAppVersion - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider - metrics Metric + apps []*klcv1alpha3.KeptnApp //Shelf is declared here + appVersions []*klcv1alpha3.KeptnAppVersion + metrics Metric ) - BeforeAll(func() { - //setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - controllers := []interfaces.Controller{&keptnapp.KeptnAppReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("load-app-controller"), - Log: GinkgoLogr, - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) - }) BeforeEach(func() { - // createTimes := make(map[string]metav1.Time, 0) - for i := 0; i < LOAD; i++ { instance := &klcv1alpha3.KeptnApp{ ObjectMeta: metav1.ObjectMeta{ @@ -83,8 +57,8 @@ var _ = Describe("[Feature:Performance] Load KeptnAppController", Ordered, func( AfterEach(func() { for _, app := range apps { // Remember to clean up the cluster after each test - deleteAppInCluster(app) - resetSpanRecords(tracer, spanRecorder) + common.DeleteAppInCluster(ctx, k8sClient, app) + common.ResetSpanRecords(tracer, spanRecorder) } }) JustAfterEach(func() { // this is an example of how to add logs to report @@ -95,7 +69,7 @@ var _ = Describe("[Feature:Performance] Load KeptnAppController", Ordered, func( It("should create the app version CR", func() { for _, app := range apps { - appVersions = append(appVersions, assertResourceUpdated(app)) + appVersions = append(appVersions, common.AssertResourceUpdated(ctx, k8sClient, app)) metrics.succeededAppVersionCount++ } }) diff --git a/operator/test/component/suite_test.go b/operator/test/component/suite_test.go deleted file mode 100644 index c013e9c827..0000000000 --- a/operator/test/component/suite_test.go +++ /dev/null @@ -1,188 +0,0 @@ -/* -Copyright 2022. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package component - -import ( - "context" - "fmt" - "os" - "path/filepath" - "strings" - "testing" - "time" - - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" - klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - . "github.com/onsi/ginkgo/v2" - "github.com/onsi/ginkgo/v2/types" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gexec" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - // nolint:gci - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/v2 to learn more about Ginkgo. -var ( - cfg *rest.Config - k8sClient client.Client - testEnv *envtest.Environment - ctx context.Context - cancel context.CancelFunc - k8sManager ctrl.Manager -) - -func TestOperatorComponents(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - ctx, cancel = context.WithCancel(context.TODO()) - By("bootstrapping test environment") - - if os.Getenv("USE_EXISTING_CLUSTER") == "true" { - t := true - testEnv = &envtest.Environment{ - UseExistingCluster: &t, - } - } else { - GinkgoLogr.Info("Setting up fake test env") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{ - filepath.Join("..", "..", "config", "crd", "bases"), - filepath.Join("..", "..", "..", "metrics-operator", "config", "crd", "bases"), - }, - ErrorIfCRDPathMissing: true, - } - } - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - // +kubebuilder:scaffold:scheme - err = klcv1alpha3.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - err = metricsapi.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - /* - One thing that this autogenerated file is missing, however, is a way to actually start your controller. - The code above will set up a client for interacting with your custom Kind, - but will not be able to test your controller behavior. - If you want to test your custom controller logic, you’ll need to add some familiar-looking manager logic - to your BeforeSuite() function, so you can register your custom controller to run on this test cluster. - You may notice that the code below runs your controller with nearly identical logic to your CronJob project’s main.go! - The only difference is that the manager is started in a separate goroutine so it does not block the cleanup of envtest - when you’re done running your tests. - Note that we set up both a "live" k8s client and a separate client from the manager. This is because when making - assertions in tests, you generally want to assert against the live state of the API server. If you use the client - from the manager (`k8sManager.GetClient`), you'd end up asserting against the contents of the cache instead, which is - slower and can introduce flakiness into your tests. We could use the manager's `APIReader` to accomplish the same - thing, but that would leave us with two clients in our test assertions and setup (one for reading, one for writing), - and it'd be easy to make mistakes. - Note that we keep the reconciler running against the manager's cache client, though -- we want our controller to - behave as it would in production, and we use features of the cache (like indicies) in our controller which aren't - available when talking directly to the API server. - */ - - k8sManager, err = ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - }) - Expect(err).ToNot(HaveOccurred()) - - go func() { - defer GinkgoRecover() - err = k8sManager.Start(ctx) - Expect(err).ToNot(HaveOccurred(), "failed to run manager") - gexec.KillAndWait(4 * time.Second) - - // Teardown the test environment once controller is finished. - // Otherwise, from Kubernetes 1.21+, teardown timeouts waiting on - // kube-apiserver to return - err := testEnv.Stop() - Expect(err).ToNot(HaveOccurred()) - }() - -}) - -func ignoreAlreadyExists(err error) error { - if apierrors.IsAlreadyExists(err) { - return nil - } - return err -} - -func setupManager(rec []interfaces.Controller) { - for _, r := range rec { - err := r.SetupWithManager(k8sManager) - Expect(err).To(BeNil()) - } -} - -func logErrorIfPresent(err error) { - if err != nil { - GinkgoLogr.Error(err, "Something went wrong while cleaning up the test environment") - } -} - -func resetSpanRecords(tp *otelsdk.TracerProvider, spanRecorder *sdktest.SpanRecorder) { - GinkgoLogr.Info("Removing ", fmt.Sprint(len(spanRecorder.Ended())), " spans") - tp.UnregisterSpanProcessor(spanRecorder) - spanRecorder = sdktest.NewSpanRecorder() - tp.RegisterSpanProcessor(spanRecorder) -} - -var _ = ReportAfterSuite("custom report", func(report Report) { - f, err := os.Create("report.component-operator") - Expect(err).ToNot(HaveOccurred(), "failed to generate report") - for _, specReport := range report.SpecReports { - path := strings.Split(specReport.FileName(), "/") - testFile := path[len(path)-1] - if specReport.ContainerHierarchyTexts != nil { - testFile = specReport.ContainerHierarchyTexts[0] - } - fmt.Fprintf(f, "%s %s ", testFile, specReport.LeafNodeText) - switch specReport.State { - case types.SpecStatePassed: - fmt.Fprintf(f, "%s\n", "✓") - case types.SpecStateFailed: - fmt.Fprintf(f, "%s\n", "✕") - default: - fmt.Fprintf(f, "%s\n", specReport.State) - } - } - f.Close() -}) diff --git a/operator/test/component/task/task_suite_test.go b/operator/test/component/task/task_suite_test.go new file mode 100644 index 0000000000..197565deee --- /dev/null +++ b/operator/test/component/task/task_suite_test.go @@ -0,0 +1,59 @@ +package task_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntask" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestTask(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Task Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + _ = os.Setenv("FUNCTION_RUNNER_IMAGE", "my-image") + + ////setup controllers here + controller := &keptntask.KeptnTaskReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-task-controller"), + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.task-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/taskcontroller_test.go b/operator/test/component/task/task_test.go similarity index 73% rename from operator/test/component/taskcontroller_test.go rename to operator/test/component/task/task_test.go index 5ea968fc9a..f4cfc2a49e 100644 --- a/operator/test/component/taskcontroller_test.go +++ b/operator/test/component/task/task_test.go @@ -1,17 +1,13 @@ -package component +package task_test import ( "context" - "os" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntask" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -19,40 +15,13 @@ import ( "k8s.io/apiserver/pkg/storage/names" ) -var _ = Describe("KeptnTaskController", Ordered, func() { +var _ = Describe("Task", Ordered, func() { var ( name string taskDefinitionName string namespace string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider ) - BeforeAll(func() { - // setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - _ = os.Setenv("FUNCTION_RUNNER_IMAGE", "my-image") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptntask.KeptnTaskReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-task-controller"), - Log: GinkgoLogr, - Meters: initKeptnMeters(), - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) // we can register multiple time the same controller - }) - BeforeEach(func() { // list var here they will be copied for every spec name = names.SimpleNameGenerator.GenerateName("test-task-reconciler-") taskDefinitionName = names.SimpleNameGenerator.GenerateName("my-taskdef-") @@ -108,9 +77,9 @@ var _ = Describe("KeptnTaskController", Ordered, func() { }) AfterEach(func() { err := k8sClient.Delete(context.TODO(), taskDefinition) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) err = k8sClient.Delete(context.TODO(), task) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) }) }) @@ -147,8 +116,8 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.Keptn "code": "console.log('hello');", }, } - err := k8sClient.Create(context.TODO(), cm) + err := k8sClient.Create(context.TODO(), cm) Expect(err).To(BeNil()) taskDefinition := &klcv1alpha3.KeptnTaskDefinition{ @@ -168,5 +137,17 @@ func makeTaskDefinition(taskDefinitionName, namespace string) *klcv1alpha3.Keptn err = k8sClient.Create(context.TODO(), taskDefinition) Expect(err).To(BeNil()) + err = k8sClient.Get(context.TODO(), types.NamespacedName{ + Namespace: namespace, + Name: taskDefinitionName, + }, taskDefinition) + + Expect(err).To(BeNil()) + + taskDefinition.Status.Function.ConfigMap = cmName + + err = k8sClient.Status().Update(ctx, taskDefinition) + Expect(err).To(BeNil()) + return taskDefinition } diff --git a/operator/test/component/taskdefinition/taskdefinition_suite_test.go b/operator/test/component/taskdefinition/taskdefinition_suite_test.go new file mode 100644 index 0000000000..888008d423 --- /dev/null +++ b/operator/test/component/taskdefinition/taskdefinition_suite_test.go @@ -0,0 +1,55 @@ +package taskdefinition_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntaskdefinition" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestTaskdefinition(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Taskdefinition Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptntaskdefinition.KeptnTaskDefinitionReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-taskdefinition-controller"), + Log: GinkgoLogr, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.taskdefinition-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/taskdefinitioncontroller_test.go b/operator/test/component/taskdefinition/taskdefinition_test.go similarity index 85% rename from operator/test/component/taskdefinitioncontroller_test.go rename to operator/test/component/taskdefinition/taskdefinition_test.go index 3566367336..adc55b5f84 100644 --- a/operator/test/component/taskdefinitioncontroller_test.go +++ b/operator/test/component/taskdefinition/taskdefinition_test.go @@ -1,11 +1,10 @@ -package component +package taskdefinition_test import ( "context" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptntaskdefinition" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" @@ -14,31 +13,12 @@ import ( "k8s.io/apiserver/pkg/storage/names" ) -var _ = Describe("KeptnTaskDefinitionController", Ordered, func() { +var _ = Describe("Taskdefinition", Ordered, func() { var ( taskDefinitionName string namespace string ) - BeforeAll(func() { - // setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - - ////setup controllers here - controllers := []interfaces.Controller{&keptntaskdefinition.KeptnTaskDefinitionReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-taskdefinition-controller"), - Log: GinkgoLogr, - }} - setupManager(controllers) // we can register multiple time the same controller - }) - BeforeEach(func() { // list var here they will be copied for every spec taskDefinitionName = names.SimpleNameGenerator.GenerateName("my-taskdefinition-") namespace = "default" // namespaces are not deleted in the api so be careful @@ -99,7 +79,7 @@ var _ = Describe("KeptnTaskDefinitionController", Ordered, func() { }, "30s").Should(Succeed()) err = k8sClient.Delete(context.TODO(), configmap) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) It("TaskDefinition referencing existing Configmap", func() { @@ -150,7 +130,7 @@ var _ = Describe("KeptnTaskDefinitionController", Ordered, func() { }, "30s").Should(Succeed()) err = k8sClient.Delete(context.TODO(), configmap) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) It("TaskDefinition referencing non-existing Configmap", func() { @@ -200,7 +180,7 @@ var _ = Describe("KeptnTaskDefinitionController", Ordered, func() { AfterEach(func() { err := k8sClient.Delete(context.TODO(), taskDefinition) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) }) diff --git a/operator/test/component/workload/workload_suite_test.go b/operator/test/component/workload/workload_suite_test.go new file mode 100644 index 0000000000..58cf475f67 --- /dev/null +++ b/operator/test/component/workload/workload_suite_test.go @@ -0,0 +1,56 @@ +package workload_test + +import ( + "context" + "os" + "testing" + + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkload" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestWorkload(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Workload Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnworkload.KeptnWorkloadReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-workload-controller"), + Log: GinkgoLogr, + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.workload-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/workloadcontroller_test.go b/operator/test/component/workload/workload_test.go similarity index 67% rename from operator/test/component/workloadcontroller_test.go rename to operator/test/component/workload/workload_test.go index b957e2b110..7447dbe779 100644 --- a/operator/test/component/workloadcontroller_test.go +++ b/operator/test/component/workload/workload_test.go @@ -1,4 +1,4 @@ -package component +package workload_test import ( "context" @@ -6,57 +6,23 @@ import ( klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkload" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apiserver/pkg/storage/names" ) -// clean example of component test (E2E test/ integration test can be achieved adding a real cluster) -// Workload controller creates WorkloadVersion when a new Workload CRD is added -// span for creation and reconcile are correct -// container must be ordered to have the before all setup -// this way the container spec check is not randomized, so we can make -// assertions on spans number and traces -var _ = Describe("KeptnWorkloadController", Ordered, func() { +var _ = Describe("Workload", Ordered, func() { var ( name string namespace string version string applicationName string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider ) - BeforeAll(func() { - //setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptnworkload.KeptnWorkloadReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-workload-controller"), - Log: GinkgoLogr, - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) // we can register multiple time the same controller - // so that they have a different span/trace - }) - BeforeEach(func() { // list var here they will be copied for every spec name = names.SimpleNameGenerator.GenerateName("my-workload-") applicationName = names.SimpleNameGenerator.GenerateName("my-app-") @@ -105,17 +71,17 @@ var _ = Describe("KeptnWorkloadController", Ordered, func() { Expect(spans[1].Name()).To(Equal("create_workload_instance")) Expect(spans[1].Attributes()).To(ContainElement(apicommon.WorkloadName.String(workload.Name))) Expect(spans[1].Attributes()).To(ContainElement(apicommon.WorkloadVersion.String(workload.Spec.Version))) - Expect(spans[0].Attributes()).To(ContainElement(apicommon.AppName.String(workload.Spec.AppName))) + Expect(spans[1].Attributes()).To(ContainElement(apicommon.AppName.String(workload.Spec.AppName))) }) }) AfterEach(func() { By("Cleaning Up KeptnWorkload CRD") err := k8sClient.Delete(ctx, workload) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) By("Cleaning Up KeptnWorkloadInstance CRD") err = k8sClient.Delete(ctx, workloadInstance) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) }) }) diff --git a/operator/test/component/workloadinstance/workloadinstance_suite_test.go b/operator/test/component/workloadinstance/workloadinstance_suite_test.go new file mode 100644 index 0000000000..9a25400d11 --- /dev/null +++ b/operator/test/component/workloadinstance/workloadinstance_suite_test.go @@ -0,0 +1,59 @@ +package workloadinstance_test + +import ( + "context" + "os" + "testing" + + controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkloadinstance" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + otelsdk "go.opentelemetry.io/otel/sdk/trace" + sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + // nolint:gci + // +kubebuilder:scaffold:imports +) + +func TestWorkloadinstance(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Workloadinstance Suite") +} + +var ( + k8sManager ctrl.Manager + tracer *otelsdk.TracerProvider + k8sClient client.Client + ctx context.Context + spanRecorder *sdktest.SpanRecorder +) + +var _ = BeforeSuite(func() { + ctx, k8sManager, tracer, spanRecorder, k8sClient, _ = common.InitSuite() + + ////setup controllers here + controller := &keptnworkloadinstance.KeptnWorkloadInstanceReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Recorder: k8sManager.GetEventRecorderFor("test-workloadinstance-controller"), + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + SpanHandler: &controllercommon.SpanHandler{}, + TracerFactory: &common.TracerFactory{Tracer: tracer}, + } + err := controller.SetupWithManager(k8sManager) + Expect(err).To(BeNil()) + +}) + +var _ = ReportAfterSuite("custom report", func(report Report) { + f, err := os.Create("report.workloadinstance-operator") + Expect(err).ToNot(HaveOccurred(), "failed to generate report") + for _, specReport := range report.SpecReports { + common.WriteReport(specReport, f) + } + f.Close() +}) diff --git a/operator/test/component/workloadinstancecontroller_test.go b/operator/test/component/workloadinstance/workloadinstance_test.go similarity index 84% rename from operator/test/component/workloadinstancecontroller_test.go rename to operator/test/component/workloadinstance/workloadinstance_test.go index b474a631d0..29ab3491fe 100644 --- a/operator/test/component/workloadinstancecontroller_test.go +++ b/operator/test/component/workloadinstance/workloadinstance_test.go @@ -1,4 +1,4 @@ -package component +package workloadinstance_test import ( "context" @@ -7,13 +7,9 @@ import ( klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/keptnworkloadinstance" + "github.com/keptn/lifecycle-toolkit/operator/test/component/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - otelsdk "go.opentelemetry.io/otel/sdk/trace" - sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -22,75 +18,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func getPodTemplateSpec() corev1.PodTemplateSpec { - return corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - "app": "nginx", - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "nginx", - Image: "nginx", - }, - }, - }, - } -} - -// clean example of component test (E2E test/ integration test can be achieved adding a real cluster) -// App controller creates AppVersion when a new App CRD is added -// span for creation and reconcile are correct -// container must be ordered to have the before all setup -// this way the container spec check is not randomized, so we can make -// assertions on spans number and traces -var _ = Describe("KeptnWorkloadInstanceController", Ordered, func() { +var _ = Describe("Workloadinstance", Ordered, func() { var ( - appName string - namespace string - version string - spanRecorder *sdktest.SpanRecorder - tracer *otelsdk.TracerProvider + appName string + namespace string + version string ) - BeforeAll(func() { - //setup once - By("Waiting for Manager") - Eventually(func() bool { - return k8sManager != nil - }).Should(Equal(true)) - - By("Creating the Controller") - - spanRecorder = sdktest.NewSpanRecorder() - tracer = otelsdk.NewTracerProvider(otelsdk.WithSpanProcessor(spanRecorder)) - - ////setup controllers here - controllers := []interfaces.Controller{&keptnworkloadinstance.KeptnWorkloadInstanceReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("test-workloadinstance-controller"), - Log: GinkgoLogr, - Meters: initKeptnMeters(), - SpanHandler: &controllercommon.SpanHandler{}, - TracerFactory: &tracerFactory{tracer: tracer}, - }} - setupManager(controllers) // we can register multiple time the same controller - // so that they have a different span/trace - - //for a fake controller you can also use - //controller, err := controller.New("app-controller", cm, controller.Options{ - // Reconciler: reconcile.Func( - // func(_ context.Context, request reconcile.Request) (reconcile.Result, error) { - // reconciled <- request - // return reconcile.Result{}, nil - // }), - //}) - //Expect(err).NotTo(HaveOccurred()) - }) - BeforeEach(func() { // list var here they will be copied for every spec namespace = "default" // namespaces are not deleted in the api so be careful // when creating you can use ignoreAlreadyExists(err error) @@ -442,11 +376,11 @@ var _ = Describe("KeptnWorkloadInstanceController", Ordered, func() { AfterEach(func() { // Remember to clean up the cluster after each test err := k8sClient.Delete(ctx, appVersion) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) err = k8sClient.Delete(ctx, wi) - logErrorIfPresent(err) + common.LogErrorIfPresent(err) // Reset span recorder after each spec - resetSpanRecords(tracer, spanRecorder) + common.ResetSpanRecords(tracer, spanRecorder) }) }) @@ -476,7 +410,7 @@ func createAppVersionInCluster(name string, namespace string, version string) *k } By("Invoking Reconciling for Create") - Expect(ignoreAlreadyExists(k8sClient.Create(ctx, instance))).Should(Succeed()) + Expect(common.IgnoreAlreadyExists(k8sClient.Create(ctx, instance))).Should(Succeed()) av := &klcv1alpha3.KeptnAppVersion{} err := k8sClient.Get(ctx, types.NamespacedName{ @@ -489,3 +423,21 @@ func createAppVersionInCluster(name string, namespace string, version string) *k _ = k8sClient.Status().Update(ctx, av) return av } + +func getPodTemplateSpec() corev1.PodTemplateSpec { + return corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app": "nginx", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "nginx", + Image: "nginx", + }, + }, + }, + } +} diff --git a/release-please-config.json b/release-please-config.json index 586ac8e3aa..ccc9e4705f 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -11,8 +11,12 @@ "extra-files": [ "README.md", "operator/config/manager/manager.yaml", - "examples/argo/Makefile", - "examples/observability/Makefile" + "examples/support/argo/Makefile", + "examples/support/observability/Makefile", + "helm/chart/Chart.yaml", + ".github/workflows/validate-helm-docs.yml", + "Makefile", + "docs/content/en/docs/snippets/tasks/install.md" ], "changelog-sections": [ { diff --git a/renovate.json b/renovate.json index e156a9680f..25af678023 100644 --- a/renovate.json +++ b/renovate.json @@ -23,15 +23,23 @@ "**/tests/**" ], "ignoreDeps": [ - "ghcr.keptn.sh/keptn/keptn-lifecycle-operator", + "ghcr.keptn.sh/keptn/lifecycle-operator", "ghcr.keptn.sh/keptn/scheduler", "ghcr.keptn.sh/keptn/functions-runtime", - "docker.io/thschue/keptn-lifecycle-operator", - "docker.io/thschue/scheduler", - "docker.io/annadreal/keptn-lifecycle-operator", - "docker.io/annadreal/kube-scheduler" + "ghcr.keptn.sh/keptn/certificate-operator", + "ghcr.keptn.sh/keptn/metrics-operator" ], "packageRules": [ + { + "excludePackagePatterns": [ + "docker.io\\/thschue\\/.*", + "docker.io\\/annadreal\\/.*", + "docker.io\\/bacherfl\\/.*", + "docker.io\\/mowies\\/.*", + "docker.io\\/odubajdt\\/.*", + "docker.io\\/thisthatdc\\/.*" + ] + }, { "matchManagers": ["gomod"], "addLabels": ["go"] @@ -62,5 +70,22 @@ "# renovate: datasource=(?.+?) depName=(?.+?)\\s.*?_VERSION ?(\\??=|\\: ?) ?\\\"?(?.+?)?\\\"?\\s" ] } - ] + ], + "kubernetes": { + "fileMatch": [ + "examples\\/.*\\.ya?ml$", + "test\\/.*\\.ya?ml$" + ], + "packageRules": [ + { + "excludePackagePatterns": [ + ".*podtato\\-head.*" + ] + } + ], + "ignorePaths": [ + "examples/support/observability/config/prometheus/**/*", + "test/prometheus/**/*" + ] + } } diff --git a/scheduler/go.mod b/scheduler/go.mod index 14533a91fe..4565226845 100644 --- a/scheduler/go.mod +++ b/scheduler/go.mod @@ -14,12 +14,12 @@ require ( go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/trace v0.20.0 google.golang.org/grpc v1.52.3 - k8s.io/api v0.25.6 - k8s.io/apimachinery v0.25.6 - k8s.io/apiserver v0.25.6 - k8s.io/client-go v0.25.6 - k8s.io/component-base v0.25.6 - k8s.io/klog/v2 v2.90.0 + k8s.io/api v0.25.7 + k8s.io/apimachinery v0.25.7 + k8s.io/apiserver v0.25.7 + k8s.io/client-go v0.25.7 + k8s.io/component-base v0.25.7 + k8s.io/klog/v2 v2.90.1 k8s.io/kubernetes v1.25.6 sigs.k8s.io/controller-runtime v0.13.1 ) @@ -105,7 +105,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.25.0 // indirect k8s.io/cloud-provider v0.25.4 // indirect - k8s.io/component-helpers v0.25.6 // indirect + k8s.io/component-helpers v0.25.7 // indirect k8s.io/csi-translation-lib v0.25.4 // indirect k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect k8s.io/kube-scheduler v0.0.0 // indirect @@ -119,30 +119,30 @@ require ( replace ( github.com/keptn/lifecycle-toolkit/scheduler/pkg/klcpermit => /pkg/klcpermit - k8s.io/api => k8s.io/api v0.25.6 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.25.6 - k8s.io/apimachinery => k8s.io/apimachinery v0.25.6 - k8s.io/apiserver => k8s.io/apiserver v0.25.6 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.6 - k8s.io/client-go => k8s.io/client-go v0.25.6 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.25.6 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.25.6 - k8s.io/code-generator => k8s.io/code-generator v0.25.6 - k8s.io/component-base => k8s.io/component-base v0.25.6 + k8s.io/api => k8s.io/api v0.25.7 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.25.7 + k8s.io/apimachinery => k8s.io/apimachinery v0.25.7 + k8s.io/apiserver => k8s.io/apiserver v0.25.7 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.7 + k8s.io/client-go => k8s.io/client-go v0.25.7 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.25.7 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.25.7 + k8s.io/code-generator => k8s.io/code-generator v0.25.7 + k8s.io/component-base => k8s.io/component-base v0.25.7 k8s.io/component-helpers => k8s.io/component-helpers v0.25.6 - k8s.io/controller-manager => k8s.io/controller-manager v0.25.6 - k8s.io/cri-api => k8s.io/cri-api v0.25.6 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.25.6 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.25.6 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.25.6 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.25.6 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.25.6 - k8s.io/kubectl => k8s.io/kubectl v0.25.6 - k8s.io/kubelet => k8s.io/kubelet v0.25.6 + k8s.io/controller-manager => k8s.io/controller-manager v0.25.7 + k8s.io/cri-api => k8s.io/cri-api v0.25.7 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.25.7 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.25.7 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.25.7 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.25.7 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.25.7 + k8s.io/kubectl => k8s.io/kubectl v0.25.7 + k8s.io/kubelet => k8s.io/kubelet v0.25.7 k8s.io/kubernetes => k8s.io/kubernetes v1.25.6 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.25.6 - k8s.io/metrics => k8s.io/metrics v0.25.6 - k8s.io/mount-utils => k8s.io/mount-utils v0.25.6 - k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.25.6 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.25.6 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.25.7 + k8s.io/metrics => k8s.io/metrics v0.25.7 + k8s.io/mount-utils => k8s.io/mount-utils v0.25.7 + k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.25.7 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.25.7 ) diff --git a/scheduler/go.sum b/scheduler/go.sum index 8fa7c14e51..9cf69d3530 100644 --- a/scheduler/go.sum +++ b/scheduler/go.sum @@ -265,8 +265,6 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.8.1 h1:xFTEVwOFa1D/Ty24Ws1npBWkDYEV9BqZrsDxVrVkrrU= github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= -github.com/onsi/gomega v1.27.0 h1:QLidEla4bXUuZVFa4KX6JHCsuGgbi85LC/pCHrt/O08= -github.com/onsi/gomega v1.27.0/go.mod h1:i189pavgK95OSIipFBa74gC2V4qrQuvjuyGEr3GmbXA= github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -464,8 +462,6 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -728,35 +724,37 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.25.6 h1:LwDY2H6kD/3R8TekJYYaJWOdekNdXDO44eVpX6sNtJA= -k8s.io/api v0.25.6/go.mod h1:bVp01KUcl8VUHFBTJMOknWNo7XvR0cMbeTTuFg1zCUs= -k8s.io/apiextensions-apiserver v0.25.6 h1:MwdaCpHtGVSM5SiA6Hm4g2w5voMNiPCwBjOqz9YTlrg= -k8s.io/apiextensions-apiserver v0.25.6/go.mod h1:aXw8Xmhf6/gfGx3y0xkj8o8evTZbfOFqZeWIigg4XsE= -k8s.io/apimachinery v0.25.6 h1:r6KIF2AHwLqFfZ0LcOA3I11SF62YZK83dxj1fn14NOQ= -k8s.io/apimachinery v0.25.6/go.mod h1:1S2i1QHkmxc8+EZCIxe/fX5hpldVXk4gvnJInMEb8D4= -k8s.io/apiserver v0.25.6 h1:32mn8HAlsEl1tpuiVmhAl0YCVkOugjybsJ6l6kf0c8k= -k8s.io/apiserver v0.25.6/go.mod h1:IEp2B2/FvQ8GmdspscUoUS0iFF/GGc6NVrJ/cTM4OaA= -k8s.io/client-go v0.25.6 h1:CHxACHi0DijmlYyUR7ooZoXnD5P8jYLgBHcxp775x/U= -k8s.io/client-go v0.25.6/go.mod h1:s9mMAGFYiH3Z66j7BESzu0GEradT9GQ2LjFf/YRrnyc= -k8s.io/cloud-provider v0.25.6 h1:xxJg78XIeotzLRaXlk8HgZ+OsOWy5uBmDCkErGtgkl0= -k8s.io/cloud-provider v0.25.6/go.mod h1:CHXlDObyf8hE7sKxSuzbHi5lA/zHjkgEdT46r+wwvLU= -k8s.io/component-base v0.25.6 h1:v3ci6FbXFcxpjyQJaaLq0MgzT3vyFzwUDWtO+KRv9Bk= -k8s.io/component-base v0.25.6/go.mod h1:k7DfcfJ8cOI6A2xTCfU5LxsnXV+lWw1ME8cRCHzIh6o= +k8s.io/api v0.25.7 h1:r+J8U7CPhPNNTvyow1yw6IzdLt6nBCvPQEW8Cdglep8= +k8s.io/api v0.25.7/go.mod h1:9epkK0wROSVQJKaKW3eY/thGtfbILsLqweTq99qKynk= +k8s.io/apiextensions-apiserver v0.25.7 h1:JcQRpJuUb+fq9yuLVOJvnPb2exTOpndihw6cm5SYSdY= +k8s.io/apiextensions-apiserver v0.25.7/go.mod h1:OospDXJZREut4pOtZhvz4tvKMWxJHbcf8HFtlafN7gc= +k8s.io/apimachinery v0.25.7 h1:kDtoW8uvDkwKc9Lq2sablqWTMZUloRjJVZWURFrdAiI= +k8s.io/apimachinery v0.25.7/go.mod h1:ZTl0drTQaFi5gMM3snYI5tWV1XJmRH1gfnDx2QCLsxk= +k8s.io/apiserver v0.25.7 h1:V5bq3uDAYj9qy6JbBqbjw2YHfooF89h8JBGkcW6wAWw= +k8s.io/apiserver v0.25.7/go.mod h1:utJWlDvIY5pP+fC4yjWQjWjbz+jWj5odwgtVAf7uuCg= +k8s.io/client-go v0.25.7 h1:yERmM57CweHC13+wRek/LjScnL5kw6EnVvjoGwS6F7Y= +k8s.io/client-go v0.25.7/go.mod h1:+msAWrAey/u++r/ij0HISJs3QA+RrqXsIa/LqBAT23o= +k8s.io/cloud-provider v0.25.7 h1:82CA8Ne/FPbHR79f+bPTzCPj04uhmvwRzQRXI8sC18g= +k8s.io/cloud-provider v0.25.7/go.mod h1:Hl/mIwQlEJI3bXTsv6CJ2cpmBZE+txL6tQbLnCAGbdk= +k8s.io/component-base v0.25.7 h1:xGWvweUXGK5TA+92Qr51hzYw1cM/QpZNMz1vhtcM6NQ= +k8s.io/component-base v0.25.7/go.mod h1:yoYUxxtHH0ysjUwqQ3xpvoD9t1+ENbX5EYgsW+lif+Y= k8s.io/component-helpers v0.25.6 h1:OHTT22as3x7DUeMD4SrsuLTjSU0ywfVALiz2pDOXaWo= k8s.io/component-helpers v0.25.6/go.mod h1:TbxdooEyf6EgMtx/5WayyChEXY6uTgZs59T1FwLL/Nw= -k8s.io/csi-translation-lib v0.25.6 h1:MnMgkTkhYfkyq4r9Bcem3TCjxZdlbSoyphZygJqoToE= -k8s.io/csi-translation-lib v0.25.6/go.mod h1:bZrHetdvxNkS65y8VhivbiYxELnpIjVLpmcD94hi404= +k8s.io/csi-translation-lib v0.25.7 h1:qswah8EqrwTvVy4P5RqSy6aeAexUYW/xkPOHiiPz5VQ= +k8s.io/csi-translation-lib v0.25.7/go.mod h1:j99rZ1fMgvFe6YbNYJVTnbUo0iwalsEgAMAnX9lOVMo= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.90.0 h1:VkTxIV/FjRXn1fgNNcKGM8cfmL1Z33ZjXRTVxKCoF5M= k8s.io/klog/v2 v2.90.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= +k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 h1:MQ8BAZPZlWk3S9K4a9NCkIFQtZShWqoha7snGixVgEA= k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= -k8s.io/kube-scheduler v0.25.6 h1:Wbxc1u8I6CWhi48vINZl1AJ9R7LEKX5PAqJomlknd7I= -k8s.io/kube-scheduler v0.25.6/go.mod h1:F9lTr2v2oipN7lB+BCxa34oLSFwXwr6FmxGRV0g+y7E= +k8s.io/kube-scheduler v0.25.7 h1:liQG5w8MJ4qyY01J8JmWhLaZ/aFyFi9Q7ATVsKrqpqw= +k8s.io/kube-scheduler v0.25.7/go.mod h1:aBLYbMfTFlx6Cs+Ho6Thp0b/S84FeW+4vhdMWUGJB/Q= k8s.io/kubernetes v1.25.6 h1:3zBcz3I4CXKnzR/K37Kzjtmu4O+/5XV/tUCa7gSiJG4= k8s.io/kubernetes v1.25.6/go.mod h1:iB7lKyWeYg8+Oi5EPDEfdMtmae8BvjzziSpek2CcBe4= -k8s.io/mount-utils v0.25.6 h1:7fK5wzp7F93PZiz7RdnvEavRVuoe89yJ+zspy4hrzGc= -k8s.io/mount-utils v0.25.6/go.mod h1:Eqb/IPZnzLiL6/Fv6hwxq6HAr+HPCxMutQrItylgO68= +k8s.io/mount-utils v0.25.7 h1:+PA6rm7YmMwu8Gj8OJLlVjg6dPWRKXdIW47bg0dMl8c= +k8s.io/mount-utils v0.25.7/go.mod h1:vojU37mpuNwtcRmJiVso5mgFvdo5wI8No6RLp2O1yhg= k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4= k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/test/integration/expose-keptn-metric/00-install.yaml b/test/integration/expose-keptn-metric/00-install.yaml index 9c181a52fe..16c9bb7513 100644 --- a/test/integration/expose-keptn-metric/00-install.yaml +++ b/test/integration/expose-keptn-metric/00-install.yaml @@ -8,7 +8,7 @@ spec: spec: containers: - name: test-prometheus - image: curlimages/curl:7.72.0 + image: curlimages/curl:7.88.1 args: - /bin/sh - -ec @@ -19,7 +19,7 @@ spec: exit 1 fi - name: test-api-endpoint - image: curlimages/curl:7.72.0 + image: curlimages/curl:7.88.1 args: - /bin/sh - -ec diff --git a/test/integration/expose-keptn-metric/01-install.yaml b/test/integration/expose-keptn-metric/01-install.yaml index 63c4ae0d17..023353283f 100644 --- a/test/integration/expose-keptn-metric/01-install.yaml +++ b/test/integration/expose-keptn-metric/01-install.yaml @@ -19,7 +19,7 @@ spec: spec: containers: - name: test-prometheus - image: curlimages/curl:7.72.0 + image: curlimages/curl:7.88.1 args: - /bin/sh - -ec @@ -31,7 +31,7 @@ spec: fi exit 1 - name: test-api-endpoint - image: curlimages/curl:7.72.0 + image: curlimages/curl:7.88.1 args: - /bin/sh - -ec diff --git a/test/integration/podtato-head-application/00-install.yaml b/test/integration/podtato-head-application/00-install.yaml index d03e8328fb..bdc37e81f5 100644 --- a/test/integration/podtato-head-application/00-install.yaml +++ b/test/integration/podtato-head-application/00-install.yaml @@ -52,11 +52,11 @@ spec: terminationGracePeriodSeconds: 5 initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] containers: - name: server - image: ghcr.io/podtato-head/entry:latest + image: ghcr.io/podtato-head/entry:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -105,7 +105,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/hat:latest + image: ghcr.io/podtato-head/hat:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -152,7 +152,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-leg:latest + image: ghcr.io/podtato-head/left-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -199,7 +199,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-arm:latest + image: ghcr.io/podtato-head/left-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -246,7 +246,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-leg:latest + image: ghcr.io/podtato-head/right-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -293,7 +293,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-arm:latest + image: ghcr.io/podtato-head/right-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 diff --git a/test/integration/restartable-app/00-install.yaml b/test/integration/restartable-app/00-install.yaml index 68413d39c5..79a664b24c 100644 --- a/test/integration/restartable-app/00-install.yaml +++ b/test/integration/restartable-app/00-install.yaml @@ -45,11 +45,11 @@ spec: terminationGracePeriodSeconds: 5 initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] containers: - name: server - image: ghcr.io/podtato-head/entry:latest + image: ghcr.io/podtato-head/entry:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -98,7 +98,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/hat:latest + image: ghcr.io/podtato-head/hat:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -145,7 +145,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-leg:latest + image: ghcr.io/podtato-head/left-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -192,7 +192,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/left-arm:latest + image: ghcr.io/podtato-head/left-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -239,7 +239,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-leg:latest + image: ghcr.io/podtato-head/right-leg:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -286,7 +286,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/right-arm:latest + image: ghcr.io/podtato-head/right-arm:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 diff --git a/test/integration/simple-deployment-annotated/00-install.yaml b/test/integration/simple-deployment-annotated/00-install.yaml index 95f2095c62..5fcb18768a 100644 --- a/test/integration/simple-deployment-annotated/00-install.yaml +++ b/test/integration/simple-deployment-annotated/00-install.yaml @@ -41,6 +41,6 @@ spec: command: ['sh', '-c', 'echo The app is running! && sleep infinity'] initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] diff --git a/test/integration/simple-deployment-evaluation/00-install.yaml b/test/integration/simple-deployment-evaluation/00-install.yaml index d578dbd495..63404499e4 100644 --- a/test/integration/simple-deployment-evaluation/00-install.yaml +++ b/test/integration/simple-deployment-evaluation/00-install.yaml @@ -57,6 +57,6 @@ spec: command: ['sh', '-c', 'echo The app is running! && sleep infinity'] initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 10'] diff --git a/test/integration/simple-deployment/00-install.yaml b/test/integration/simple-deployment/00-install.yaml index a467b1281f..48c868751a 100644 --- a/test/integration/simple-deployment/00-install.yaml +++ b/test/integration/simple-deployment/00-install.yaml @@ -41,6 +41,6 @@ spec: command: ['sh', '-c', 'echo The app is running! && sleep infinity'] initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] diff --git a/test/integration/simple-statefulset-annotated/00-install.yaml b/test/integration/simple-statefulset-annotated/00-install.yaml index c2c6a6eeb0..8b3086a3c6 100644 --- a/test/integration/simple-statefulset-annotated/00-install.yaml +++ b/test/integration/simple-statefulset-annotated/00-install.yaml @@ -40,6 +40,6 @@ spec: command: ['sh', '-c', 'echo The app is running! && sleep infinity'] initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] diff --git a/test/integration/simple-statefulset-annotated/02-install.yaml b/test/integration/simple-statefulset-annotated/02-install.yaml index 3586279095..4fefc098c7 100644 --- a/test/integration/simple-statefulset-annotated/02-install.yaml +++ b/test/integration/simple-statefulset-annotated/02-install.yaml @@ -28,6 +28,6 @@ spec: command: ['sh', '-c', 'echo The app is running! && sleep infinity'] initContainers: - name: init-myservice - image: busybox:1.32.1 + image: busybox:1.36.0 command: ['sh', '-c', 'sleep 30'] diff --git a/test/integration/workload-instance-failing-pre-task/00-install.yaml b/test/integration/workload-instance-failing-pre-task/00-install.yaml index f235a5575b..10aa39adf8 100644 --- a/test/integration/workload-instance-failing-pre-task/00-install.yaml +++ b/test/integration/workload-instance-failing-pre-task/00-install.yaml @@ -45,7 +45,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/entry:latest + image: ghcr.io/podtato-head/entry:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -69,4 +69,4 @@ spec: targetPort: 9000 type: LoadBalancer # change to NodePort if no LoadBalancer controller is available - # type: NodePort \ No newline at end of file + # type: NodePort diff --git a/test/integration/workload-instance-missing-evaluation/00-install.yaml b/test/integration/workload-instance-missing-evaluation/00-install.yaml index 27382245ce..35fe411dce 100644 --- a/test/integration/workload-instance-missing-evaluation/00-install.yaml +++ b/test/integration/workload-instance-missing-evaluation/00-install.yaml @@ -33,7 +33,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: ghcr.io/podtato-head/entry:latest + image: ghcr.io/podtato-head/entry:0.2.7 imagePullPolicy: Always ports: - containerPort: 9000 @@ -57,4 +57,4 @@ spec: targetPort: 9000 type: LoadBalancer # change to NodePort if no LoadBalancer controller is available - # type: NodePort \ No newline at end of file + # type: NodePort