Skip to content

Commit

Permalink
feat: kube-hetzner own cluster autoscaler image
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvest89 committed Oct 27, 2023
1 parent 4d8e654 commit e2a7a10
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 60 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions .github/workflows/cluster-autoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Cluster Autoscaler

on:
pull_request:

jobs:
build:
uses: ./.github/workflows/multi-arch-build.yaml
with:
image: ghcr.io/kube-hetzner/autoscaler/cluster-autoscaler
context: cluster-autoscaler
digestName: 'cluster-autoscaler'
108 changes: 108 additions & 0 deletions .github/workflows/multi-arch-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
on:
workflow_call:
inputs:
image:
required: true
type: string
context:
required: true
type: string
dockerfile:
required: false
type: string
default: ${{ inputs.context }}
digestName:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
tags: |
type=raw,value=latest,enable=true
type=raw,value={{date 'YYYYMMDD'}},enable=true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
build-args: ${{ inputs.buildArgs }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ inputs.image }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.digestName }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
name: Merge and publish
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: ${{ inputs.digestName }}
path: /tmp/digests
- uses: geekyeggo/delete-artifact@v2
with:
name: ${{ inputs.digestName }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
tags: |
type=raw,value=latest,enable=true
type=raw,value={{date 'YYYYMMDD'}},enable=true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ inputs.image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ inputs.image }}:${{ steps.meta.outputs.version }}
12 changes: 12 additions & 0 deletions cluster-autoscaler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.21 as build

WORKDIR /app

COPY . .
RUN go build -v -o /usr/local/bin/app

FROM golang:1.21

COPY --from=build /usr/local/bin/app /usr/local/bin/app

CMD ["app"]
20 changes: 0 additions & 20 deletions cluster-autoscaler/Dockerfile.amd64

This file was deleted.

20 changes: 0 additions & 20 deletions cluster-autoscaler/Dockerfile.arm64

This file was deleted.

20 changes: 0 additions & 20 deletions cluster-autoscaler/Dockerfile.s390x

This file was deleted.

0 comments on commit e2a7a10

Please sign in to comment.