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

271 kubernetes helm chart #403

Closed
wants to merge 4 commits into from
Closed
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
17 changes: 17 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: sablier
version: "0.0.0"
appVersion: "1.8.0"
description: A free and open-source software to start workloads on demand and stop them after a period of inactivity.
type: application
keywords:
- Orchestration & Management
home: https://acouvreur.github.io/sablier/#/
sources:
- "https://github.com/acouvreur/sablier"
maintainers:
- name: Alexis Couvreur
email: [email protected]
url: https://www.alexiscouvreur.fr/
icon: A URL to an SVG or PNG image to be used as an icon (optional).
deprecated: false
Empty file added helm/README.md
Empty file.
53 changes: 53 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
app: sablier-{{ .Release.Name }}
{{- with .Values.deploymentLabels }}
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
{{- with .Values.deploymentStrategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
app: sablier-{{ .Release.Name }}
template:
metadata:
labels:
app: sablier-{{ .Release.Name }}
{{- with .Values.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podAnnotations }}
annotations:
{{ toYaml . | nindent 8 }}
{{- end }}
spec:
Fixed Show fixed Hide fixed
serviceAccountName: sablier-{{ .Release.Name }}

Check warning

Code scanning / SonarCloud

Service account permissions should be restricted Medium

Bind this Service Account to RBAC or disable "automountServiceAccountToken". See more on SonarCloud
containers:
- name: sablier

Check warning

Code scanning / SonarCloud

Memory limits should be enforced Medium

Specify a memory limit for this container. See more on SonarCloud

Check warning

Code scanning / SonarCloud

Storage limits should be enforced Medium

Specify a storage limit for this container. See more on SonarCloud
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
imagePullPolicy: IfNotPresent
args: ["start", "--provider.name=kubernetes", "--logging.level={{ .Values.logLevel}}"]
ports:
- containerPort: 10000
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
32 changes: 32 additions & 0 deletions helm/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: sablier-{{ .Release.Name }}
rules:
- apiGroups:
- apps
- ""
resources:
- deployments
- deployments/scale
- statefulsets
- statefulsets/scale
verbs:
- patch # Scale up and down
- get # Retrieve info about specific dep
- update # Scale up and down
- list # Events
- watch # Events
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: sablier-{{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: sablier-{{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
5 changes: 5 additions & 0 deletions helm/templates/sa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
12 changes: 12 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: sablier-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
selector:
app: sablier-{{ .Release.Name }}
ports:
- protocol: TCP
port: 10000
targetPort: 10000
203 changes: 203 additions & 0 deletions helm/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: Sablier Deployment Generation manifest
templates:
- "deployment.yaml"
release:
name: test-sablier
namespace: sablier
tests:
- it: should create 1 sablier deployment
asserts:
- hasDocuments:
count: 1
- equal:
path: metadata.name
value: sablier-test-sablier
- equal:
path: metadata.namespace
value: sablier
- equal:
path: spec.selector.matchLabels
value:
app: sablier-test-sablier
- it: should add deploymentLabels
set:
deploymentLabels:
random: test
random2: test2
asserts:
- equal:
path: metadata.labels
value:
app: sablier-test-sablier
random: test
random2: test2
- it: should not add deployments labels
asserts:
- equal:
path: metadata.labels
value:
app: sablier-test-sablier
- it: should add deploymentAnnotations
set:
deploymentAnnotations:
random: test
random2: test2
asserts:
- equal:
path: metadata.annotations
value:
random: test
random2: test2
- it: should not add deployment annotations
asserts:
- notExists:
path: metadata.annotations
- it: should override replicas
set:
replicas: 10
asserts:
- equal:
path: spec.replicas
value: 10
- it: should add podLabels
set:
podLabels:
label1: hello
labels2: world
asserts:
- equal:
path: spec.template.metadata.labels
value:
app: sablier-test-sablier
label1: hello
labels2: world

- it: should not add podLabels
asserts:
- equal:
path: spec.template.metadata.labels
value:
app: sablier-test-sablier
- it: should add podAnnotations
set:
podAnnotations:
annotations1: hello
annotations2: world
asserts:
- equal:
path: spec.template.metadata.annotations
value:
annotations1: hello
annotations2: world
- it: should not add podAnnotations
asserts:
- notExists:
path: spec.template.metadata.annotations
- it: shoudl set sablier loglevel
set:
logLevel: debug
asserts:
- equal:
path: spec.template.spec.containers[0].args
value:
["start", "--provider.name=kubernetes", "--logging.level=debug"]
- it: should set sablier livenessProbe
set:
livenessProbe:
httpGet:
path: /healthz
port: 10001
initialDelaySeconds: 7
timeoutSeconds: 2
successThreshold: 1
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: /healthz
port: 10001
initialDelaySeconds: 7
periodSeconds: 5
timeoutSeconds: 2
successThreshold: 1
failureThreshold: 3
- it: should set sablier readinessProbe
set:
readinessProbe:
httpGet:
path: /healthz
port: 10000
initialDelaySeconds: 7
periodSeconds: 5
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
asserts:
- equal:
path: spec.template.spec.containers[0].readinessProbe
value:
httpGet:
path: /healthz
port: 10000
initialDelaySeconds: 7
periodSeconds: 5
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
- it: should set sablier resource
set:
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
asserts:
- equal:
path: spec.template.spec.containers[0].resources
value:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
- it: should set empty resource
asserts:
- equal:
path: spec.template.spec.containers[0].resources
value: {}
- it: should set new tag and image repository
set:
image:
tag: 1.1.1
repository: test
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: test:1.1.1
- it: should set new tag only
set:
image:
tag: 1.1.1
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: acouvreur/sablier:1.1.1
- it: should override deployment strategy
set:
deploymentStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 50%
asserts:
- equal:
path: spec.strategy
value:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 50%
maxSurge: 25%
57 changes: 57 additions & 0 deletions helm/tests/rbac_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: Sablier RBAC Generation manifest
templates:
- "rbac.yaml"
release:
name: test-sablier
namespace: sablier
tests:
- it: should create rbac
asserts:
- hasDocuments:
count: 2
- it: should correctly set ClusterRole
documentSelector:
path: kind
value: ClusterRole
asserts:
- equal:
path: metadata.name
value: sablier-test-sablier
- equal:
path: rules
value:
- apiGroups:
- apps
- ""
resources:
- deployments
- deployments/scale
- statefulsets
- statefulsets/scale
verbs:
- patch # Scale up and down
- get # Retrieve info about specific dep
- update # Scale up and down
- list # Events
- watch # Events
- it: should correctly set ClusterRoleBinding
documentSelector:
path: kind
value: ClusterRoleBinding
asserts:
- equal:
path: metadata.name
value: sablier-test-sablier
- equal:
path: roleRef
value:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: sablier-test-sablier
- equal:
path: subjects
value:
- kind: ServiceAccount
name: sablier
namespace: sablier
Loading
Loading