Skip to content

Commit

Permalink
Merge pull request #315 from alercebroker/refactor/lightcurve_charts_…
Browse files Browse the repository at this point in the history
…values

Refactor/lightcurve charts values
  • Loading branch information
AlxEnashi authored Aug 27, 2024
2 parents ffecaeb + 66e6112 commit 5375a27
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cd-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: true
type: string
event:
required: true
required: false
type: string
secrets:
ADMIN_TOKEN:
Expand Down Expand Up @@ -163,6 +163,7 @@ jobs:
CR_TOKEN: "${{ secrets.ADMIN_TOKEN }}"

deploy-production:
if: inputs.event
needs: release-chart
runs-on: ubuntu-latest
permissions:
Expand Down
22 changes: 11 additions & 11 deletions charts/lightcurve/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "lightcurve.name" -}}
{{- define "service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -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 "lightcurve.fullname" -}}
{{- define "service.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,36 +26,36 @@ 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 "lightcurve.chart" -}}
{{- define "service.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "lightcurve.serviceAccountName" -}}
{{- define "service.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "lightcurve.fullname" .) .Values.serviceAccount.name }}
{{- default (include "service.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
14 changes: 8 additions & 6 deletions charts/lightcurve/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
namespace: {{ .Values.namespace }}
data:
port: '{{ .Values.configmap.port }}'
api-url: '{{ .Values.configmap.apiUrl }}'
service: '{{ .Values.configmap.service }}'
---
apiVersion: v1
metadata:
name: lightcurve-nginx-conf
name: {{ include "service.name" . }}-nginx-conf
namespace: {{ .Values.namespace }}
data:
default.conf: '{{ .Values.configmap.nginxConf }}'
default.conf: |
server {
listen 80;
location /v2/lightcurve/ {
location {{ .Values.ingress.path }}/ {
proxy_pass http://localhost:8000/;
proxy_redirect off;
proxy_set_header X-Forwarded-Prefix /v2/lightcurve/;
proxy_set_header X-Forwarded-Prefix {{ .Values.ingress.path }}/;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
}
location /v2/lightcurve {
location {{ .Values.ingress.path }} {
proxy_pass http://localhost:8000/;
proxy_redirect off;
proxy_set_header X-Forwarded-Prefix /v2/lightcurve;
proxy_set_header X-Forwarded-Prefix {{ .Values.ingress.path }};
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
}
Expand Down
19 changes: 12 additions & 7 deletions charts/lightcurve/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "lightcurve.labels" . | nindent 4 }}
{{- include "service.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "lightcurve.selectorLabels" . | nindent 6 }}
{{- include "service.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "lightcurve.selectorLabels" . | nindent 8 }}
{{- include "service.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -35,13 +35,18 @@ spec:
- name: PORT
valueFrom:
configMapKeyRef:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
key: port
- name: API_URL
valueFrom:
configMapKeyRef:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
key: api-url
- name: SERVICE
valueFrom:
configMapKeyRef:
name: {{ include "service.name" . }}
key: service
- name: PSQL_HOST
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -117,7 +122,7 @@ spec:
volumes:
- name: nginx-conf
configMap:
name: lightcurve-nginx-conf
name: {{ include "service.name" . }}-nginx-conf
items:
- key: "default.conf"
path: "default.conf"
Expand Down
6 changes: 3 additions & 3 deletions charts/lightcurve/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "lightcurve.labels" . | nindent 4 }}
{{- include "service.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
4 changes: 2 additions & 2 deletions charts/lightcurve/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ spec:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /v2/lightcurve
- path: {{ .Values.ingress.path }}
pathType: Prefix
backend:
service:
name: lightcurve
name: {{ include "service.name" . }}
port:
number: {{ .Values.service.port }}
6 changes: 3 additions & 3 deletions charts/lightcurve/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "lightcurve.fullname" . }}
name: {{ include "service.name" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "lightcurve.labels" . | nindent 4 }}
{{- include "service.labels" . | nindent 4 }}
annotations:
alb.ingress.kubernetes.io/healthcheck-path: /
prometheus.io/scrape: "true"
Expand All @@ -16,4 +16,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "lightcurve.selectorLabels" . | nindent 4 }}
{{- include "service.selectorLabels" . | nindent 4 }}
4 changes: 4 additions & 0 deletions charts/lightcurve/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ affinity:
## Override this value with the NodeGroup tag accordingly
values: []

nameOverride: ""

configmap:
port: ""
apiUrl: ""
service: ""

ingress:
certificateArn: ""
host: ""
k8sGroupName: ""
k8sTags: ""
path: "" # path without end /

secrets:
secretKey: ""
Expand Down

0 comments on commit 5375a27

Please sign in to comment.