Skip to content

Commit

Permalink
Merge pull request #46 from blockscout/points-merits
Browse files Browse the repository at this point in the history
Rework points chart
  • Loading branch information
alik-agaev authored Nov 12, 2024
2 parents 6ae07b0 + af14837 commit f7b25c7
Show file tree
Hide file tree
Showing 14 changed files with 491 additions and 208 deletions.
2 changes: 1 addition & 1 deletion charts/blockscout-points/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
version: 0.2.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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,147 +1,150 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "blockscout-points.fullname" . }}
name: {{ include "blockscout-points.fullname" . }}-backend
labels:
app: {{ include "blockscout-points.fullname" . }}-backend
{{- include "blockscout-points.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.backend.replicaCount }}
selector:
matchLabels:
app: {{ include "blockscout-points.fullname" . }}-backend
{{- include "blockscout-points.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- if eq .Values.image.pullPolicy "Always" }}
{{- if eq .Values.backend.image.pullPolicy "Always" }}
rollme: {{ randAlphaNum 5 | quote }}
{{- end }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
checksum/config: {{ include (print $.Template.BasePath "/backend-secret.yaml") . | sha256sum }}
{{- with .Values.backend.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "blockscout-points.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
app: {{ include "blockscout-points.fullname" . }}-backend
{{- include "blockscout-points.labels" . | nindent 8 }}-backend
{{- with .Values.backend.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.backend.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "blockscout-points.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.backend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
- name: {{ .Chart.Name }}-backend
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- toYaml .Values.backend.securityContext | nindent 12 }}
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
env:
- name: POINTS_BACKEND__SERVER__HTTP__ENABLED
value: 'true'
- name: POINTS_BACKEND__SERVER__HTTP__ADDR
value: "0.0.0.0:{{ .Values.service.port }}"
value: "0.0.0.0:{{ .Values.backend.service.port }}"
- name: POINTS_BACKEND__DATABASE__CREATE_DATABASE
value: {{ .Values.config.database.createDatabase | quote }}
value: {{ .Values.backend.config.database.createDatabase | quote }}
- name: POINTS_BACKEND__DATABASE__RUN_MIGRATIONS
value: {{ .Values.config.database.runMigrations | quote }}
value: {{ .Values.backend.config.database.runMigrations | quote }}
- name: POINTS_BACKEND__AUTH__ADMIN_API_KEY
valueFrom:
secretKeyRef:
name: {{ include "blockscout-points.fullname" . }}-config
name: {{ include "blockscout-points.fullname" . }}-backend-config
key: adminApiKey
- name: POINTS_BACKEND__AUTH__SECRET
valueFrom:
secretKeyRef:
name: {{ include "blockscout-points.fullname" . }}-config
name: {{ include "blockscout-points.fullname" . }}-backend-config
key: jwtSecret
{{- if .Values.config.grpc.enabled }}
{{- if .Values.backend.config.grpc.enabled }}
- name: POINTS_BACKEND__SERVER__GRPC__ENABLED
value: 'true'
- name: POINTS_BACKEND__SERVER__GRPC__ADDR
value: 0.0.0.0:{{ .Values.config.grpc.port }}
value: 0.0.0.0:{{ .Values.backend.config.grpc.port }}
{{- end }}
{{- if .Values.metrics.enabled }}
{{- if .Values.backend.metrics.enabled }}
- name: POINTS_BACKEND__METRICS__ENABLED
value: 'true'
{{- end }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__HOST
value: {{ .Values.config.database.host | quote }}
value: {{ .Values.backend.config.database.host | quote }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__PORT
value: {{ .Values.config.database.port | quote }}
value: {{ .Values.backend.config.database.port | quote }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__DBNAME
value: {{ .Values.config.database.db | quote }}
{{- if not .Values.config.database.existingSecret }}
value: {{ .Values.backend.config.database.db | quote }}
{{- if not .Values.backend.config.database.existingSecret }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__USER
valueFrom:
secretKeyRef:
name: {{ include "blockscout-points.fullname" . }}-config
name: {{ include "blockscout-points.fullname" . }}-backend-config
key: username
- name: postgres_pass
valueFrom:
secretKeyRef:
name: {{ include "blockscout-points.fullname" . }}-config
name: {{ include "blockscout-points.fullname" . }}-backend-config
key: password
{{- else }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__USER
valueFrom:
secretKeyRef:
name: {{ .Values.config.database.existingSecret }}
key: {{ .Values.config.database.existingSecretUsernameKey }}
name: {{ .Values.backend.config.database.existingSecret }}
key: {{ .Values.backend.config.database.existingSecretUsernameKey }}
- name: POINTS_BACKEND__DATABASE__CONNECT__KV__PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.config.database.existingSecret }}
key: {{ .Values.config.database.existingSecretPasswordKey }}
name: {{ .Values.backend.config.database.existingSecret }}
key: {{ .Values.backend.config.database.existingSecretPasswordKey }}
{{- end }}
{{- range $key, $value := .Values.env }}
{{- range $key, $value := .Values.backend.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.envFromSecret }}
{{- if .Values.backend.envFromSecret }}
envFrom:
- secretRef:
name: {{ include "blockscout-points.fullname" . }}-env
name: {{ include "blockscout-points.fullname" . }}-backend-env
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: {{ .Values.backend.service.port }}
protocol: TCP
{{- if .Values.config.grpc.enabled }}
{{- if .Values.backend.config.grpc.enabled }}
- name: grpc
containerPort: {{ .Values.config.grpc.port }}
containerPort: {{ .Values.backend.config.grpc.port }}
protocol: TCP
{{- end}}
{{- if .Values.metrics.enabled }}
{{- if .Values.backend.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.metrics.port }}
containerPort: {{ .Values.backend.metrics.port }}
protocol: TCP
{{- end }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
{{- toYaml .Values.backend.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
{{- toYaml .Values.backend.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
{{- toYaml .Values.backend.resources | nindent 12 }}
{{- with .Values.backend.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
{{- with .Values.backend.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
{{- with .Values.backend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .Values.backend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .Values.backend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.backend.ingress.enabled -}}
{{- $fullName := include "blockscout-points.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") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- $svcPort := .Values.backend.service.port -}}
{{- if and .Values.backend.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.backend.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.backend.ingress.annotations "kubernetes.io/ingress.class" .Values.backend.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
Expand All @@ -15,20 +15,20 @@ apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
name: {{ $fullName }}-backend
labels:
{{- include "blockscout-points.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
{{- with .Values.backend.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- if and .Values.backend.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.backend.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
{{- if .Values.backend.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
{{- range .Values.backend.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
Expand All @@ -37,7 +37,7 @@ spec:
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- range .Values.backend.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
Expand All @@ -49,11 +49,11 @@ spec:
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
name: {{ $fullName }}-backend
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
serviceName: {{ $fullName }}-backend
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
Expand Down
28 changes: 28 additions & 0 deletions charts/blockscout-points/templates/backend-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.backend.envFromSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "blockscout-points.fullname" . }}-backend-env
labels:
{{- include "blockscout-points.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := .Values.backend.envFromSecret }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "blockscout-points.fullname" . }}-backend-config
labels:
{{- include "blockscout-points.labels" . | nindent 4 }}
type: Opaque
data:
adminApiKey: {{ .Values.backend.config.auth.adminApiKey | b64enc | quote }}
jwtSecret: {{ .Values.backend.config.auth.jwtSecret | b64enc | quote }}
{{- if not .Values.backend.config.database.existingSecret }}
username: {{ .Values.backend.config.database.user | b64enc | quote }}
password: {{ .Values.backend.config.database.pass | b64enc | quote }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/blockscout-points/templates/backend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "blockscout-points.fullname" . }}-backend
labels:
app: {{ include "blockscout-points.fullname" . }}-backend
{{- include "blockscout-points.labels" . | nindent 4 }}
spec:
type: {{ .Values.backend.service.type }}
ports:
- port: {{ .Values.backend.service.port }}
targetPort: http
protocol: TCP
name: http
{{- if .Values.backend.config.grpc.enabled }}
- port: {{ .Values.backend.config.grpc.port }}
targetPort: grpc
protocol: TCP
name: grpc
{{- end}}
{{- if .Values.backend.metrics.enabled }}
- port: {{ .Values.backend.metrics.port }}
targetPort: metrics
protocol: TCP
name: metrics
{{- end }}
selector:
app: {{ include "blockscout-points.fullname" . }}-backend
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{- if and .Values.metrics.enabled .Values.metrics.prometheus.enabled }}
{{- if and .Values.backend.metrics.enabled .Values.backend.metrics.prometheus.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "blockscout-points.fullname" . }}
name: {{ include "blockscout-points.fullname" . }}-backend
labels:
{{- include "blockscout-points.labels" . | nindent 4 }}
spec:
Expand All @@ -12,5 +12,5 @@ spec:
path: /metrics
selector:
matchLabels:
app.kubernetes.io/name: {{ include "blockscout-points.fullname" . }}
app.kubernetes.io/name: {{ include "blockscout-points.fullname" . }}-backend
{{- end }}
Loading

0 comments on commit f7b25c7

Please sign in to comment.