Skip to content

Commit

Permalink
[Common] New Resources (#91)
Browse files Browse the repository at this point in the history
* Add new resources
* Add CI values for testing
  • Loading branch information
lazam authored Jun 17, 2022
1 parent 9d27903 commit 2b3f0e4
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 56 deletions.
24 changes: 4 additions & 20 deletions charts/common/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
apiVersion: v2
name: common
description: A generic 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: "0.1.6"

# 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"
version: 0.1.7
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
7 changes: 1 addition & 6 deletions charts/common/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
# To do

add templates for:
- configmaps
- serviceMonitor
- prometheusRules
# Generic Helm Chart
20 changes: 20 additions & 0 deletions charts/common/ci/kind-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
image:
repository: nginx
pullPolicy: IfNotPresent
tag: "latest"

service:
annotations: {}
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP

env:
RANDOM_ENV_VAR: justsomerandom

config:
test.yml: |-
test: data
15 changes: 15 additions & 0 deletions charts/common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ helm.sh/chart: {{ include "common.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.extraLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Expand All @@ -60,3 +63,15 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "common.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
14 changes: 14 additions & 0 deletions charts/common/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.config }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
data:
{{- range $key, $val := .Values.config }}
{{ $key }}: {{ $val | quote }}
{{- end -}}
{{- end }}
12 changes: 9 additions & 3 deletions charts/common/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -35,9 +36,11 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.containerPort }}
protocol: TCP
{{- range $keys := .Values.service.ports }}
- name: {{ .name }}
containerPort: {{ .targetPort }}
protocol: {{ .protocol }}
{{- end }}
{{- with .Values.livenessProbe }}
livenessProbe:
{{- toYaml . | trim | nindent 12 }}
Expand Down Expand Up @@ -69,4 +72,7 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.additionalPodSpec }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/common/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
spec:
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
Expand Down
1 change: 1 addition & 0 deletions charts/common/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
type: Opaque
Expand Down
13 changes: 9 additions & 4 deletions charts/common/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.sessionAffinity }}
sessionAffinity: {{ .Values.service.sessionAffinity }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
{{ toYaml .Values.service.ports | indent 4 }}
selector:
{{- include "common.selectorLabels" . | nindent 4 }}
1 change: 1 addition & 0 deletions charts/common/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "common.serviceAccountName" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
Expand Down
24 changes: 24 additions & 0 deletions charts/common/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
{{ toYaml .Values.serviceMonitor.endpoints | indent 4 }}
jobLabel: "{{ .Release.Name }}"
selector:
matchLabels:
{{- include "common.selectorLabels" . | nindent 8 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/common/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "common.fullname" . }}
namespace: {{ template "common.namespace" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- if .Values.stateful.podAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ include "common.fullname" . }}
Expand Down Expand Up @@ -78,6 +83,9 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.additionalPodSpec }}
{{- toYaml . | nindent 6 }}
{{- end }}
volumes:
{{- if .Values.persistence.existingClaim }}
- name: data
Expand Down
Loading

0 comments on commit 2b3f0e4

Please sign in to comment.