Skip to content

Commit

Permalink
do not log + helm
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Nov 11, 2024
1 parent d8b3435 commit b9c5be3
Show file tree
Hide file tree
Showing 21 changed files with 784 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .helm/adhoc/cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: siibra-jugex-certificate
spec:
isCA: false
commonName: siibra-jugex.apps.tc.humanbrainproject.eu
dnsNames:
- siibra-jugex.apps.tc.humanbrainproject.eu
issuerRef:
kind: ClusterIssuer
name: letsencrypt-production-issuer-1
privateKey:
algorithm: RSA
encoding: PKCS1
size: 2048
renewBefore: 120h0m0s
secretName: siibra-jugex-prod-secret
usages:
- server auth
---

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: neurogenpy-certificate
spec:
isCA: false
commonName: ngpy.apps.hbp.eu
dnsNames:
- ngpy.apps.hbp.eu
issuerRef:
kind: ClusterIssuer
name: letsencrypt-production-issuer-1
privateKey:
algorithm: RSA
encoding: PKCS1
size: 2048
renewBefore: 120h0m0s
secretName: neurogenpy-prod-secret
usages:
- server auth
10 changes: 10 additions & 0 deletions .helm/adhoc/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: jugex-toolbox
data:
SIIBRA_TOOLBOX_LOG_DIR: /siibra-tool-log
SIIBRA_TOOLBOX_DATA_DIR: /siibra-tool-data
SIIBRA_JURGEX_CELERY_BROKER: redis://redis:6379
SIIBRA_JURGEX_CELERY_RESULT: redis://redis:6379
SIIBRA_CACHEDIR: /siibra-tool-data/tmp
30 changes: 30 additions & 0 deletions .helm/adhoc/cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-trim-old-log-usage
spec:
# run two month
schedule: "41 1 */5 */2 *"
concurrencyPolicy: Replace
jobTemplate:
spec:
template:
spec:
containers:
- name: cronjob-trim-old-log-usage
image: docker-registry.ebrains.eu/monitoring/kubectl:v1.29.2
imagePullPolicy: Always
command:
- /bin/ash
- -c
# delete all files over 30 days of modification date
- "find /siibra-tool-log -mindepth 1 -maxdepth 1 -mtime +30 -delete"
volumeMounts:
- mountPath: /siibra-tool-log
name: log-volume

restartPolicy: OnFailure
volumes:
- name: log-volume
persistentVolumeClaim:
claimName: log-volume-claim-2
60 changes: 60 additions & 0 deletions .helm/adhoc/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: redis
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: redis
spec:
containers:
- image: docker-registry.ebrains.eu/monitoring/redis:alpine3.17
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- redis-cli
- ping
failureThreshold: 3
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 1
name: redis
ports:
- containerPort: 6379
protocol: TCP
readinessProbe:
exec:
command:
- redis-cli
- ping
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 200m
memory: 1Gi
requests:
cpu: 100m
memory: 128Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
33 changes: 33 additions & 0 deletions .helm/adhoc/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jugex-toolbox
spec:
rules:
- host: siibra-jugex.apps.tc.humanbrainproject.eu
http:
paths:
- backend:
service:
name: jugex-toolbox
port:
number: 6001
path: /
pathType: ImplementationSpecific
- host: ngpy.apps.hbp.eu
http:
paths:
- backend:
service:
name: neurogenpy-toolbox
port:
number: 6001
path: /
pathType: ImplementationSpecific
tls:
- hosts:
- siibra-jugex.apps.tc.humanbrainproject.eu
secretName: siibra-jugex-prod-secret
- hosts:
- ngpy.apps.hbp.eu
secretName: neurogenpy-prod-secret
27 changes: 27 additions & 0 deletions .helm/adhoc/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
type: longhorn-pvc
name: data-volume-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 16Gi
storageClassName: longhorn-1
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
type: longhorn-pvc
name: log-volume-claim-2
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 4Gi
storageClassName: longhorn-1
14 changes: 14 additions & 0 deletions .helm/adhoc/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: redis
name: redis
spec:
ports:
- port: 6379
protocol: TCP
targetPort: 6379
selector:
app: redis
type: ClusterIP
16 changes: 16 additions & 0 deletions .helm/deploy_neurogenpy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

SERVER_IMG="docker-registry.ebrains.eu/siibra-toolbox/neurogenpy"
WORKER_IMG="docker-registry.ebrains.eu/siibra-toolbox/neurogenpy"
SERVER_TAG="server"
WORKER_TAG="worker"

helm install neurogenpy ./toolbox \
--set image.serverRepository=$SERVER_IMG \
--set image.workerRepository=$WORKER_IMG \
--set image.serverTag=$SERVER_TAG \
--set image.workerTag=$WORKER_TAG \
--set workerResources.limits.memory=4Gi \
--set envObj.NEUROGENPY_CELERY_BROKER=redis://redis:6379 \
--set envObj.NEUROGENPY_CELERY_RESULT=redis://redis:6379

23 changes: 23 additions & 0 deletions .helm/toolbox/.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 .helm/toolbox/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: toolbox
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: 0.1.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: "0.0.2"
22 changes: 22 additions & 0 deletions .helm/toolbox/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "toolbox.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "toolbox.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "toolbox.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "toolbox.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions .helm/toolbox/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "toolbox.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 "toolbox.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 "toolbox.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

0 comments on commit b9c5be3

Please sign in to comment.