Change-Id: I5895a80e86992b9408ecf96e889dc1ef6db4e994
This commit is contained in:
oleksandr k 2020-03-12 17:49:26 +00:00
parent 9418a85eca
commit 2cb25f1fa8
10 changed files with 324 additions and 0 deletions

18
.zuul.yaml Normal file
View File

@ -0,0 +1,18 @@
- job:
name: zuul-helm-functional
parent: apply-helm-charts
run: playbooks/functional/run.yaml
vars:
minikube_dns_resolvers: ['1.1.1.1', '8.8.8.8']
helm_charts:
nodepool: ./charts/nodepool
- project:
check:
jobs:
- chart-testing-lint
- zuul-helm-functional
gate:
jobs:
- chart-testing-lint
- zuul-helm-functional

22
chart/.helmignore Normal file
View File

@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

9
chart/Chart.yaml Normal file
View File

@ -0,0 +1,9 @@
apiVersion: v2
name: lodgeit
description: Helm charts for deploying Lodgeit
type: application
version: 0.0.0
appVersion: 0.0.1

View File

@ -0,0 +1,60 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "lodgeit.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 "lodgeit.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 -}}
{{/*
Generate chart secret name
*/}}
{{- define "lodgeit.secretName" -}}
{{ default (include "lodgeit.fullname" .) .Values.existingSecret }}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "lodgeit.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "lodgeit.labels" -}}
helm.sh/chart: {{ include "lodgeit.chart" . }}
{{ include "lodgeit.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "lodgeit.selectorLabels" -}}
app.kubernetes.io/name: {{ include "lodgeit.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

View File

@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "lodgeit.fullname" . }}
labels:
{{- include "lodgeit.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "lodgeit.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "lodgeit.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.version }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: LODGEIT_DBURI
valueFrom:
secretKeyRef:
name: {{ template "lodgeit.secretName" . }}
key: db-uri
- name: LODGEIT_SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ template "lodgeit.secretName" . }}
key: secret-key
ports:
- name: http
containerPort: 9000
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,37 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "lodgeit.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "lodgeit.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,21 @@
{{- if not .Values.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "lodgeit.fullname" . }}
labels:
{{- include "lodgeit.labels" . | nindent 4 }}
type: Opaque
data:
{{ if .Values.dbUri }}
db-uri: {{ .Values.dbUri | b64enc | quote }}
{{ else }}
db-uri: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
{{ if .Values.secretKey }}
secret-key: {{ .Values.secretKey | b64enc | quote }}
{{ else }}
secret-key: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
{{- end }}

View File

@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "lodgeit.fullname" . }}
labels:
{{- include "lodgeit.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{ end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
selector:
{{- include "lodgeit.selectorLabels" . | nindent 4 }}

62
chart/values.yaml Normal file
View File

@ -0,0 +1,62 @@
replicaCount: 1
image:
repository: opendevorg/lodgeit
version: latest
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
dbUri: "sqlite:////tmp/lodgeit.db"
secretKey: "password"
#existingSecret:
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
# type: ClusterIP
port: 80
type: NodePort
nodePort: 30009
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}

View File

@ -0,0 +1,6 @@
- hosts: all
roles:
- role: helm-template
vars:
helm_release_name: lodgeit
helm_chart: ./chart