diff --git a/deploy/coins/bitcoin/scripts/entry-dev.sh b/deploy/coins/bitcoin/scripts/entry-dev.sh index 1ae37017..ad7583f5 100644 --- a/deploy/coins/bitcoin/scripts/entry-dev.sh +++ b/deploy/coins/bitcoin/scripts/entry-dev.sh @@ -13,8 +13,8 @@ bitcoind -regtest -txindex -fallbackfee=0.000001 -rpcuser=$RPC_USER -rpcpassword # give time to bitcoind to start while true do - bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS generatetoaddress 100 $MINER && break - sleep 5 + bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS generatetoaddress 100 $MINER && break + sleep 5 done bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS createwallet "miner" false false $RPC_PASS false false true && @@ -24,6 +24,6 @@ bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS importprivkey $PR # mine a new block every BLOCK_TIME while true do - bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS generatetoaddress 1 $MINER - sleep $BLOCK_TIME + bitcoin-cli -regtest -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS generatetoaddress 1 $MINER + sleep $BLOCK_TIME done diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 5e3f2b4c..ff371db3 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -8,7 +8,7 @@ name: serai-dev # coins - node clients for coins only (BTC, ETH, XMR) # cluster-sm - Alice, Bob, Charlie # cluster-coins-sm - cluster-sm with coins - # cluter-lg - Alice, Bob, Charlie, Dave, Eve, Ferdie + # cluster-lg - Alice, Bob, Charlie, Dave, Eve, Ferdie # cluster-coins-lg - cluster-lg with coins # monero - full node monero only # bitcoin - full node bitcoin only @@ -42,7 +42,6 @@ services: - "./serai/scripts:/scripts" serai-base: - &serai <<: *serai_defaults hostname: serai-base profiles: @@ -52,7 +51,6 @@ services: NAME: base serai-alice: - &serai <<: *serai_defaults hostname: serai-alice profiles: @@ -67,7 +65,6 @@ services: VALIDATOR: true serai-bob: - &serai <<: *serai_defaults hostname: serai-bob profiles: @@ -81,7 +78,6 @@ services: NAME: Bob serai-charlie: - &serai <<: *serai_defaults hostname: serai-charlie profiles: @@ -95,7 +91,6 @@ services: NAME: Charlie serai-dave: - &serai <<: *serai_defaults hostname: serai-dave profiles: @@ -107,7 +102,6 @@ services: NAME: Dave serai-eve: - &serai <<: *serai_defaults hostname: serai-eve profiles: @@ -119,7 +113,6 @@ services: NAME: Eve serai-ferdie: - &serai <<: *serai_defaults hostname: serai-ferdie profiles: @@ -171,6 +164,5 @@ services: context: ./coins/monero/ restart: unless-stopped volumes: - - "./coins/monero/temp:/temp" - "./coins/monero/scripts:/scripts" entrypoint: /scripts/entry-dev.sh diff --git a/deploy/kubernetes/Makefile b/deploy/kubernetes/Makefile new file mode 100644 index 00000000..f2c40572 --- /dev/null +++ b/deploy/kubernetes/Makefile @@ -0,0 +1,103 @@ +SHELL := /bin/bash + +check-helm: + @helm version || $(MAKE) install-helm + +check-kubectl: + @kubectl version || $(MAKE) install-kubectl + +install-helm: + @curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + @chmod 700 get_helm.sh + @./get_helm.sh + @rm get_helm.sh + +install-kubectl: + @curl -LO 'https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl' + @sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + @rm kubectl + +deploy-base: + @docker compose -f ../docker-compose.yml --profile base build --quiet + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-base charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-base,nameOverride=serai-base,\ + image.envVariables[1].value=base,configMapFile=% + +deploy-bitcoin: + @docker compose -f ../docker-compose.yml --profile bitcoin build --quiet + @(cat ../coins/bitcoin/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install bitcoin-daemon\ + charts/bitcoin/ --values charts/bitcoin/values.yaml --set configMapFile=% + +deploy-ethereum: + @docker compose -f ../docker-compose.yml --profile ethereum build --quiet + @(cat ../coins/ethereum/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install ethereum-daemon\ + charts/ethereum/ --values charts/ethereum/values.yaml --set configMapFile=% + +deploy-monero: + @docker compose -f ../docker-compose.yml --profile monero build --quiet + @(cat ../coins/monero/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install monero-daemon\ + charts/monero/ --values charts/monero/values.yaml --set configMapFile=% + +deploy-cluster-sm: + @docker compose -f ../docker-compose.yml --profile cluster-sm build --quiet + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-alice charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-alice,nameOverride=serai-alice,\ + image.envVariables[1].value=Alice,image.envVariables[2].value="'1'",configMapFile=% + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-charlie charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-charlie,nameOverride=serai-charlie,\ + image.envVariables[1].value=Charlie,configMapFile=% + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-bob charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-bob,nameOverride=serai-bob,\ + image.envVariables[1].value=Bob,configMapFile=% + +deploy-cluster-lg: deploy-cluster-sm + @docker compose -f ../docker-compose.yml --profile cluster-lg build --quiet + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-dave charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-dave,nameOverride=serai-dave,\ + image.envVariables[1].value=Dave,configMapFile=% + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-eve charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-eve,nameOverride=serai-eve,\ + image.envVariables[1].value=Eve,configMapFile=% + @(cat ../serai/scripts/entry-dev.sh | base64 -w 0 -) | xargs -I % helm upgrade --install serai-ferdie charts/serai/\ + --values charts/serai/values.yaml --set image.envVariablesfullnameOverride=serai-ferdie,nameOverride=serai-ferdie,\ + image.envVariables[1].value=Ferdie,configMapFile=% + +deploy-coins: deploy-bitcoin deploy-ethereum deploy-monero + +deploy-cluster-coins-sm: deploy-cluster-sm deploy-coins + +deploy-cluster-coins-lg: deploy-cluster-lg deploy-coins + +deploy-all: deploy-cluster-coins-lg + +delete-base: + @helm delete serai-base + +delete-bitcoin: + @helm delete bitcoin-daemon + +delete-ethereum: + @helm delete ethereum-daemon + +delete-monero: + @helm delete monero-daemon + +delete-cluster-lg: delete-cluster-sm + @helm delete serai-dave + @helm delete serai-eve + @helm delete serai-ferdie + +delete-cluster-sm: + @helm delete serai-alice + @helm delete serai-charlie + @helm delete serai-bob + +delete-coins: delete-bitcoin delete-ethereum delete-monero + +delete-cluster-coins-sm: delete-cluster-sm delete-coins + +delete-cluster-coins-lg: delete-cluster-lg delete-coins + +delete-all: delete-cluster-coins-lg + +check-dependencies: check-helm check-kubectl diff --git a/deploy/kubernetes/README.md b/deploy/kubernetes/README.md new file mode 100644 index 00000000..7bf68d9e --- /dev/null +++ b/deploy/kubernetes/README.md @@ -0,0 +1,41 @@ +# Kubernetes +## Run with Kubernetes +Running the Serai infrastructure is easy with Kubernetes. + +We utilize Makefile to easily orchestrate various pieces of the infrastructure on kubernetes. + +**Example to deploy:** `make deploy-` +```bash +make deploy-cluster-sm +``` +**Example to delete:** `make -i delete-` +```bash +make delete-cluster-sm +``` + +All commands are assumed to be ran from the kubernetes folder, not the serai root folder. + +### Profiles: +* deploy-base - single node, named base +* deploy-coins - node clients for coins only (BTC, ETH, XMR) +* deploy-cluster-sm - Alice (Validator), Bob, Charlie +* deploy-cluster-coins-sm - cluster-sm with coins +* deploy-cluster-lg - Alice (Validator), Bob, Charlie, Dave, Eve, Ferdie +* deploy-cluster-coins-lg - cluster-lg with coins +* deploy-monero - full node monero only +* deploy-bitcoin - full node bitcoin only +* deploy-ethereum - full node ethereum only + +## Requirements for Linux +* Local built images of serai and coins, please follow the Instructions [here](../README.md) +* Running kubernetes cluster (version >= 1.19) +* Curl tool +* Make tool +* Kubectl, check if not installed +```bash +make check-kubectl +``` +* Helm, check if not installed +```bash +make check-helm +``` diff --git a/deploy/kubernetes/charts/bitcoin/Chart.yaml b/deploy/kubernetes/charts/bitcoin/Chart.yaml new file mode 100644 index 00000000..3824b0e4 --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: bitcoin +description: A Helm chart for bitcoin-daemon +type: application +version: 0.1.0 diff --git a/deploy/kubernetes/charts/bitcoin/templates/_helpers.tpl b/deploy/kubernetes/charts/bitcoin/templates/_helpers.tpl new file mode 100644 index 00000000..17b464a4 --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{- define "bitcoin.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "bitcoin.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 253 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "bitcoin.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "bitcoin.labels" -}} +helm.sh/chart: {{ include "bitcoin.chart" . }} +{{ include "bitcoin.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "bitcoin.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bitcoin.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "bitcoin.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bitcoin.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/bitcoin/templates/configmap.yaml b/deploy/kubernetes/charts/bitcoin/templates/configmap.yaml new file mode 100644 index 00000000..bf550200 --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + entry-dev.sh: | +{{ .Values.configMapFile | b64dec | indent 4}} diff --git a/deploy/kubernetes/charts/bitcoin/templates/deployment.yaml b/deploy/kubernetes/charts/bitcoin/templates/deployment.yaml new file mode 100644 index 00000000..f852a96e --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bitcoin.fullname" . }} + labels: + {{- include "bitcoin.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bitcoin.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bitcoin.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bitcoin.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if hasKey .Values.image "ports" }} + ports: + {{- range .Values.image.ports }} + - name: {{ .name }} + containerPort: {{ .containerPort }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "command" }} + command: + {{- toYaml .Values.image.command | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "args" }} + args: + {{- toYaml .Values.image.args | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "envVariables" }} + env: + {{- toYaml .Values.image.envVariables | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "volumeMounts" }} + volumeMounts: + {{- range .Values.image.volumeMounts }} + - mountPath: {{ .mountPath }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- 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 }} + {{- if hasKey .Values "volumes" }} + volumes: + {{- range .Values.volumes }} + - configMap: + defaultMode: {{ .configMap.defaultMode }} + name: {{ $.Release.Name}}-{{ .configMap.name }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- end }} diff --git a/deploy/kubernetes/charts/bitcoin/templates/ingress.yaml b/deploy/kubernetes/charts/bitcoin/templates/ingress.yaml new file mode 100644 index 00000000..39dff21c --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/templates/ingress.yaml @@ -0,0 +1,50 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "bitcoin.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}} + {{- end }} +{{- end }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "bitcoin.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if .pathType }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/bitcoin/templates/service.yaml b/deploy/kubernetes/charts/bitcoin/templates/service.yaml new file mode 100644 index 00000000..e5fc600f --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/templates/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bitcoin.fullname" . }} + labels: + {{- include "bitcoin.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- if hasKey .Values.service "ports" }} + {{- range .Values.service.ports }} + - port: {{ .port }} + name: {{ .name }} + targetPort: {{ .targetPort }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- end }} + selector: + {{- include "bitcoin.selectorLabels" . | nindent 4 }} diff --git a/deploy/kubernetes/charts/bitcoin/values.yaml b/deploy/kubernetes/charts/bitcoin/values.yaml new file mode 100644 index 00000000..54bb0462 --- /dev/null +++ b/deploy/kubernetes/charts/bitcoin/values.yaml @@ -0,0 +1,74 @@ +replicaCount: 1 + +net: mainnet + +image: + repository: serai-dev-bitcoin + pullPolicy: IfNotPresent + tag: "latest" + ports: + - name: p2p + containerPort: 18444 + protocol: TCP + - name: rpc + containerPort: 18443 + protocol: TCP + volumeMounts: + - mountPath: /scripts + name: configmap-volume + args: + - bash + - /scripts/entry-dev.sh + +volumes: + - configMap: + defaultMode: 420 + name: configmap + name: configmap-volume + +configMapFile: "entry-dev.sh" + +imagePullSecrets: [] + +serviceAccount: + create: false + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + ports: + - name: p2p + port: 18444 + targetPort: p2p + protocol: TCP + - name: rpc + port: 18443 + targetPort: rpc + protocol: TCP + +ingress: + enabled: false + className: "" + annotations: {} + hosts: [] + tls: [] + +resources: {} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deploy/kubernetes/charts/ethereum/Chart.yaml b/deploy/kubernetes/charts/ethereum/Chart.yaml new file mode 100644 index 00000000..31594044 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: ethereum +description: A Helm chart for ethereum-daemon +type: application +version: 0.1.0 diff --git a/deploy/kubernetes/charts/ethereum/templates/_helpers.tpl b/deploy/kubernetes/charts/ethereum/templates/_helpers.tpl new file mode 100644 index 00000000..ab9b2fc9 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{- define "ethereum.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "ethereum.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 253 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "ethereum.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "ethereum.labels" -}} +helm.sh/chart: {{ include "ethereum.chart" . }} +{{ include "ethereum.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "ethereum.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ethereum.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "ethereum.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ethereum.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/ethereum/templates/configmap.yaml b/deploy/kubernetes/charts/ethereum/templates/configmap.yaml new file mode 100644 index 00000000..bf550200 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + entry-dev.sh: | +{{ .Values.configMapFile | b64dec | indent 4}} diff --git a/deploy/kubernetes/charts/ethereum/templates/deployment.yaml b/deploy/kubernetes/charts/ethereum/templates/deployment.yaml new file mode 100644 index 00000000..b673ba12 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/templates/deployment.yaml @@ -0,0 +1,89 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ethereum.fullname" . }} + labels: + {{- include "ethereum.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "ethereum.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ethereum.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "ethereum.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if hasKey .Values.image "ports" }} + ports: + {{- range .Values.image.ports }} + - name: {{ .name }} + containerPort: {{ .containerPort }} + protocol: {{ .protocol }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "command" }} + command: + {{- toYaml .Values.image.command | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "args" }} + args: + {{- toYaml .Values.image.args | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "envVariables" }} + env: + {{- toYaml .Values.image.envVariables | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "volumeMounts" }} + volumeMounts: + {{- range .Values.image.volumeMounts }} + - mountPath: {{ .mountPath }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- 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 }} + {{- if hasKey .Values "volumes" }} + volumes: + {{- range .Values.volumes }} + - configMap: + defaultMode: {{ .configMap.defaultMode }} + name: {{ $.Release.Name}}-{{ .configMap.name }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- end }} diff --git a/deploy/kubernetes/charts/ethereum/templates/ingress.yaml b/deploy/kubernetes/charts/ethereum/templates/ingress.yaml new file mode 100644 index 00000000..18dcd185 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/templates/ingress.yaml @@ -0,0 +1,50 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "ethereum.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}} + {{- end }} +{{- end }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "ethereum.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if .pathType }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/ethereum/templates/service.yaml b/deploy/kubernetes/charts/ethereum/templates/service.yaml new file mode 100644 index 00000000..df83df17 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/templates/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "ethereum.fullname" . }} + labels: + {{- include "ethereum.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- if hasKey .Values.service "ports" }} + {{- range .Values.service.ports }} + - port: {{ .port }} + name: {{ .name }} + targetPort: {{ .targetPort }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- end }} + selector: + {{- include "ethereum.selectorLabels" . | nindent 4 }} diff --git a/deploy/kubernetes/charts/ethereum/values.yaml b/deploy/kubernetes/charts/ethereum/values.yaml new file mode 100644 index 00000000..cef45a09 --- /dev/null +++ b/deploy/kubernetes/charts/ethereum/values.yaml @@ -0,0 +1,60 @@ +replicaCount: 1 + +image: + repository: serai-dev-ethereum + pullPolicy: IfNotPresent + tag: "latest" + + ports: + - name: rpc + containerPort: 8545 + protocol: TCP + volumeMounts: + - mountPath: /scripts + name: configmap-volume + args: + - bash + - /scripts/entry-dev.sh + +volumes: + - configMap: + defaultMode: 420 + name: configmap + name: configmap-volume + +configMapFile: "entry-dev.sh" + +imagePullSecrets: [] + +serviceAccount: + create: false + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + port: 8545 + +ingress: + enabled: false + className: "" + annotations: {} + hosts: [] + tls: [] + +resources: {} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +nodeSelector: {} +tolerations: [] +affinity: {} diff --git a/deploy/kubernetes/charts/monero/Chart.yaml b/deploy/kubernetes/charts/monero/Chart.yaml new file mode 100644 index 00000000..b9c0d84c --- /dev/null +++ b/deploy/kubernetes/charts/monero/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: monero +description: A Helm chart for monero-daemon +type: application +version: 0.1.0 diff --git a/deploy/kubernetes/charts/monero/templates/_helpers.tpl b/deploy/kubernetes/charts/monero/templates/_helpers.tpl new file mode 100644 index 00000000..2829e603 --- /dev/null +++ b/deploy/kubernetes/charts/monero/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{- define "monero.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "monero.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 253 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "monero.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "monero.labels" -}} +helm.sh/chart: {{ include "monero.chart" . }} +{{ include "monero.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "monero.selectorLabels" -}} +app.kubernetes.io/name: {{ include "monero.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "monero.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "monero.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/monero/templates/configmap.yaml b/deploy/kubernetes/charts/monero/templates/configmap.yaml new file mode 100644 index 00000000..bf550200 --- /dev/null +++ b/deploy/kubernetes/charts/monero/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + entry-dev.sh: | +{{ .Values.configMapFile | b64dec | indent 4}} diff --git a/deploy/kubernetes/charts/monero/templates/deployment.yaml b/deploy/kubernetes/charts/monero/templates/deployment.yaml new file mode 100644 index 00000000..fdd32c05 --- /dev/null +++ b/deploy/kubernetes/charts/monero/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "monero.fullname" . }} + labels: + {{- include "monero.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "monero.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "monero.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "monero.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if hasKey .Values.image "ports" }} + ports: + {{- range .Values.image.ports }} + - name: {{ .name }} + containerPort: {{ .containerPort }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "command" }} + command: + {{- toYaml .Values.image.command | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "args" }} + args: + {{- toYaml .Values.image.args | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "envVariables" }} + env: + {{- toYaml .Values.image.envVariables | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "volumeMounts" }} + volumeMounts: + {{- range .Values.image.volumeMounts }} + - mountPath: {{ .mountPath }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- 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 }} + {{- if hasKey .Values "volumes" }} + volumes: + {{- range .Values.volumes }} + - configMap: + defaultMode: {{ .configMap.defaultMode }} + name: {{ $.Release.Name}}-{{ .configMap.name }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- end }} diff --git a/deploy/kubernetes/charts/monero/templates/ingress.yaml b/deploy/kubernetes/charts/monero/templates/ingress.yaml new file mode 100644 index 00000000..2ae3d4fa --- /dev/null +++ b/deploy/kubernetes/charts/monero/templates/ingress.yaml @@ -0,0 +1,50 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "monero.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}} + {{- end }} +{{- end }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "monero.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if .pathType }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/monero/templates/service.yaml b/deploy/kubernetes/charts/monero/templates/service.yaml new file mode 100644 index 00000000..1a4f90d2 --- /dev/null +++ b/deploy/kubernetes/charts/monero/templates/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "monero.fullname" . }} + labels: + {{- include "monero.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- if hasKey .Values.service "ports" }} + {{- range .Values.service.ports }} + - port: {{ .port }} + name: {{ .name }} + targetPort: {{ .targetPort }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- end }} + selector: + {{- include "monero.selectorLabels" . | nindent 4 }} diff --git a/deploy/kubernetes/charts/monero/values.yaml b/deploy/kubernetes/charts/monero/values.yaml new file mode 100644 index 00000000..8105e003 --- /dev/null +++ b/deploy/kubernetes/charts/monero/values.yaml @@ -0,0 +1,72 @@ +replicaCount: 1 + +image: + repository: serai-dev-monero + pullPolicy: IfNotPresent + tag: "latest" + ports: + - name: p2p + containerPort: 18080 + protocol: TCP + - name: rpc + containerPort: 18081 + protocol: TCP + volumeMounts: + - mountPath: /scripts + name: configmap-volume + args: + - bash + - /scripts/entry-dev.sh + +volumes: + - configMap: + defaultMode: 420 + name: configmap + name: configmap-volume + +configMapFile: "entry-dev.sh" + +imagePullSecrets: [] + +serviceAccount: + create: false + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + ports: + - name: p2p + port: 18080 + targetPort: p2p + protocol: TCP + - name: rpc + port: 18081 + targetPort: rpc + protocol: TCP + +ingress: + enabled: false + className: "" + annotations: {} + hosts: [] + tls: [] + +resources: {} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deploy/kubernetes/charts/serai/Chart.yaml b/deploy/kubernetes/charts/serai/Chart.yaml new file mode 100644 index 00000000..69249e1d --- /dev/null +++ b/deploy/kubernetes/charts/serai/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: serai +description: A Helm chart for serai +type: application +version: 0.1.0 diff --git a/deploy/kubernetes/charts/serai/templates/_helpers.tpl b/deploy/kubernetes/charts/serai/templates/_helpers.tpl new file mode 100644 index 00000000..962c2f80 --- /dev/null +++ b/deploy/kubernetes/charts/serai/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{- define "serai-base.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "serai-base.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 253 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 253 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "serai-base.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 253 | trimSuffix "-" }} +{{- end }} + +{{- define "serai-base.labels" -}} +helm.sh/chart: {{ include "serai-base.chart" . }} +{{ include "serai-base.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "serai-base.selectorLabels" -}} +app.kubernetes.io/name: {{ include "serai-base.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "serai-base.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "serai-base.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/serai/templates/configmap.yaml b/deploy/kubernetes/charts/serai/templates/configmap.yaml new file mode 100644 index 00000000..bf550200 --- /dev/null +++ b/deploy/kubernetes/charts/serai/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + entry-dev.sh: | +{{ .Values.configMapFile | b64dec | indent 4}} diff --git a/deploy/kubernetes/charts/serai/templates/deployment.yaml b/deploy/kubernetes/charts/serai/templates/deployment.yaml new file mode 100644 index 00000000..35d0d7c0 --- /dev/null +++ b/deploy/kubernetes/charts/serai/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "serai-base.fullname" . }} + labels: + {{- include "serai-base.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "serai-base.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "serai-base.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "serai-base.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if hasKey .Values.image "ports" }} + ports: + {{- range .Values.image.ports }} + - name: {{ .name }} + containerPort: {{ .containerPort }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "command" }} + command: + {{- toYaml .Values.image.command | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "args" }} + args: + {{- toYaml .Values.image.args | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "envVariables" }} + env: + {{- toYaml .Values.image.envVariables | nindent 12 }} + {{- end }} + + {{- if hasKey .Values.image "volumeMounts" }} + volumeMounts: + {{- range .Values.image.volumeMounts }} + - mountPath: {{ .mountPath }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- 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 }} + {{- if hasKey .Values "volumes" }} + volumes: + {{- range .Values.volumes }} + - configMap: + defaultMode: {{ .configMap.defaultMode }} + name: {{ $.Release.Name}}-{{ .configMap.name }} + name: {{ $.Release.Name}}-{{ .name }} + {{- end }} + {{- end }} diff --git a/deploy/kubernetes/charts/serai/templates/ingress.yaml b/deploy/kubernetes/charts/serai/templates/ingress.yaml new file mode 100644 index 00000000..b020fc02 --- /dev/null +++ b/deploy/kubernetes/charts/serai/templates/ingress.yaml @@ -0,0 +1,50 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "serai-base.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}} + {{- end }} +{{- end }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "serai-base.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if .pathType }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/kubernetes/charts/serai/templates/service.yaml b/deploy/kubernetes/charts/serai/templates/service.yaml new file mode 100644 index 00000000..f45d73ef --- /dev/null +++ b/deploy/kubernetes/charts/serai/templates/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "serai-base.fullname" . }} + labels: + {{- include "serai-base.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- if hasKey .Values.service "ports" }} + {{- range .Values.service.ports }} + - port: {{ .port }} + name: {{ .name }} + targetPort: {{ .targetPort }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- end }} + selector: + {{- include "serai-base.selectorLabels" . | nindent 4 }} diff --git a/deploy/kubernetes/charts/serai/values.yaml b/deploy/kubernetes/charts/serai/values.yaml new file mode 100644 index 00000000..9c702daf --- /dev/null +++ b/deploy/kubernetes/charts/serai/values.yaml @@ -0,0 +1,92 @@ +replicaCount: 1 + +image: + repository: serai + pullPolicy: IfNotPresent + tag: "dev" + ports: + - name: p2p + containerPort: 30333 + protocol: TCP + - name: prometheus + containerPort: 9615 + protocol: TCP + - name: rpc + containerPort: 9933 + protocol: TCP + - name: ws + containerPort: 9944 + protocol: TCP + + volumeMounts: + - mountPath: /scripts + name: configmap-volume + envVariables: + - name: CHAIN + value: dev + - name: NAME + value: base + - name: VALIDATOR + value: + args: + - bash + - /scripts/entry-dev.sh + +volumes: + - configMap: + defaultMode: 420 + name: configmap + name: configmap-volume + +configMapFile: "entry-dev.sh" + +imagePullSecrets: [] + +serviceAccount: + create: false + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + ports: + - name: p2p + port: 30333 + targetPort: p2p + protocol: TCP + - name: prometheus + port: 9615 + targetPort: prometheus + protocol: TCP + - name: rpc + port: 9933 + targetPort: rpc + protocol: TCP + - name: ws + port: 9944 + targetPort: ws + protocol: TCP + +ingress: + enabled: false + className: "" + annotations: {} + hosts: [] + tls: [] + +resources: {} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +nodeSelector: {} +tolerations: [] +affinity: {}