Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test Chart

on:
push:
pull_request:

jobs:
test-e2e:
name: Run on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install kubebuilder
run: |
curl -L -o kubebuilder "https://go.kubebuilder.io/dl/latest/$(go env GOOS)/$(go env GOARCH)"
chmod +x kubebuilder
sudo mv kubebuilder /usr/local/bin/
- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Create kind cluster
run: kind create cluster

- name: Build and load operator image
run: |
go mod tidy
make manifests # Generate fresh manifests first
# Force Docker usage in CI (simpler than handling both runtimes)
make image-build CONTAINER_RUNTIME=docker
IMAGE_NAME="docker.io/persesdev/perses-operator:v$(cat VERSION)"
kind load docker-image "${IMAGE_NAME}"
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Test Helm chart
run: |
make helm-chart
helm lint dist/chart
make helm-install
- name: Check Helm release
run: |
helm status perses-operator --namespace perses-operator-system
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to have a workflow to release this helm chart. Same like this one

2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Dockerfile.cross
*~
.vscode

/dist

.goreleaser.yaml

/.github/perses-ci/
Expand Down
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,24 @@ generate-changelog:
.PHONY: tag
tag:
./scripts/release.sh --tag "${VERSION}"

##@ Helm
.PHONY: helm-chart
helm-chart: manifests
kubebuilder edit --plugins=helm/v1-alpha
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be great if the kubebuilder binary can be installed locally instead of installing it globally by the end-user in advance. Please see how it is done for [jsonnet_binary here](https://github.com/perses/perses-operator/blob/main/Makefile#L316-L320.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks for the feedback, will try to pick up this work again

@echo "Helm chart updated in dist/chart/"

.PHONY: helm-chart-force
helm-chart-force: manifests
kubebuilder edit --plugins=helm/v1-alpha --force
@echo "Helm chart forcibly updated in dist/chart/"

.PHONY: helm-install
helm-install: helm-chart
helm upgrade --install perses-operator dist/chart \
--create-namespace \
--namespace perses-operator-system \
--set image.repository=$(IMAGE_TAG_BASE) \
--set image.tag=v$(VERSION) \
--set metrics.enable=false \
--force
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ domain: perses.dev
layout:
- go.kubebuilder.io/v4
plugins:
helm.kubebuilder.io/v1-alpha: {}
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: perses-operator
Expand All @@ -16,7 +17,6 @@ resources:
namespaced: true
controller: true
domain: perses.dev
group:
kind: Perses
path: github.com/perses/perses-operator/api/v1alpha1
version: v1alpha1
Expand Down
25 changes: 25 additions & 0 deletions dist/chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Patterns to ignore when building Helm packages.
# Operating system files
.DS_Store

# Version control directories
.git/
.gitignore
.bzr/
.hg/
.hgignore
.svn/

# Backup and temporary files
*.swp
*.tmp
*.bak
*.orig
*~

# IDE and editor-related files
.idea/
.vscode/

# Helm chart artifacts
dist/chart/*.tgz
7 changes: 7 additions & 0 deletions dist/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: perses-operator
description: A Helm chart to distribute the project perses-operator
type: application
version: 0.1.0
appVersion: "0.1.0"
icon: "https://example.com/icon.png"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
icon: "https://example.com/icon.png"
icon: "https://github.com/perses/perses/blob/main/docs/images/perses_logo_lt.png"

50 changes: 50 additions & 0 deletions dist/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- define "chart.name" -}}
{{- if .Chart }}
{{- if .Chart.Name }}
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- else if .Values.nameOverride }}
{{ .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
perses-operator
{{- end }}
{{- else }}
perses-operator
{{- end }}
{{- end }}


{{- define "chart.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Chart.Version }}
helm.sh/chart: {{ .Chart.Version | quote }}
{{- end }}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{- define "chart.hasMutatingWebhooks" -}}
{{- $hasMutating := false }}
{{- range . }}
{{- if eq .type "mutating" }}
$hasMutating = true }}{{- end }}
{{- end }}
{{ $hasMutating }}}}{{- end }}


{{- define "chart.hasValidatingWebhooks" -}}
{{- $hasValidating := false }}
{{- range . }}
{{- if eq .type "validating" }}
$hasValidating = true }}{{- end }}
{{- end }}
{{ $hasValidating }}}}{{- end }}
36 changes: 36 additions & 0 deletions dist/chart/templates/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.certmanager.enable }}
# Self-signed Issuer
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
name: selfsigned-issuer
namespace: {{ .Release.Namespace }}
spec:
selfSigned: {}
{{- if .Values.metrics.enable }}
---
# Certificate for the metrics
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations:
{{- if .Values.crd.keep }}
"helm.sh/resource-policy": keep
{{- end }}
labels:
{{- include "chart.labels" . | nindent 4 }}
name: metrics-certs
namespace: {{ .Release.Namespace }}
spec:
dnsNames:
- perses-operator.{{ .Release.Namespace }}.svc
- perses-operator.{{ .Release.Namespace }}.svc.cluster.local
- perses-operator-metrics-service.{{ .Release.Namespace }}.svc
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: metrics-server-cert
{{- end }}
{{- end }}
Loading
Loading