Skip to content

Commit

Permalink
added multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
kolikons committed Oct 6, 2024
1 parent 8d4d3fb commit 8acb274
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 59 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ jobs:
runs-on: ${{ matrix.os }}
name: Build & Test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/setup-go@v2
with:
go-version: 1.17

- run: go mod download
- run: go mod download

- name: Build & Test
run: |
go build -v .
go test ./...
- name: Build & Test
run: |
go build -v .
go test ./...
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: release --snapshot --skip-publish --skip-sign --rm-dist
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: release --snapshot --skip-publish --skip-sign --rm-dist
4 changes: 2 additions & 2 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: helm release
on:
push:
push:
tags:
- "chart-*"

jobs:
helm-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@master
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/helm-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: helm tests
on:
pull_request:
paths:
- 'charts/**'
- '.github/workflows/helm-tests.yaml'
- "charts/**"
- ".github/workflows/helm-tests.yaml"

jobs:
helm-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.17

Expand All @@ -40,18 +40,25 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
if: success() && startsWith(github.ref, 'refs/tags/')
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
60 changes: 42 additions & 18 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,55 @@ builds:
- arm64
ignore:
- goos: darwin
goarch: '386'
goarch: "386"
- goos: linux
goarch: arm64
dockers:
- image_templates:
- "kolikons/{{.ProjectName}}:{{ .Version }}"
- "kolikons/{{.ProjectName}}:latest"
dockerfile: Dockerfile
goos: linux
goarch: amd64
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.source=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- "--label=org.opencontainers.image.created={{.Date}}"
- --label=org.opencontainers.image.licenses=MIT
- image_templates:
- "kolikons/{{.ProjectName}}:{{ .Version }}-amd64"
use: buildx
dockerfile: Dockerfile
goarch: amd64
build_flag_templates:
- "--platform=linux/amd64"
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.source=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- "--label=org.opencontainers.image.created={{.Date}}"
- --label=org.opencontainers.image.licenses=MIT
- image_templates:
- "kolikons/{{.ProjectName}}:{{ .Version }}-arm64"
use: buildx
dockerfile: Dockerfile
goarch: arm64
build_flag_templates:
- "--platform=linux/arm64"
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.source=https://github.com/kolikons/label-watch
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- "--label=org.opencontainers.image.created={{.Date}}"
- --label=org.opencontainers.image.licenses=MIT
docker_manifests:
- name_template: "kolikons/{{.ProjectName}}:{{ .Version }}"
image_templates:
- "kolikons/{{.ProjectName}}:{{ .Version }}-amd64"
- "kolikons/{{.ProjectName}}:{{ .Version }}-arm64"
- name_template: "kolikons/{{.ProjectName}}:latest"
image_templates:
- "kolikons/{{.ProjectName}}:{{ .Version }}-amd64"
- "kolikons/{{.ProjectName}}:{{ .Version }}-arm64"
changelog:
sort: asc
filters:
exclude:
- '^doc:'
- 'typo'
- "^doc:"
- "typo"
signs:
- artifacts: checksum
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ When Kubernetes cluster's created, worker nodes is tagged as none.
---

## Usage of label-watch

label-watch supports two mode of running. The first one is outside kubernetes cluster and inside

#### Example label-watch outside kuberntes cluster:

1. You must have `kube config` that uses for connecting `kubectl`
2. Run command with the following flags:

```sh
$ kubectl get node
AME STATUS ROLES AGE VERSION
Expand Down Expand Up @@ -46,8 +49,10 @@ kind-worker2 Ready <none> 2m36s v1.20.2
```

#### Example label-watch inside kubernetes cluster:

1. Modify ARGs in [scripts/deployment.yml](scripts/deployment.yml#22)
2. Deploy the kubernetes manifest from [scripts/deployment.yml](scripts/deployment.yml)

```sh
$ kubectl get node
NAME STATUS ROLES AGE VERSION
Expand All @@ -67,12 +72,15 @@ kind-worker2 Ready <none> 13m v1.20.2
```

# Helm

Add kolikons repository to Helm repos:

```bash
helm repo add kolikons https://kolikons.github.io/charts/
```

Install label-watch

```bash
helm install label-watch kolikons/label-watch \
--namespace kube-system
Expand All @@ -85,16 +93,19 @@ helm install label-watch kolikons/label-watch \
```sh
docker run kolikons/label-watch:latest
```

---

# Homebrew

```sh
brew install kolikons/tap/label-watch
```

---

## label-watch ARGS

```sh
label-watch --help
Usage of label-watch:
Expand Down
4 changes: 2 additions & 2 deletions charts/label-watch/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ maintainers:
url: https://github.com/kolikons/label-watch
sources:
- https://github.com/kolikons/label-watch
version: 0.0.2
appVersion: "0.0.2"
version: 1.0.0
appVersion: "0.1.0"
5 changes: 2 additions & 3 deletions charts/label-watch/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ spec:
{{- end }}
labels:
{{- include "app.selectorLabels" . | nindent 8 }}
{{- range $key, $value := $.Values.podLabels }}
{{- range $key, $value := $.Values.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -43,7 +43,6 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:

{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
Expand Down
28 changes: 14 additions & 14 deletions scripts/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ spec:
serviceAccountName: label-watch
restartPolicy: Always
containers:
- name: label-watch
args:
- -interval
- 30m
- -label
- node-type
image: kolikons/label-watch:0.0.1
imagePullPolicy: Always
- name: label-watch
args:
- -interval
- 30m
- -label
- node-type
image: kolikons/label-watch:0.1.0
imagePullPolicy: Always
---
apiVersion: v1
kind: ServiceAccount
Expand All @@ -40,18 +40,18 @@ kind: ClusterRole
metadata:
name: label-watch
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: [ "list", "patch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: label-watch
subjects:
- kind: ServiceAccount
name: label-watch
namespace: default
- kind: ServiceAccount
name: label-watch
namespace: default
roleRef:
kind: ClusterRole
name: label-watch
Expand Down

0 comments on commit 8acb274

Please sign in to comment.