This commit is contained in:
Damien Ostler 2024-02-08 22:45:35 -05:00
parent 04a1a6c290
commit 479dcd7be9
10 changed files with 95 additions and 108 deletions

View File

@ -1,5 +1,5 @@
apiVersion: v2
name: search
name: core-api
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
@ -21,4 +21,4 @@ version: 0.1.0
# 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: "latest"
appVersion: "1.16.0"

View File

@ -1,22 +0,0 @@
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 "search.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 "search.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "search.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 "search.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 }}

View File

@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "search.name" -}}
{{- define "core-api.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
@ -10,7 +10,7 @@ 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 "search.fullname" -}}
{{- define "core-api.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "search.chart" -}}
{{- define "core-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "search.labels" -}}
helm.sh/chart: {{ include "search.chart" . }}
{{ include "search.selectorLabels" . }}
{{- define "core-api.labels" -}}
helm.sh/chart: {{ include "core-api.chart" . }}
{{ include "core-api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "search.selectorLabels" -}}
app.kubernetes.io/name: {{ include "search.name" . }}
{{- define "core-api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "core-api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "search.serviceAccountName" -}}
{{- define "core-api.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "search.fullname" .) .Values.serviceAccount.name }}
{{- default (include "core-api.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}

View File

@ -1,16 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "search.fullname" . }}
name: {{ include "core-api.fullname" . }}
labels:
{{- include "search.labels" . | nindent 4 }}
{{- include "core-api.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "search.selectorLabels" . | nindent 6 }}
{{- include "core-api.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
@ -18,13 +18,16 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "search.selectorLabels" . | nindent 8 }}
{{- include "core-api.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "search.serviceAccountName" . }}
serviceAccountName: {{ include "core-api.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
@ -33,55 +36,24 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: NEXT_PUBLIC_MUI_X_LICENSE_KEY
value: {{ .Values.mui_x_license }}
{{- with .Values.keycloak }}
- name: KEYCLOAK_ID
value: '{{ .client_id }}'
- name: KEYCLOAK_SECRET
value: '{{ .client_secret }}'
- name: KEYCLOAK_ISSUER
value: '{{ .client_issuer }}'
{{- end }}
- name: NEXTAUTH_URL
value: '{{ .Values.nextauth.url }}'
{{- with .Values.dim }}
- name: API_GATEWAY
value: '{{ .gateway }}'
- name: DOCUMENT_STREAM_API
value: '{{ .stream_api }}'
- name: DOCUMENT_PREVIEW_API
value: '{{ .preview_api }}'
{{- end }}
{{- with .Values.solr }}
- name: ZK_HOST
value: '{{ .zkHost }}'
- name: SOLR_HOST_OVERRIDE
value: '{{ .solr_host_override }}'
- name: SOLR_USER
{{- toYaml .basicAuth.usernameValue | nindent 12 }}
- name: SOLR_PASS
{{- toYaml .basicAuth.passwordValue | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
httpGet:
path: /
port: http
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@ -2,14 +2,14 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "search.fullname" . }}
name: {{ include "core-api.fullname" . }}
labels:
{{- include "search.labels" . | nindent 4 }}
{{- include "core-api.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "search.fullname" . }}
name: {{ include "core-api.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
@ -29,4 +29,4 @@ spec:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "search.fullname" . -}}
{{- $fullName := include "core-api.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
@ -17,7 +17,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "search.labels" . | nindent 4 }}
{{- include "core-api.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
@ -58,4 +58,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "search.fullname" . }}
name: {{ include "core-api.fullname" . }}
labels:
{{- include "search.labels" . | nindent 4 }}
{{- include "core-api.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "search.selectorLabels" . | nindent 4 }}
{{- include "core-api.selectorLabels" . | nindent 4 }}

View File

@ -2,11 +2,12 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "search.serviceAccountName" . }}
name: {{ include "core-api.serviceAccountName" . }}
labels:
{{- include "search.labels" . | nindent 4 }}
{{- include "core-api.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "core-api.fullname" . }}-test-connection"
labels:
{{- include "core-api.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "core-api.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View File

@ -1,22 +1,24 @@
# Default values for search.
# Default values for core-api.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: docker pull ghcr.io/comissions-app/core-api
repository: ghcr.io/comissions-app/core-api
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
imagePullSecrets: ["comissions-app"]
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
@ -24,13 +26,12 @@ serviceAccount:
name: ""
podAnnotations: {}
podLabels: {}
podSecurityContext:
{}
podSecurityContext: {}
# fsGroup: 2000
securityContext:
{}
securityContext: {}
# capabilities:
# drop:
# - ALL
@ -40,17 +41,16 @@ securityContext:
service:
type: ClusterIP
port: 3000
port: 80
ingress:
enabled: false
enabled: true
className: ""
annotations:
{}
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
- host: core-api.comissions.dev
paths:
- path: /
pathType: ImplementationSpecific
@ -59,8 +59,7 @@ ingress:
# hosts:
# - chart-example.local
resources:
{}
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
@ -72,6 +71,15 @@ resources:
# cpu: 100m
# memory: 128Mi
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
autoscaling:
enabled: false
minReplicas: 1
@ -79,8 +87,21 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false
# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
nodeSelector: {}
tolerations: []
affinity: {}
affinity: {}