Skip to content

Commit

Permalink
move 'commons' chart
Browse files Browse the repository at this point in the history
  • Loading branch information
akafazov committed Nov 21, 2024
1 parent 7d1db27 commit 2ffb271
Show file tree
Hide file tree
Showing 28 changed files with 218 additions and 39 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build common Workflow
on:
push:
paths:
- 'charts/common/**'
- '.github/workflows/common.yaml'

jobs:
pipeline:
concurrency:
group: common-${{ github.ref }}
cancel-in-progress: true
uses: openmfp/gha/.github/workflows/pipeline-chart.yml@main
with:
chartFolder: charts
chartName: common
additionalTestFilesCommand: ''
chartRepos: 'bitnami=https://charts.bitnami.com/bitnami,openfga=https://openfga.github.io/helm-charts'
secrets: inherit

updateVersionFile:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [pipeline]
uses: openmfp/gha/.github/workflows/job-update-version-file.yml@main
secrets: inherit
with:
componentVersionKey: "common"
version: ${{ needs.pipeline.outputs.version }}
10 changes: 3 additions & 7 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ tasks:
- helm package ./charts/openmfp
helmtest:
cmds:
- helm unittest ./charts/common
- helm unittest ./charts/account-operator-crds
- helm unittest ./charts/account-operator
- "for chart in $(echo {{.CHARTS}} | tr ',' ' '); do helm unittest $chart; done"
test:
deps:
- task: helmtest
update:
cmds:
- helm dependency update ./charts/common
- helm dependency update ./charts/account-operator-crds
- helm dependency update ./charts/account-operator
- "for chart in $(echo {{.CHARTS}} | tr ',' ' '); do helm dependency update $chart; done"
validate:
cmds:
- task: lint
- task: package
- task: test
- task: test
2 changes: 1 addition & 1 deletion charts/account-operator-crds/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kcp:
enabled: false
enabled: false
6 changes: 3 additions & 3 deletions charts/account-operator/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies:
version: 0.1.4
- name: common
repository: file://../common
version: 0.1.3
digest: sha256:ecdfbd09cac50aef69e9ea41eac7ef3e80284d8ab273ed416daadf48d89de053
generated: "2024-11-14T20:28:13.309725+01:00"
version: 0.1.4
digest: sha256:53e54ba3caca17b02488e6900343bed1c7ee97f79aebe10b572956a4f11ccc6e
generated: "2024-11-21T15:07:29.093387942+02:00"
4 changes: 2 additions & 2 deletions charts/account-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apiVersion: v2
name: account-operator
description: A Helm chart for Kubernetes
type: application
version: 0.4.11
version: 0.4.12
appVersion: "0.101.0"
dependencies:
- name: account-operator-crds
version: 0.1.4
condition: crds.enabled
repository: file://../account-operator-crds
- name: common
version: 0.1.3
version: 0.1.4
repository: file://../common
Binary file modified charts/account-operator/charts/account-operator-crds-0.1.4.tgz
Binary file not shown.
Binary file removed charts/account-operator/charts/common-0.1.3.tgz
Binary file not shown.
Binary file added charts/account-operator/charts/common-0.1.4.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/account-operator/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
rules:
- apiGroups:
- core.openmfp.io
Expand Down
6 changes: 3 additions & 3 deletions charts/account-operator/templates/cluster-rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
subjects:
- kind: ServiceAccount
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
apiGroup: rbac.authorization.k8s.io
12 changes: 6 additions & 6 deletions charts/account-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
namespace: {{ .Release.Namespace }}
{{- if .Values.webhooks.enabled }}
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "entity.name" . }}-serving-cert
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "common.entity.name" . }}-serving-cert
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
selector:
matchLabels:
service: {{ include "entity.name" . }}
service: {{ include "common.entity.name" . }}
template:
metadata:
labels:
service: {{ include "entity.name" . }}
service: {{ include "common.entity.name" . }}
control-plane: controller-manager
{{- with .Values.deployment.specTemplate.labels }}
{{- toYaml . | nindent 8 }}
Expand All @@ -28,7 +28,7 @@ spec:
traffic.sidecar.istio.io/excludeInboundPorts: "9443"
{{- end }}
spec:
serviceAccountName: {{ include "entity.name" . }}
serviceAccountName: {{ include "common.entity.name" . }}
containers:
- args:
- operator
Expand Down Expand Up @@ -122,7 +122,7 @@ spec:
- name: cert
secret:
defaultMode: 420
secretName: {{ include "entity.name" . }}-webhook-server-cert
secretName: {{ include "common.entity.name" . }}-webhook-server-cert
{{- end }}


Expand Down
4 changes: 2 additions & 2 deletions charts/account-operator/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "entity.name" . }}
name: {{ include "common.entity.name" . }}
namespace: {{ .Release.Namespace }}
{{- include "global.imagePullSecret" . }}
{{- include "common.imagePullSecret" . }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: {{ include "entity.name" . }}-mutating-webhook-configuration
name: {{ include "common.entity.name" . }}-mutating-webhook-configuration
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "entity.name" . }}-serving-cert
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "common.entity.name" . }}-serving-cert
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: {{ include "entity.name" . }}-webhook
name: {{ include "common.entity.name" . }}-webhook
namespace: {{ .Release.Namespace }}
path: /mutate-core-openmfp-io-v1alpha1-account
failurePolicy: Fail
Expand Down
12 changes: 6 additions & 6 deletions charts/account-operator/templates/webhook/pki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: {{ include "entity.name" . }}-selfsigned-issuer
name: {{ include "common.entity.name" . }}-selfsigned-issuer
namespace: {{ .Release.namespace }}
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "entity.name" . }}-serving-cert
name: {{ include "common.entity.name" . }}-serving-cert
namespace: {{ .Release.namespace }}
spec:
dnsNames:
- {{ include "entity.name" . }}-webhook.{{ .Release.Namespace }}.svc
- {{ include "entity.name" . }}-webhook.{{ .Release.Namespace }}.svc.cluster.local
- {{ include "common.entity.name" . }}-webhook.{{ .Release.Namespace }}.svc
- {{ include "common.entity.name" . }}-webhook.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ include "entity.name" . }}-selfsigned-issuer
secretName: {{ include "entity.name" . }}-webhook-server-cert
name: {{ include "common.entity.name" . }}-selfsigned-issuer
secretName: {{ include "common.entity.name" . }}-webhook-server-cert
{{- end -}}
4 changes: 2 additions & 2 deletions charts/account-operator/templates/webhook/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "entity.name" . }}-webhook
name: {{ include "common.entity.name" . }}-webhook
namespace: {{ .Release.Namespace }}
spec:
ports:
- port: 443
protocol: TCP
targetPort: 9443
selector:
service: {{ include "entity.name" . }}
service: {{ include "common.entity.name" . }}
control-plane: controller-manager
{{- end -}}
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: A Helm chart for Kubernetes

type: library

version: 0.1.3
version: 0.1.4
3 changes: 3 additions & 0 deletions charts/common/templates/_certManagerEnabled.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "common.certManagerEnabled" -}}
{{- default (.Values.certManager).enabled (((.Values.global).certManager).enabled) -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/common/templates/_entityName.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "entity.name" -}}
{{- define "common.entity.name" -}}
{{- if contains .Chart.Name .Release.Name }}
{{- printf "%s" .Chart.Name | trunc 63 }}
{{- else }}
Expand Down
2 changes: 1 addition & 1 deletion charts/common/templates/_imagePullSecret.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- define "global.imagePullSecret" }}
{{- define "common.imagePullSecret" }}
imagePullSecrets:
- name: {{ default .Values.imagePullSecret (.Values.global).imagePullSecret }}
{{- end -}}
3 changes: 3 additions & 0 deletions charts/common/templates/_istioEnabled.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "common.istioEnabled" -}}
{{- default (.Values.istio).enabled (((.Values.global).istio).enabled) -}}
{{- end -}}
23 changes: 23 additions & 0 deletions charts/common/test-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/common/test-chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://..
version: 0.1.4
digest: sha256:03b950f56aee5eb8a4a6fb02669d74e1f7858f0c69d3162ae63b2e633f7c2686
generated: "2024-11-20T13:25:22.886154+01:00"
29 changes: 29 additions & 0 deletions charts/common/test-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v2
name: test-chart
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

dependencies:
- name: common
version: 0.1.4
repository: file://..
Binary file added charts/common/test-chart/charts/common-0.1.4.tgz
Binary file not shown.
22 changes: 22 additions & 0 deletions charts/common/test-chart/templates/vs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if eq (include "common.istioEnabled" .) "true" -}}
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: {{ include "common.entity.name" . }}
namespace: {{ .Release.Namespace }}
spec:
gateways:
- {{ .Release.Namespace }}/gateway
hosts:
- some.domain
http:
match:
- uri:
exact: some.domain
name: default
route:
- destination:
host: some.host
port:
number: 8080
{{- end -}}
44 changes: 44 additions & 0 deletions charts/common/test-chart/tests/__snapshot__/istio_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
test global value:
1: |
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: RELEASE-NAME-test-chart
namespace: NAMESPACE
spec:
gateways:
- NAMESPACE/gateway
hosts:
- some.domain
http:
match:
- uri:
exact: some.domain
name: default
route:
- destination:
host: some.host
port:
number: 8080
test local value:
1: |
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: RELEASE-NAME-test-chart
namespace: NAMESPACE
spec:
gateways:
- NAMESPACE/gateway
hosts:
- some.domain
http:
match:
- uri:
exact: some.domain
name: default
route:
- destination:
host: some.host
port:
number: 8080
Loading

0 comments on commit 2ffb271

Please sign in to comment.