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

Helm Chart & Automated Release #85

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions .github/workflows/release-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Charts

on:
push:
branches: [ main ]

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ Now, open your favorite browser and enter the url of dailyclean-api service : ht

Enjoy dailyclean !!!!

## Deploy using Helm

Add the helm repository, update and install the chart:
```bash
helm repo add dailyclean https://axafrance.github.io/dailyclean/
helm repo update
helm install dailyclean dailyclean/dailyclean
```

Check the [values.yaml](./charts/dailyclean/values.yaml) file to see the available configuration options.

## How Does It Work

- Daily clean use native kubernetes API, it works with any kubernetes projects.
Expand Down
23 changes: 23 additions & 0 deletions charts/dailyclean/.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/
5 changes: 5 additions & 0 deletions charts/dailyclean/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: dailyclean
description: A Helm chart to deploy the dailyclean application
type: application
version: 0.0.1
49 changes: 49 additions & 0 deletions charts/dailyclean/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dailyclean.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 "dailyclean.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 "dailyclean.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "dailyclean.labels" -}}
helm.sh/chart: {{ include "dailyclean.chart" . }}
{{ include "dailyclean.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

52 changes: 52 additions & 0 deletions charts/dailyclean/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
axa.com/dailyclean: 'false'
{{- include "dailyclean.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "dailyclean.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "dailyclean.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "dailyclean.fullname" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: SERVICE_JOB_IMAGENAME
value: {{ .Values.image.serviceJobImageName }}
- name: SERVICE_JOB_SERVICEACCOUNTNAME
value: {{ include "dailyclean.fullname" . }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
30 changes: 30 additions & 0 deletions charts/dailyclean/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host | quote }}
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "dailyclean.fullname" . }}
port:
number: {{ .Values.service.port }}
{{- end -}}
24 changes: 24 additions & 0 deletions charts/dailyclean/templates/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.route.enabled -}}
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
router: {{ .Values.route.router }}
{{- with .Values.route.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
host: {{ .Values.route.host }}
to:
kind: Service
name: {{ include "dailyclean.fullname" . }}
port:
targetPort: {{ .Values.service.port }}
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
{{- end }}
15 changes: 15 additions & 0 deletions charts/dailyclean/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "dailyclean.selectorLabels" . | nindent 4 }}
84 changes: 84 additions & 0 deletions charts/dailyclean/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
rules:
- verbs:
- create
apiGroups:
- ''
resources:
- pods/exec
- verbs:
- get
- list
- watch
apiGroups:
- ''
resources:
- pods
- verbs:
- get
- list
- watch
apiGroups:
- metrics.k8s.io
resources:
- pods
- verbs:
- get
- list
- watch
- patch
apiGroups:
- apps
- extensions
resources:
- deployments
- replicasets
- verbs:
- get
- list
- watch
- patch
apiGroups:
- apps
resources:
- statefulsets
- verbs:
- get
- create
- patch
- update
- delete
- list
- watch
apiGroups:
- batch
resources:
- jobs
- cronjobs
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "dailyclean.fullname" . }}
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "dailyclean.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "dailyclean.fullname" . }}
15 changes: 15 additions & 0 deletions charts/dailyclean/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "dailyclean.fullname" . }}-test-connection"
labels:
{{- include "dailyclean.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "dailyclean.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Loading