From 573b0ce3120eaa466da692ab8664f7ef7ef5a73b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Jan 2024 12:46:56 +0100 Subject: [PATCH 1/3] Add Containerfile --- Containerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 00000000..194ef1dc --- /dev/null +++ b/Containerfile @@ -0,0 +1,14 @@ +FROM golang AS build + +WORKDIR /build +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -o /icinga-kubernetes cmd/icinga-kubernetes/main.go + +FROM scratch + +COPY --from=build /icinga-kubernetes /icinga-kubernetes + +CMD ["/icinga-kubernetes"] From 65fe7ee825ff832cc594fa4ae147a6abc12ddc3e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Jan 2024 12:47:15 +0100 Subject: [PATCH 2/3] GitHub: Add workflow for Docker image --- .github/workflows/docker-image.yml | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..0550dbdc --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,41 @@ +name: Docker Image + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + icinga/icinga-kubernetes + tags: | + type=edge + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PERSONAL_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: Containerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 5df3e8ada503fa02ce4affcd6b2b7c03b9c89c8c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Jan 2024 13:37:07 +0100 Subject: [PATCH 3/3] Add docs how to run the container --- doc/02-Installation.md.d/From-Source.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/02-Installation.md.d/From-Source.md b/doc/02-Installation.md.d/From-Source.md index fde5f208..797151c3 100644 --- a/doc/02-Installation.md.d/From-Source.md +++ b/doc/02-Installation.md.d/From-Source.md @@ -36,3 +36,14 @@ With locally accessible kubeconfig and `config.yml` files, `icinga-kubernetes` c ```bash icinga-kubernetes -config /path/to/config.yml [-kubeconfig $HOME/.kube/config] ``` + +## Using a Container + +With locally accessible kubeconfig and `config.yml` files, +run the `icinga/icinga-kubernetes` image using a container runtime of you choice, e.g. Docker: + +```bash +export KUBECONFIG=$HOME/.kube/config +export ICINGA_KUBERNETES_CONFIG=config.yml +docker run --rm --network=host -v $ICINGA_KUBERNETES_CONFIG:/config.yml -v $KUBECONFIG:/.kube/config icinga/icinga-kubernetes +```