Skip to content

Commit

Permalink
Adding smart-contract-verification chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nzenchik committed Aug 2, 2024
1 parent f5c9be3 commit 03d5ef3
Show file tree
Hide file tree
Showing 19 changed files with 1,038 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/smart-contract-verification/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/smart-contract-verification/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: smart-contract-verification
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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

# 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.
# It is recommended to use it with quotes.
appVersion: "1.0.0"
62 changes: 62 additions & 0 deletions charts/smart-contract-verification/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "smart-contract-verification.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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 "smart-contract-verification.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "smart-contract-verification.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "smart-contract-verification.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "smart-contract-verification.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{{- if .Values.ethBytecodeDb.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
labels:
app: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
{{- include "smart-contract-verification.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.ethBytecodeDb.replicaCount }}
selector:
matchLabels:
app: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
{{- include "smart-contract-verification.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- if eq .Values.ethBytecodeDb.image.pullPolicy "Always" }}
rollme: {{ randAlphaNum 5 | quote }}
{{- end }}
{{- with .Values.ethBytecodeDb.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
{{- include "smart-contract-verification.labels" . | nindent 8 }}
{{- with .Values.ethBytecodeDb.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "smart-contract-verification.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.ethBytecodeDb.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-eth-bytecode-db
securityContext:
{{- toYaml .Values.ethBytecodeDb.securityContext | nindent 12 }}
image: "{{ .Values.ethBytecodeDb.image.repository }}:{{ .Values.ethBytecodeDb.image.tag }}"
imagePullPolicy: {{ .Values.ethBytecodeDb.image.pullPolicy }}
env:
- name: ETH_BYTECODE_DB__SERVER__HTTP__ADDR
value: "0.0.0.0:{{ .Values.ethBytecodeDb.service.port }}"
- name: ETH_BYTECODE_DB__VERIFIER__HTTP_URL
value: http://{{ include "smart-contract-verification.fullname" . }}-smart-contract-verifier:{{ .Values.smartContractVerifier.service.port }}
{{- if .Values.metrics.enabled }}
- name: ETH_BYTECODE_DB__METRICS__ENABLED
value: 'true'
- name: ETH_BYTECODE_DB__METRICS__ADDR
value: 0.0.0.0:{{ .Values.metrics.port }}
{{- end }}
{{- range $key, $value := .Values.ethBytecodeDb.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if or .Values.ethBytecodeDb.envFromSecret }}
envFrom:
- secretRef:
name: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db-env
{{- end }}
ports:
- name: http
containerPort: {{ .Values.ethBytecodeDb.service.port }}
protocol: TCP
{{- if .Values.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.metrics.port }}
protocol: TCP
{{- end }}
livenessProbe:
{{- toYaml .Values.ethBytecodeDb.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.ethBytecodeDb.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.ethBytecodeDb.resources | nindent 12 }}
{{- with .Values.ethBytecodeDb.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.ethBytecodeDb.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- 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 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{- if .Values.ethBytecodeDb.ingress.enabled -}}
{{- $fullName := include "smart-contract-verification.fullname" . -}}
{{- $svcPort := .Values.ethBytecodeDb.service.port -}}
{{- if and .Values.ethBytecodeDb.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ethBytecodeDb.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ethBytecodeDb.ingress.annotations "kubernetes.io/ingress.class" .Values.ethBytecodeDb.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-eth-bytecode-db
labels:
{{- include "smart-contract-verification.labels" . | nindent 4 }}
{{- with .Values.ethBytecodeDb.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ethBytecodeDb.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ethBytecodeDb.ingress.className }}
{{- end }}
{{- if .Values.ethBytecodeDb.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ethBytecodeDb.ingress.hostname | quote }}
secretName: {{ $fullName }}-eth-bytecode-db-ingress-tls
{{- end }}
rules:
- host: {{ .Values.ethBytecodeDb.ingress.hostname | quote }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-eth-bytecode-db
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}-eth-bytecode-db
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.ethBytecodeDb.envFromSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db-env
labels:
{{- include "smart-contract-verification.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := .Values.ethBytecodeDb.envFromSecret }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.ethBytecodeDb.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
labels:
{{- include "smart-contract-verification.labels" . | nindent 4 }}
spec:
type: {{ .Values.ethBytecodeDb.service.type }}
ports:
- port: {{ .Values.ethBytecodeDb.service.port }}
targetPort: http
protocol: TCP
name: http
{{- if .Values.metrics.enabled }}
- port: {{ .Values.metrics.port }}
targetPort: metrics
protocol: TCP
name: metrics
{{- end }}
selector:
app: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
{{- include "smart-contract-verification.selectorLabels" . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and .Values.metrics.enabled .Values.metrics.prometheus.enabled .Values.ethBytecodeDb.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
labels:
{{- include "smart-contract-verification.labels" . | nindent 4 }}
spec:
endpoints:
- scrapeTimeout: 30s
port: metrics
path: /metrics
selector:
matchLabels:
app: {{ include "smart-contract-verification.fullname" . }}-eth-bytecode-db
{{- end }}
13 changes: 13 additions & 0 deletions charts/smart-contract-verification/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "smart-contract-verification.serviceAccountName" . }}
labels:
{{- include "smart-contract-verification.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading

0 comments on commit 03d5ef3

Please sign in to comment.