Skip to content

Commit

Permalink
feat(helm): basic helm chart
Browse files Browse the repository at this point in the history
definitelly not complete helm chart. Lot of RBAC stuff is missing for
now.

Signed-off-by: Hy3n4 <[email protected]>
  • Loading branch information
Hy3n4 committed Nov 3, 2023
1 parent 1b6fb9e commit 32cdd30
Show file tree
Hide file tree
Showing 13 changed files with 547 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm/osko/.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/
26 changes: 26 additions & 0 deletions helm/osko/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: osko
description: Base Helm chart for OSKO

# 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"

home: https://github.com/oskoperator/osko
1 change: 1 addition & 0 deletions helm/osko/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. OpenSLO Kubernetes Operator is installed in the cluster
62 changes: 62 additions & 0 deletions helm/osko/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "osko.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 "osko.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 "osko.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "osko.selectorLabels" -}}
app.kubernetes.io/name: {{ include "osko.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "osko.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "osko.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions helm/osko/templates/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
{{- include "osko.labels" . | nindent 4 }}
name: {{ include "osko.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "osko.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "osko.fullname" . }}
namespace: {{ .Release.Namespace }}
181 changes: 181 additions & 0 deletions helm/osko/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "osko.fullname" . }}
rules:
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- monitoring.coreos.com
resources:
- prometheusrules
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- alertconditions
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- alertconditions/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- alertconditions/status
verbs:
- get
- patch
- update
- apiGroups:
- openslo.com
resources:
- alertnotificationtargets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- alertnotificationtargets/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- alertnotificationtargets/status
verbs:
- get
- patch
- update
- apiGroups:
- openslo.com
resources:
- alertpolicies
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- alertpolicies/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- alertpolicies/status
verbs:
- get
- patch
- update
- apiGroups:
- openslo.com
resources:
- datasources
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- datasources/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- datasources/status
verbs:
- get
- patch
- update
- apiGroups:
- openslo.com
resources:
- slis
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- slis/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- slis/status
verbs:
- get
- patch
- update
- apiGroups:
- openslo.com
resources:
- slos
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- openslo.com
resources:
- slos/finalizers
verbs:
- update
- apiGroups:
- openslo.com
resources:
- slos/status
verbs:
- get
- patch
- update
66 changes: 66 additions & 0 deletions helm/osko/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "osko.fullname" . }}
labels:
{{- include "osko.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "osko.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "osko.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "osko.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
command:
- /manager
args:
- --leader-elect
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8081
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: http
readinessProbe:
httpGet:
path: /readyz
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
terminationGracePeriodSeconds: 10
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 32cdd30

Please sign in to comment.