Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoW Faucet #597

Merged
merged 15 commits into from
Aug 25, 2023
Merged
4 changes: 2 additions & 2 deletions charts/tezos-faucet/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ 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: 2.0.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.
appVersion: 1.16.0
appVersion: 2.0.0
27 changes: 19 additions & 8 deletions charts/tezos-faucet/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
{{- if .Values.enableUI }}
apiVersion: v1
data:
config.json: |
{{ .Values.config | mustToPrettyJson | indent 4 }}
kind: ConfigMap
metadata:
name: faucet-config
namespace: {{ .Release.Namespace }}
data:
config.json: |
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
{{- $newProfiles := dict }}
{{- range $key, $value := .Values.profiles }}
{{- $newProfiles = set $newProfiles $key (pick $value "amount" "profile") }}
{{- end }}
{{- $_ := set .Values.config.application "profiles" $newProfiles }}
{{- $_ := set .Values.config.application "disableChallenges" .Values.disableChallenges }}
{{ .Values.config | mustToPrettyJson | indent 4 }}
---
{{- end }}

apiVersion: v1
kind: ConfigMap
metadata:
name: faucet-backend-config
namespace: {{ .Release.Namespace }}
data:
FAUCET_ADDRESS: {{ .Values.config.network.faucetAddress }}
RPC_URL: {{ .Values.config.network.rpcUrl }}
AUTHORIZED_HOST: {{ .Values.authorizedHost }}
FAUCET_AMOUNT_USER: "{{ .Values.config.application.profiles.user.amount}}"
FAUCET_AMOUNT_BAKER: "{{ .Values.config.application.profiles.baker.amount}}"
profiles.json: {{ .Values.profiles | mustToPrettyJson | quote }}

AUTHORIZED_HOST: "{{ .Values.authorizedHost }}"
DISABLE_CHALLENGES: "{{ .Values.disableChallenges }}"
ENABLE_CAPTCHA: "{{ .Values.enableCaptcha }}"
MAX_BALANCE: "{{ .Values.maxBalance }}"
REDIS_URL: "{{ .Values.redis.url }}"
RPC_URL: "{{ .Values.backendRpcUrl | default .Values.config.network.rpcUrl | required "An rpc url is required." }}"
97 changes: 70 additions & 27 deletions charts/tezos-faucet/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,77 @@ spec:
annotations:
# ensure that the pod bounces each time configmap changes
# https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
restartPolicy: Always
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "tezos-faucet.serviceAccountName" . }}
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- image: {{ .Values.images.tezos_faucet_backend }}
name: faucet-backend
ports:
- name: backend
containerPort: 3000
protocol: TCP
envFrom:
- configMapRef:
- name: faucet-backend
image: {{ .Values.images.tezosFaucetBackend }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
ports:
- name: backend
containerPort: 3000
protocol: TCP
envFrom:
- configMapRef:
name: faucet-backend-config
- secretRef:
name: faucet-backend-secret
env:
# profiles.json is stored in faucet-backend-config instead of in a new
# dedicated configmap. We don't need it to be an env var so we make it
# empty here to counteract envFrom.
- name: profiles.json
value: ""
volumeMounts:
- name: faucet-backend-config
mountPath: /app/dist/profiles.json
subPath: profiles.json
readOnly: true
{{- if .Values.enableUI }}
- name: faucet
image: {{ .Values.images.tezosFaucet }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
ports:
- name: frontend
containerPort: 8080
protocol: TCP
volumeMounts:
- name: faucet-config
mountPath: /app/public/config.json
subPath: config.json
readOnly: true
{{- end }}
volumes:
- name: faucet-backend-config
configMap:
name: faucet-backend-config
- secretRef:
name: faucet-backend-secret
- image: {{ .Values.images.tezos_faucet }}
name: faucet
ports:
- name: frontend
containerPort: 8080
protocol: TCP
volumeMounts:
{{- if .Values.enableUI }}
- name: faucet-config
mountPath: "/app/src/config.json"
subPath: "config.json"
readOnly: true
restartPolicy: Always
volumes:
- name: faucet-config
configMap:
name: faucet-config
status: {}
configMap:
name: faucet-config
{{- end }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
42 changes: 20 additions & 22 deletions charts/tezos-faucet/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := "tezos-faucet" -}}
{{- $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}}
Expand All @@ -16,6 +15,7 @@ apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "tezos-faucet.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
Expand All @@ -40,25 +40,23 @@ spec:
- host: {{ .Values.ingress.host | quote }}
http:
paths:
- path: "/info"
pathType: 'Prefix'
backend:
service:
name: {{ $fullName }}
port:
number: 3000
- path: "/send"
pathType: 'Prefix'
backend:
service:
name: {{ $fullName }}
port:
number: 3000
- path: "/"
pathType: 'Prefix'
backend:
service:
name: {{ $fullName }}
port:
number: 8080
{{- range $path := list "/info" "/challenge" "/verify" }}
- path: {{ $path }}
pathType: Exact
backend:
service:
name: {{ $fullName }}
port:
number: 3000
{{- end }}

{{- if .Values.enableUI }}
- path: /
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
number: 8080
{{- end }}
{{- end }}
14 changes: 3 additions & 11 deletions charts/tezos-faucet/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: faucet-secret
namespace: {{ .Release.Namespace }}
data:
recaptcha_keys.json: |
{{ .Values.recaptcha_keys | toJson | b64enc | indent 4 }}
---
apiVersion: v1
kind: Secret
metadata:
name: faucet-backend-secret
namespace: {{ .Release.Namespace }}
data:
FAUCET_PRIVATE_KEY: {{ .Values.faucetPrivateKey | b64enc }}
FAUCET_CAPTCHA_SECRET: {{ .Values.googleCaptchaSecretKey | b64enc }}
CAPTCHA_SECRET: {{ .Values.googleCaptchaSecretKey | b64enc }}
FAUCET_PRIVATE_KEY: {{ required "faucetPrivateKey is required." .Values.faucetPrivateKey | b64enc }}
REDIS_PASSWORD: {{ .Values.redis.password | b64enc }}
6 changes: 4 additions & 2 deletions charts/tezos-faucet/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ metadata:
namespace: {{ .Release.Namespace }}
spec:
type: NodePort
selector:
app: tezos-faucet
ports:
{{- if .Values.enableUI }}
- name: frontend
port: 8080
targetPort: frontend
protocol: TCP
{{- end }}
- name: backend
port: 3000
targetPort: backend
protocol: TCP
selector:
app: tezos-faucet
12 changes: 12 additions & 0 deletions charts/tezos-faucet/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "tezos-faucet.serviceAccountName" . }}
labels:
{{- include "tezos-faucet.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading
Loading