mirror of
https://github.com/outbackdingo/talos-cloud-controller-manager.git
synced 2026-01-27 10:20:27 +00:00
feat: gitops automatization
GH-Actions: * build and lint * helm chart tests * push release images Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
.github/
|
||||
.git/
|
||||
**/.gitignore
|
||||
charts/
|
||||
|
||||
34
.github/workflows/build-test.yaml
vendored
Normal file
34
.github/workflows/build-test.yaml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Build check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 'cmd/**'
|
||||
- 'pkg/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
cache: true
|
||||
|
||||
- name: Build
|
||||
run: make build
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
args: --config=.golangci.yml
|
||||
29
.github/workflows/charts.yaml
vendored
Normal file
29
.github/workflows/charts.yaml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Helm chart check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'charts/**'
|
||||
|
||||
jobs:
|
||||
helm-lint:
|
||||
name: Helm chart check
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
|
||||
- name: Install chart-testing tools
|
||||
id: lint
|
||||
uses: helm/chart-testing-action@v2.3.1
|
||||
|
||||
- name: Run helm chart linter
|
||||
run: ct --config hack/ct.yml lint
|
||||
- name: Run helm template
|
||||
run: |
|
||||
helm template -n kube-system -f charts/talos-cloud-controller-manager/values-tests.yaml \
|
||||
ccm charts/talos-cloud-controller-manager > /dev/null
|
||||
4
.github/workflows/conform.yaml
vendored
4
.github/workflows/conform.yaml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
jobs:
|
||||
conform:
|
||||
name: Conformance
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -18,5 +18,5 @@ jobs:
|
||||
- name: Checkout main branch
|
||||
run: git fetch --no-tags origin main:main
|
||||
|
||||
- name: Conform Action
|
||||
- name: Conform action
|
||||
uses: talos-systems/conform@v0.1.0-alpha.27
|
||||
|
||||
33
.github/workflows/release.yaml
vendored
Normal file
33
.github/workflows/release.yaml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-publish:
|
||||
name: "Build image and publish"
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
|
||||
- name: Set up docker buildx
|
||||
run: make docker-init
|
||||
- name: Github registry login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
run: make images
|
||||
env:
|
||||
PUSH: "true"
|
||||
16
Dockerfile
16
Dockerfile
@@ -1,18 +1,24 @@
|
||||
# syntax = docker/dockerfile:1.4
|
||||
########################################
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} golang:1.19-alpine AS builder
|
||||
RUN apk update && apk add --no-cache make
|
||||
ENV GO111MODULE on
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.mod go.sum /src
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
RUN make build-all-archs
|
||||
|
||||
####
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} scratch AS release
|
||||
ARG ARCH
|
||||
COPY --from=builder /src/talos-cloud-controller-manager-${ARCH} /talos-cloud-controller-manager
|
||||
########################################
|
||||
|
||||
FROM --platform=${TARGETARCH} scratch AS release
|
||||
LABEL org.opencontainers.image.source https://github.com/siderolabs/talos-cloud-controller-manager
|
||||
LABEL org.opencontainers.image.licenses MIT
|
||||
|
||||
ARG TARGETARCH
|
||||
COPY --from=builder /src/talos-cloud-controller-manager-${TARGETARCH} /talos-cloud-controller-manager
|
||||
|
||||
ENTRYPOINT ["/talos-cloud-controller-manager"]
|
||||
|
||||
44
Makefile
44
Makefile
@@ -1,10 +1,12 @@
|
||||
REGISTRY ?= ghcr.io
|
||||
USERNAME ?= sergelogvinov
|
||||
USERNAME ?= siderolabs
|
||||
PROJECT ?= talos-cloud-controller-manager
|
||||
IMAGE ?= $(REGISTRY)/$(USERNAME)/$(PROJECT)
|
||||
PLATFORM ?= linux/arm64,linux/amd64
|
||||
PUSH ?= false
|
||||
|
||||
SHA ?= $(shell git describe --match=none --always --abbrev=8 --dirty)
|
||||
TAG ?= $(shell git describe --tag --always --dirty --match v[0-9]\*)
|
||||
TAG ?= $(shell git describe --tag --always --match v[0-9]\*)
|
||||
|
||||
OS ?= $(shell go env GOOS)
|
||||
ARCH ?= $(shell go env GOARCH)
|
||||
@@ -12,6 +14,11 @@ ARCHS = amd64 arm64
|
||||
|
||||
TESTARGS ?= "-v"
|
||||
|
||||
BUILD_ARGS := --platform=$(PLATFORM)
|
||||
ifeq ($(PUSH),true)
|
||||
BUILD_ARGS += --push=$(PUSH)
|
||||
endif
|
||||
|
||||
######
|
||||
|
||||
# Help Menu
|
||||
@@ -24,6 +31,7 @@ To build this project, you must have the following installed:
|
||||
- git
|
||||
- make
|
||||
- golang 1.19
|
||||
- golangci-lint
|
||||
|
||||
endef
|
||||
|
||||
@@ -39,7 +47,7 @@ build-all-archs:
|
||||
@for arch in $(ARCHS); do $(MAKE) ARCH=$${arch} build ; done
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
build: ## Build
|
||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build \
|
||||
-o talos-cloud-controller-manager-$(ARCH) ./cmd/talos-cloud-controller-manager
|
||||
|
||||
@@ -49,7 +57,7 @@ run: build
|
||||
--use-service-account-credentials --leader-elect=false --bind-address=127.0.0.1
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
lint: ## Lint
|
||||
golangci-lint run --config .golangci.yml
|
||||
|
||||
.PHONY: unit
|
||||
@@ -57,22 +65,26 @@ unit:
|
||||
go test -tags=unit $(shell go list ./...) $(TESTARGS)
|
||||
|
||||
.PHONY: conformance
|
||||
conformance:
|
||||
conformance: ## Conformance
|
||||
docker run --rm -it -v $(PWD):/src -w /src ghcr.io/siderolabs/conform:v0.1.0-alpha.27 enforce
|
||||
|
||||
.PHONY: docs
|
||||
docs:
|
||||
helm template -n kube-system talos-cloud-controller-manager -f charts/talos-cloud-controller-manager/values-example.yaml \
|
||||
helm template -n kube-system talos-cloud-controller-manager \
|
||||
--set-string image.tag=$(TAG) \
|
||||
charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager.yml
|
||||
|
||||
images-push: $(foreach arch,$(ARCHS),image-push-$(arch)) image-manifest
|
||||
image-push-%:
|
||||
@docker build --build-arg=ARCH=$* --build-arg=IMAGE=$(IMAGE) -t $(IMAGE):$(SHA)-$* \
|
||||
--target=release -f Dockerfile .
|
||||
@docker push $(IMAGE):$(SHA)-$*
|
||||
git-chglog --config hack/chglog-config.yml -o CHANGELOG.md
|
||||
|
||||
image-manifest: $(foreach arch,$(ARCHS),image-manifest-$(arch))
|
||||
@docker manifest push --purge $(IMAGE):$(SHA)
|
||||
image-manifest-%:
|
||||
@docker manifest create $(IMAGE):$(SHA) --amend $(IMAGE):$(SHA)-$*
|
||||
@docker manifest annotate --os linux --arch $* $(IMAGE):$(SHA) $(IMAGE):$(SHA)-$*
|
||||
docker-init:
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
||||
docker context create multiarch ||:
|
||||
docker buildx create --name multiarch --driver docker-container --use ||:
|
||||
docker context use multiarch
|
||||
docker buildx inspect --bootstrap multiarch
|
||||
|
||||
images:
|
||||
@docker buildx build $(BUILD_ARGS) \
|
||||
-t $(IMAGE):$(TAG) \
|
||||
-f Dockerfile .
|
||||
|
||||
19
charts/talos-cloud-controller-manager/values-tests.yaml
Normal file
19
charts/talos-cloud-controller-manager/values-tests.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
# Define some variables.
|
||||
|
||||
extraArgs:
|
||||
- --cluster-name=kubernetes
|
||||
|
||||
podAnnotations:
|
||||
project: test
|
||||
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: kubernetes.io/role
|
||||
operator: In
|
||||
values:
|
||||
- control-plane
|
||||
|
||||
logVerbosityLevel: 4
|
||||
22
hack/CHANGELOG.tpl.md
Executable file
22
hack/CHANGELOG.tpl.md
Executable file
@@ -0,0 +1,22 @@
|
||||
{{ range .Versions }}
|
||||
<a name="{{ .Tag.Name }}"></a>
|
||||
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
|
||||
|
||||
Welcome to the {{ .Tag.Name }} release of Talos CCM!
|
||||
|
||||
### Changelog
|
||||
|
||||
{{ range .Commits -}}{{ if ne .Subject "" -}}
|
||||
* {{ .Hash.Short }} {{ .Header }}
|
||||
{{ end }}{{ end }}
|
||||
|
||||
{{- if .NoteGroups -}}
|
||||
{{ range .NoteGroups -}}
|
||||
### {{ .Title }}
|
||||
|
||||
{{ range .Notes }}
|
||||
{{ .Body }}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
27
hack/chglog-config.yml
Executable file
27
hack/chglog-config.yml
Executable file
@@ -0,0 +1,27 @@
|
||||
style: github
|
||||
template: CHANGELOG.tpl.md
|
||||
info:
|
||||
title: CHANGELOG
|
||||
repository_url: https://github.com/siderolabs/talos-cloud-controller-manager
|
||||
options:
|
||||
commits:
|
||||
# filters:
|
||||
# Type:
|
||||
# - feat
|
||||
# - fix
|
||||
# - perf
|
||||
# - refactor
|
||||
commit_groups:
|
||||
# title_maps:
|
||||
# feat: Features
|
||||
# fix: Bug Fixes
|
||||
# perf: Performance Improvements
|
||||
# refactor: Code Refactoring
|
||||
header:
|
||||
pattern: "^(\\w*)\\:\\s(.*)$"
|
||||
pattern_maps:
|
||||
- Type
|
||||
- Subject
|
||||
notes:
|
||||
keywords:
|
||||
- BREAKING CHANGE
|
||||
9
hack/ct.yml
Normal file
9
hack/ct.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
helm-extra-args: --timeout 300s
|
||||
check-version-increment: false
|
||||
debug: true
|
||||
chart-dirs:
|
||||
- charts
|
||||
validate-maintainers: true
|
||||
namespace: default
|
||||
release-label: test
|
||||
target-branch: main
|
||||
Reference in New Issue
Block a user