Skip to content

Commit

Permalink
[FEAT] change gitignore and add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Takashi committed Oct 24, 2021
1 parent c7b4779 commit d1ed69f
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/go,linux,windows,macos,visualstudiocode,jetbrains

gitana
# End of https://www.toptal.com/developers/gitignore/api/go,linux,windows,macos,visualstudiocode,jetbrains
23 changes: 23 additions & 0 deletions charts/gitana/.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/gitana/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: gitana
description: A Helm chart for Kubernetes

# 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: 1.0.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"
Empty file.
68 changes: 68 additions & 0 deletions charts/gitana/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gitana.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 "gitana.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 "gitana.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "gitana.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "gitana.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "dashboard.labels" -}}
{{- if .Values.flags.dashboard.labels }}
{{- range .Values.flags.dashboard.labels }}{{(print .name "=" .value ) }},{{- end }}
{{- end }}
{{- end }}
84 changes: 84 additions & 0 deletions charts/gitana/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "gitana.fullname" . }}
labels:
{{- include "gitana.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "gitana.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "gitana.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gitana.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
args:
- sync
- --log.level={{ .Values.flags.log.level }}
- --sync-timer={{ .Values.flags.syncTimer }}
{{- if .Values.flags.kubeconfig }}
- --kubeconfig={{ .Values.flags.kubeconfig }}
{{- end }}
{{- if .Values.flags.dashboard.folderAnnotation }}
- --dashboard.folder-annotation={{ .Values.flags.dashboard.folderAnnotation }}
{{- end }}
- --dashboard.labels={{- include "dashboard.labels" . | trimSuffix "," }}
- --namespace={{ .Values.flags.namespace }}
{{- if .Values.flags.repository.auth }}
- --repository.auth.user={{ .Values.flags.repository.auth }}
- --repository.auth.user={{ .Values.flags.repository.password }}
{{- end }}
- --repository.branch={{ .Values.flags.repository.branch }}
- --repository.path=/tmp/gitana/repository
- --repository.url={{ .Values.flags.repository.url }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 9754
protocol: TCP
livenessProbe:
httpGet:
path: /-/health
port: http
readinessProbe:
httpGet:
path: /-/ready
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /tmp/gitana
name: gitana
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: gitana
emptyDir: {}
14 changes: 14 additions & 0 deletions charts/gitana/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "gitana.fullname" . }}
rules:
- apiGroups: [""]
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- update
11 changes: 11 additions & 0 deletions charts/gitana/templates/rolebind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "gitana.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "gitana.serviceAccountName" . }}
roleRef:
kind: Role
name: {{ include "gitana.fullname" . }}
apiGroup: rbac.authorization.k8s.io
15 changes: 15 additions & 0 deletions charts/gitana/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "gitana.fullname" . }}
labels:
{{- include "gitana.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "gitana.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/gitana/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "gitana.serviceAccountName" . }}
labels:
{{- include "gitana.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/gitana/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.serviceMonitor.enabled }}
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
labels:
{{- include "gitana.labels" . | nindent 4 }}
name: {{ include "gitana.fullname" . }}
spec:
endpoints:
- port: http
{{- if .Values.metrics.serviceMonitor.interval }}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "gitana.selectorLabels" . | nindent 4 }}
{{- end}}
15 changes: 15 additions & 0 deletions charts/gitana/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 "gitana.fullname" . }}-test-connection"
labels:
{{- include "gitana.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "gitana.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Loading

0 comments on commit d1ed69f

Please sign in to comment.