Skip to content

Commit

Permalink
build: Add NFS sidecar container to cog-ai-model charts
Browse files Browse the repository at this point in the history
Add new templates for nfsSidecarName, deployment and service.
Configure env, ports, securityContext, resources, livenessProbe and readinessProbe for the nfs sidecar container.
Update values.yaml to include NFS server configuration.
  • Loading branch information
sergiotejon committed Aug 16, 2024
1 parent adf81f4 commit 4d05e92
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
12 changes: 12 additions & 0 deletions charts/cog-ai-model/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,15 @@ Create the secret name for token
{{- default "default" .Values.sidecar.sealedSecrets.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the nfs sidecar container
*/}}
{{- define "cog-ai-model.nfsSidecarName" -}}
{{- if .Values.fullnameOverride }}
{{- printf "%s-%s" .Values.fullnameOverride .Values.nfs.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- printf "%s-%s-%s" .Release.Name $name .Values.nfs.name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/cog-ai-model/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,39 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.nfs.enabled }}
- name: {{ .Values.nfs.name }}
image: "{{ .Values.nfs.image.repository }}:{{ .Values.nfs.image.tag }}"
imagePullPolicy: {{ .Values.nfs.image.pullPolicy }}
{{- with .Values.nfs.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.ports }}
ports:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nfs.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
volumes:
- name: model-data-volume
hostPath:
Expand Down
18 changes: 18 additions & 0 deletions charts/cog-ai-model/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,22 @@ spec:
name: auth
selector:
{{- include "cog-ai-model.selectorLabels" . | nindent 4 }}
{{- end }}
---
{{- if .Values.nfs.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "cog-ai-model.nfsSidecarName" . }}
labels:
{{- include "cog-ai-model.labels" . | nindent 4 }}
spec:
type: {{ .Values.nfs.service.type }}
ports:
- port: {{ .Values.nfs.service.port }}
targetPort: {{ .Values.nfs.service.targetPort }}
protocol: TCP
name: nfs-server
selector:
{{- include "cog-ai-model.selectorLabels" . | nindent 4 }}
{{- end }}
56 changes: 55 additions & 1 deletion charts/cog-ai-model/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,58 @@ sidecar:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
# NFS server configuration default values
# It requeres the environment variable SHARED_DIRECTORY to be set to the directory to be shared.
# Also, it requieres the volume and volumeMounts to be set in the deployment related to the SHARE_DIRECTORY path.
nfs:
enabled: false

name: nfs-server-sidecar

# It must be a valid nginx image with support for template rendering
image:
repository: "itsthenetwork/nfs-server-alpine"
pullPolicy: IfNotPresent
tag: "12"

env: []

securityContext:
capabilities:
add:
- SYS_ADMIN
privileged: true

resources: {}

livenessProbe:
tcpSocket:
port: 2049
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1

readinessProbe:
tcpSocket:
port: 2049
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1

ports:
- name: nfs-server
containerPort: 2049
protocol: TCP

service:
type: ClusterIP
port: 2049
targetPort: 2049

volumeMounts: []

0 comments on commit 4d05e92

Please sign in to comment.