Skip to content

Commit 21a5419

Browse files
authored
add automated builds (#3)
* add automated builds this includes containers for the operator (and arm) along with helm and the various catalog / bundle containers that I am not sure anyone uses Signed-off-by: vsoch <[email protected]>
1 parent b15d1de commit 21a5419

17 files changed

+913
-2
lines changed

.github/workflows/build-deploy.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: build metrics-operator
2+
3+
on:
4+
pull_request: []
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
# Only build arm image on merge, takes too long otherwise
12+
build-arm:
13+
if: (github.event_name != 'pull_request')
14+
runs-on: ubuntu-latest
15+
name: make and build arm
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v3
19+
- uses: actions/setup-go@v3
20+
with:
21+
go-version: ^1.18.1
22+
- name: GHCR Login
23+
if: (github.event_name != 'pull_request')
24+
uses: docker/login-action@v2
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Add custom buildx ARM builder
31+
run: |
32+
docker buildx create --name armbuilder
33+
docker buildx use armbuilder
34+
docker buildx inspect --bootstrap
35+
36+
- name: Deploy Container
37+
run: make arm-deploy
38+
39+
build:
40+
runs-on: ubuntu-latest
41+
strategy:
42+
matrix:
43+
command: [docker]
44+
45+
name: make and build ${{ matrix.command }}
46+
steps:
47+
- name: Checkout Repository
48+
uses: actions/checkout@v3
49+
- uses: actions/setup-go@v3
50+
with:
51+
go-version: ^1.18.1
52+
- name: GHCR Login
53+
if: (github.event_name != 'pull_request')
54+
uses: docker/login-action@v2
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Build Container
61+
run: make ${{ matrix.command }}-build
62+
63+
- name: Deploy Container
64+
if: (github.event_name != 'pull_request')
65+
run: make ${{ matrix.command }}-push

.github/workflows/helm.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: helm metrics-operator
2+
3+
on:
4+
pull_request: []
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
name: Prepare chart
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
- uses: actions/setup-go@v3
18+
with:
19+
go-version: ^1.18.1
20+
- name: GHCR Login
21+
if: (github.event_name != 'pull_request')
22+
uses: docker/login-action@v2
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Install Helm
29+
run: |
30+
export HELM_EXPERIMENTAL_OCI=1
31+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
32+
33+
- name: Build chart
34+
run: make helm
35+
36+
- name: Login to Helm
37+
if: (github.event_name != 'pull_request')
38+
env:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
echo "${password}" | helm registry login -u ${username} --password-stdin ${registry}
44+
PKG_RESPONSE=$(helm package ./chart)
45+
echo "$PKG_RESPONSE"
46+
CHART_TAR_GZ=$(basename "$PKG_RESPONSE")
47+
helm push "$CHART_TAR_GZ" oci://ghcr.io/converged-computing/metrics-operator-helm

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ DEVIMG ?= ghcr.io/converged-computing/metrics-operator:test
5454
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5555
ENVTEST_K8S_VERSION = 1.26.0
5656

57+
5758
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5859
ifeq (,$(shell go env GOBIN))
5960
GOBIN=$(shell go env GOPATH)/bin
6061
else
6162
GOBIN=$(shell go env GOBIN)
6263
endif
6364

65+
HELMIFY ?= $(LOCALBIN)/helmify
66+
6467
# Setting SHELL to bash allows bash commands to be executed by recipes.
6568
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
6669
SHELL = /usr/bin/env bash -o pipefail
@@ -108,6 +111,7 @@ vet: ## Run go vet against code.
108111
test: manifests generate fmt vet envtest ## Run tests.
109112
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
110113

114+
111115
##@ Build
112116

113117
.PHONY: build
@@ -291,6 +295,14 @@ arm-deploy: manifests kustomize
291295
cd config/manager && $(KUSTOMIZE) edit set image controller=${ARMIMG}
292296
$(KUSTOMIZE) build config/default > examples/dist/metrics-operator-arm.yaml
293297

298+
.PHONY: helmify
299+
helmify: $(HELMIFY) ## Download helmify locally if necessary.
300+
$(HELMIFY): $(LOCALBIN)
301+
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest
302+
303+
helm: manifests kustomize helmify
304+
$(KUSTOMIZE) build config/default | $(HELMIFY)
305+
294306
.PHONY: pre-push
295307
pre-push: generate build-config-arm build-config
296308
git status

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ See early documentation and notes in [docs](docs).
88
## Dinosaur TODO
99

1010
- Basic design for each of perf, and storage metrics
11-
- Add automated builds / deploys for the operator
1211
- Pretty / detailed docs
1312
- Need a strategy for storing metrics output / logs
1413
- Bug that config map not cleaning up with deletion

chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/Chart.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: chart
3+
description: A Helm chart for Kubernetes
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.1.0
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "0.1.0"

chart/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chart.labels" -}}
37+
helm.sh/chart: {{ include "chart.chart" . }}
38+
{{ include "chart.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "chart.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chart.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "chart.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "chart.fullname" . }}-controller-manager
5+
labels:
6+
app.kubernetes.io/component: manager
7+
app.kubernetes.io/created-by: test
8+
app.kubernetes.io/part-of: test
9+
control-plane: controller-manager
10+
{{- include "chart.labels" . | nindent 4 }}
11+
spec:
12+
replicas: {{ .Values.controllerManager.replicas }}
13+
selector:
14+
matchLabels:
15+
control-plane: controller-manager
16+
{{- include "chart.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
labels:
20+
control-plane: controller-manager
21+
{{- include "chart.selectorLabels" . | nindent 8 }}
22+
annotations:
23+
kubectl.kubernetes.io/default-container: manager
24+
spec:
25+
affinity:
26+
nodeAffinity:
27+
requiredDuringSchedulingIgnoredDuringExecution:
28+
nodeSelectorTerms:
29+
- matchExpressions:
30+
- key: kubernetes.io/arch
31+
operator: In
32+
values:
33+
- amd64
34+
- arm64
35+
- ppc64le
36+
- s390x
37+
- key: kubernetes.io/os
38+
operator: In
39+
values:
40+
- linux
41+
containers:
42+
- args: {{- toYaml .Values.controllerManager.kubeRbacProxy.args | nindent 8 }}
43+
env:
44+
- name: KUBERNETES_CLUSTER_DOMAIN
45+
value: {{ quote .Values.kubernetesClusterDomain }}
46+
image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag
47+
| default .Chart.AppVersion }}
48+
name: kube-rbac-proxy
49+
ports:
50+
- containerPort: 8443
51+
name: https
52+
protocol: TCP
53+
resources: {{- toYaml .Values.controllerManager.kubeRbacProxy.resources | nindent
54+
10 }}
55+
securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext
56+
| nindent 10 }}
57+
- args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }}
58+
command:
59+
- /manager
60+
env:
61+
- name: KUBERNETES_CLUSTER_DOMAIN
62+
value: {{ quote .Values.kubernetesClusterDomain }}
63+
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
64+
| default .Chart.AppVersion }}
65+
imagePullPolicy: {{ .Values.controllerManager.manager.imagePullPolicy }}
66+
livenessProbe:
67+
httpGet:
68+
path: /healthz
69+
port: 8081
70+
initialDelaySeconds: 15
71+
periodSeconds: 20
72+
name: manager
73+
readinessProbe:
74+
httpGet:
75+
path: /readyz
76+
port: 8081
77+
initialDelaySeconds: 5
78+
periodSeconds: 10
79+
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10
80+
}}
81+
securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext
82+
| nindent 10 }}
83+
securityContext:
84+
runAsNonRoot: true
85+
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
86+
terminationGracePeriodSeconds: 10

0 commit comments

Comments
 (0)