Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/helmChart: initial support for installing the operator using helm charts #174

Merged
merged 13 commits into from
May 30, 2024
23 changes: 23 additions & 0 deletions charts/dragonfly-operator/.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/
24 changes: 24 additions & 0 deletions charts/dragonfly-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: dragonfly-operator
description: A Helm chart for dragonfly-operator

# 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: "v1.1.2"
63 changes: 63 additions & 0 deletions charts/dragonfly-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dragonfly-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "dragonfly-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "dragonfly-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "dragonfly-operator.labels" -}}
helm.sh/chart: {{ include "dragonfly-operator.chart" . }}
{{ include "dragonfly-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/created-by: {{ include "dragonfly-operator.name" . }}
app.kubernetes.io/part-of: {{ include "dragonfly-operator.name" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "dragonfly-operator.selectorLabels" -}}
control-plane: controller-manager
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "dragonfly-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "dragonfly-operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/dragonfly-operator/templates/clusterrolebindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "dragonfly-operator.fullname" . }}-manager-clusterrolebinding
labels:
{{- include "dragonfly-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: rbac
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "dragonfly-operator.fullname" . }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ include "dragonfly-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "dragonfly-operator.fullname" . }}-proxy-clusterrolebinding
labels:
{{- include "dragonfly-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: kube-rbac-proxy
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "dragonfly-operator.fullname" . }}-proxy-role
subjects:
- kind: ServiceAccount
name: {{ include "dragonfly-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
113 changes: 113 additions & 0 deletions charts/dragonfly-operator/templates/clusterroles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "dragonfly-operator.fullname" . }}-manager-role
labels:
{{- include "dragonfly-operator.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- dragonflydb.io
resources:
- dragonflies
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- dragonflydb.io
resources:
- dragonflies/finalizers
verbs:
- update
- apiGroups:
- dragonflydb.io
resources:
- dragonflies/status
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "dragonfly-operator.fullname" . }}-metrics-reader
labels:
{{- include "dragonfly-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/instance: metrics-reader
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "dragonfly-operator.fullname" . }}-proxy-role
labels:
{{- include "dragonfly-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/instance: proxy-role
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
Loading
Loading