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

feat(geoipupdates) introduces new chart in version 0.0.1 #1273

Merged
merged 1 commit into from
Aug 16, 2024
Merged
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
8 changes: 8 additions & 0 deletions charts/geoipupdates/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
description: MaxMind GeoIP database updater
name: geoipupdates
version: 0.0.1
appVersion: "v7.0.1"
maintainers:
- email: [email protected]
name: jenkins-infra-team
52 changes: 52 additions & 0 deletions charts/geoipupdates/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "geoipupdate.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 "geoipupdate.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 -}}

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

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "geoipupdate.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "geoipupdate.labels" -}}
{{ include "geoipupdate.selectorLabels" . }}
helm.sh/chart: {{ include "geoipupdate.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
74 changes: 74 additions & 0 deletions charts/geoipupdates/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "geoipupdate.fullname" . }}
labels:
{{ include "geoipupdate.labels" . | indent 4 }}
spec:
replicas: 1 # Do not scale up or you will run in trouble
selector:
matchLabels:
{{ include "geoipupdate.selectorLabels" . | indent 6 }}
template:
metadata:
labels:
{{ include "geoipupdate.selectorLabels" . | indent 8 }}
spec:
automountServiceAccountToken: false
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: geoipupdate
image: "{{ .Values.image }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- with .Values.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: geoipdata
mountPath: /usr/share/GeoIP
readOnly: false
- name: tmpdir
mountPath: /tmp
readOnly: false
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: GEOIPUPDATE_EDITION_IDS
value: {{ .Values.geoipupdate.editions }}
- name: GEOIPUPDATE_FREQUENCY
value: {{ .Values.geoipupdate.update_frequency | quote }}
envFrom:
- secretRef:
name: {{ include "geoipupdate.fullname" . }}
{{- 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: geoipdata
{{- if .Values.dataVolume }}
{{- toYaml .Values.dataVolume | nindent 10 }}
{{- else }}
emptyDir: {}
{{- end }}
- name: tmpdir
emptyDir:
medium: "Memory"
...
11 changes: 11 additions & 0 deletions charts/geoipupdates/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and .Values.geoipupdate.account_id .Values.geoipupdate.license_key }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "geoipupdate.fullname" . }}
type: Opaque
data:
GEOIPUPDATE_ACCOUNT_ID: {{ .Values.geoipupdate.account_id | b64enc }}
GEOIPUPDATE_LICENSE_KEY: {{ .Values.geoipupdate.license_key | b64enc }}
{{- end }}
52 changes: 52 additions & 0 deletions charts/geoipupdates/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
suite: default tests
templates:
- deployment.yaml
tests:
- it: should define the default "mirrorbits" deployment with default imagePullPolicy and metadata labels
template: deployment.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/name"]
value: "geoipupdate"
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/instance"]
value: "RELEASE-NAME"
- equal:
path: "spec.template.spec.containers[*].imagePullPolicy"
value: IfNotPresent
- equal:
path: spec.replicas
value: 1
# GeoIP is an emptyDir, with default mountpath
- equal:
path: spec.template.spec.volumes[0].name
value: geoipdata
- equal:
path: spec.template.spec.volumes[0].emptyDir
value: {}
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
value: geoipdata
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /usr/share/GeoIP
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
value: false
# Env. variables
- equal:
path: spec.template.spec.containers[0].env[0].name
value: GEOIPUPDATE_EDITION_IDS
- equal:
path: spec.template.spec.containers[0].env[0].value
value: GeoLite2-ASN GeoLite2-City GeoLite2-Country
- equal:
path: spec.template.spec.containers[0].env[1].name
value: GEOIPUPDATE_FREQUENCY
- equal:
path: spec.template.spec.containers[0].env[1].value
value: "24"
39 changes: 39 additions & 0 deletions charts/geoipupdates/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
image: ghcr.io/maxmind/geoipupdate
imagePullSecrets: []
imagePullPolicy: IfNotPresent
# securityContext:
# Secret values, set to empty below for reference:
geoipupdate:
account_id: ""
license_key: ""
editions: GeoLite2-ASN GeoLite2-City GeoLite2-Country
update_frequency: 24
podSecurityContext: {}
# fsGroup: 2000
containerSecurityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
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: {}

## Defines the geoipdata volume
## Example with a statically provisionned PVC;
# dataVolume:
# persistentVolumeClaim:
# claimName: existing-pvc