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(geoipupdater): provide a cronjob for update geoip #1443

Merged
merged 1 commit into from
Nov 26, 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
2 changes: 1 addition & 1 deletion charts/geoipupdates/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
description: MaxMind GeoIP database updater
name: geoipupdates
version: 0.1.0
version: 1.0.0
appVersion: "v7.1.0"
maintainers:
- email: [email protected]
Expand Down
62 changes: 62 additions & 0 deletions charts/geoipupdates/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "geoipupdate.fullname" . }}
labels:
{{ include "geoipupdate.labels" . | indent 4 }}
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.geoipupdate.cron }}
jobTemplate:
spec:
template:
spec:
serviceAccountName: {{ include "geoipupdate.fullname" . }}
restartPolicy: Never
containers:
- name: geoipupdate
image: "{{ .Values.image }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- with .Values.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 16 }}
{{- end }}
volumeMounts:
- name: geoipdata
mountPath: /usr/share/GeoIP
readOnly: false
- name: tmpdir
mountPath: /tmp
readOnly: false
resources:
{{- toYaml .Values.resources | nindent 16 }}
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 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: geoipdata
{{- if .Values.dataVolume }}
{{- toYaml .Values.dataVolume | nindent 14 }}
{{- else }}
emptyDir: {}
{{- end }}
- name: tmpdir
emptyDir:
medium: "Memory"
74 changes: 0 additions & 74 deletions charts/geoipupdates/templates/deployment.yaml

This file was deleted.

35 changes: 16 additions & 19 deletions charts/geoipupdates/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
suite: default tests
templates:
- deployment.yaml
- cronjob.yaml
tests:
- it: should define the default "mirrorbits" deployment with default imagePullPolicy and metadata labels
template: deployment.yaml
- it: should define the default "geoipupdate" cronjob with default imagePullPolicy and metadata labels
template: cronjob.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: CronJob
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/name"]
path: metadata.labels["app.kubernetes.io/name"]
value: "geoipupdate"
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/instance"]
path: metadata.labels["app.kubernetes.io/instance"]
value: "RELEASE-NAME"
- equal:
path: "spec.template.spec.containers[*].imagePullPolicy"
path: "spec.jobTemplate.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
path: spec.jobTemplate.spec.template.spec.volumes[0].name
value: geoipdata
- equal:
path: spec.template.spec.volumes[0].emptyDir
path: spec.jobTemplate.spec.template.spec.volumes[0].emptyDir
value: {}
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
path: spec.jobTemplate.spec.template.spec.containers[0].volumeMounts[0].name
value: geoipdata
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
path: spec.jobTemplate.spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /usr/share/GeoIP
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
path: spec.jobTemplate.spec.template.spec.containers[0].volumeMounts[0].readOnly
value: false
# Env. variables
- equal:
path: spec.template.spec.containers[0].env[0].name
path: spec.jobTemplate.spec.template.spec.containers[0].env[0].name
value: GEOIPUPDATE_EDITION_IDS
- equal:
path: spec.template.spec.containers[0].env[0].value
path: spec.jobTemplate.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
path: spec.jobTemplate.spec.template.spec.containers[0].env[1].name
value: GEOIPUPDATE_FREQUENCY
- equal:
path: spec.template.spec.containers[0].env[1].value
path: spec.jobTemplate.spec.template.spec.containers[0].env[1].value
value: "24"
1 change: 1 addition & 0 deletions charts/geoipupdates/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ geoipupdate:
license_key: ""
editions: GeoLite2-ASN GeoLite2-City GeoLite2-Country
update_frequency: 24
cron: '0 4 * * *' # default to every day at 4AM
podSecurityContext: {}
# fsGroup: 2000
containerSecurityContext: {}
Expand Down