diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d490c34 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Test and build + +on: + push: + branches: + - master + + pull_request: + branches: + - master + + +permissions: write-all + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.19' + + - uses: actions/checkout@v3.5.2 + + - name: Test With Coverage + run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3.1.4 + with: + files: coverage.txt + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.4.0 + with: + args: --timeout=5m + # since go test already does it in a previous step + skip-pkg-cache: true + + build-image: + runs-on: ubuntu-latest + needs: test + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build image + uses: docker/build-push-action@v5 + with: + # Only for CI testing purposes + push: false + tags: wfs/k8s-image-availability-exporter:latest \ No newline at end of file diff --git a/.github/workflows/chart.yml b/.github/workflows/chart.yml deleted file mode 100644 index 29831d2..0000000 --- a/.github/workflows/chart.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: chart - -env: - CHARTMUSEUM_URL: "https://charts.flant.com/api/common/github/charts" - CHART_DIR: "helm/charts/k8s-image-availability-exporter" - -on: - push: - tags: - - v* - branches: - - master - pull_request: - branches: - - master - -defaults: - run: - shell: "bash -l -eo pipefail {0}" - -jobs: - tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3.5.2 - - uses: werf/actions/install@v1.2 - - name: Werf lint chart - run: cd "$CHART_DIR" && werf helm lint - - name: Werf render chart - run: cd "$CHART_DIR" && werf helm template . - publish-charts: - runs-on: ubuntu-latest - if: "github.event_name == 'push' && github.ref == 'refs/heads/master'" - needs: tests - steps: - - uses: actions/checkout@v3.5.2 - - uses: werf/actions/install@v1.2 - - name: Package werf charts - run: | - mkdir -p .packages - werf helm package "$CHART_DIR" -d .packages - - name: Publish packaged werf charts - run: | - while read package; do - curl -sSL --post301 --data-binary "@.packages/$package" --user "${{ secrets.CHARTMUSEUM_BASIC_AUTH_USER }}:${{ secrets.CHARTMUSEUM_BASIC_AUTH_PASS }}" "$CHARTMUSEUM_URL" - done < <(find .packages -mindepth 1 -maxdepth 1 -type f -name '*.tgz' -exec sh -c 'basename "$0"' '{}' \;) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 7247cea..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CI -on: - push: - tags: - - v* - branches: - - master - pull_request: - branches: - - master -env: - REGISTRY: registry-write.deckhouse.io - IMAGE_NAME: k8s-image-availability-exporter/k8s-image-availability-exporter -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v4 - with: - go-version: '1.19' - - - uses: actions/checkout@v3.5.2 - - - name: Test With Coverage - run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.1.4 - with: - files: coverage.txt - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3.4.0 - with: - args: --timeout=5m - # since go test already does it in a previous step - skip-pkg-cache: true - build: - runs-on: ubuntu-latest - needs: test - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3.5.2 - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v2.1.0 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.DECKHOUSE_REGISTRY_USER }} - password: ${{ secrets.DECKHOUSE_REGISTRY_PASSWORD }} - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v4.4.0 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - uses: docker/build-push-action@v4.0.0 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/push-image.yaml b/.github/workflows/push-image.yaml new file mode 100644 index 0000000..85c788a --- /dev/null +++ b/.github/workflows/push-image.yaml @@ -0,0 +1,28 @@ +name: Build and push image + +on: + + # publish on releases, e.g. v2.1.13 (image tagged as "2.1.13" - "v" prefix is removed) + release: + types: [ published ] + + # publish on pushes to the main branch (image tagged as "latest") + push: + branches: + - master + +permissions: write-all + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build and publish a Docker image for ${{ github.repository }} + uses: macbre/push-to-ghcr@master + with: + context: "." + dockerfile: ./Dockerfile + image_name: ${{ github.repository }} + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release_helmchart.yaml b/.github/workflows/release_helmchart.yaml new file mode 100644 index 0000000..6fe6894 --- /dev/null +++ b/.github/workflows/release_helmchart.yaml @@ -0,0 +1,29 @@ +name: Release Charts + +on: + push: + branches: + - master + +jobs: + release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.5.0 + with: + charts_dir: helm/charts + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/README.md b/README.md index e122e39..e635ad9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # k8s-image-availability-exporter +This is a fork aiming at fixing or at least circumventing the problems described in [Issue #7 of the upstream repository](https://github.com/deckhouse/k8s-image-availability-exporter/issues/7). + +As the upstream repo uses private build infrastructure, the CI process has been adapted and the master branch of this repo should not be merged into the upstream repo for this reason. + +To add a feature in this repository: Create a new branch in from the upstream repo as described [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository). +Then, merge your feature branch in both this repositories and the upstream `master` branches. + +--- k8s-image-availability-exporter (or *k8s-iae* for short) is a Prometheus exporter that warns you proactively about images that are defined in Kubernetes objects (e.g., an `image` field in the Deployment) but are not available in the container registry (such as Docker Registry, etc.). Receiving alerts when container images related to running Kubernetes controllers are missing helps you to solve the problem before it manifests itself. For more details on the reasons behind k8s-iae and how it works, please read [this article](https://medium.com/flant-com/prometheus-exporter-to-check-kubernetes-images-availability-26c306c44c08). diff --git a/helm/charts/k8s-image-availability-exporter/README.md b/helm/charts/k8s-image-availability-exporter/README.md index a537ed6..f0b7ad1 100644 --- a/helm/charts/k8s-image-availability-exporter/README.md +++ b/helm/charts/k8s-image-availability-exporter/README.md @@ -13,9 +13,9 @@ This chart bootstraps a [k8s-image-availability-exporter](https://github.com/fla To install the chart with the release name `my-release`: ```bash -helm repo add flant_common_github https://charts.flant.com/common/github +helm repo add webfleet-k8s-iae https://Webfleet-Solutions.github.io/k8s-image-availability-exporter helm repo update -helm install my-release flant_common_github/k8s-image-availability-exporter +helm install my-release webfleet-k8s-iae/k8s-image-availability-exporter ``` The command deploys k8s-image-availability-exporter on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. @@ -40,8 +40,8 @@ The following tables list the configurable parameters of the k8s-image-availabil | Parameter | Description | Default | | ----- | ----------- | ------ | | `k8sImageAvailabilityExporter.image.pullPolicy` | Image pull policy to use for the k8s-image-availability-exporter deployment | `IfNotPresent` | -| `k8sImageAvailabilityExporter.image.repository` | Repository to use for the k8s-image-availability-exporter deployment | `flant/k8s-image-availability-exporter` | -| `k8sImageAvailabilityExporter.image.tag` | Tag to use for the k8s-image-availability-exporter deployment | `v0.1.13` | +| `k8sImageAvailabilityExporter.image.repository` | Repository to use for the k8s-image-availability-exporter deployment | `ghcr.io/Webfleet-Solutions/k8s-image-availability-exporter` | +| `k8sImageAvailabilityExporter.image.tag` | Tag to use for the k8s-image-availability-exporter deployment | `latest` | | `k8sImageAvailabilityExporter.replicas` | Number of instances to deploy for a k8s-image-availability-exporter deployment. | `1` | | `k8sImageAvailabilityExporter.resources` | Resource limits for k8s-image-availability-exporter | `{}` | | `serviceMonitor.enabled` | Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) serviceMonitor resource | `false` | diff --git a/helm/charts/k8s-image-availability-exporter/values.yaml b/helm/charts/k8s-image-availability-exporter/values.yaml index 4be5f94..9f00b76 100644 --- a/helm/charts/k8s-image-availability-exporter/values.yaml +++ b/helm/charts/k8s-image-availability-exporter/values.yaml @@ -1,7 +1,7 @@ k8sImageAvailabilityExporter: image: - repository: registry.deckhouse.io/k8s-image-availability-exporter/k8s-image-availability-exporter - tag: v0.5.1 + repository: ghcr.io/Webfleet-Solutions/k8s-image-availability-exporter + tag: latest pullPolicy: IfNotPresent replicas: 1 resources: {}