Skip to content

Commit

Permalink
Merge pull request #1 from santiment/feature/avalanche
Browse files Browse the repository at this point in the history
Feature/avalanche
  • Loading branch information
ivan-genev authored Mar 21, 2022
2 parents 62603ab + ae57bb6 commit dbc9222
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/avalanche/.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/
15 changes: 15 additions & 0 deletions charts/avalanche/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
description: Helm chart for avalanche node
name: avalanche
version: 0.0.1
appVersion: master
keywords:
- Avalanche
- validator
- blockchain
- AVAX
home: https://www.avax.network
sources:
- https://github.com/ava-labs/avalanchego
maintainers:
- name: Ivan Genev
2 changes: 2 additions & 0 deletions charts/avalanche/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avalanche
=====
20 changes: 20 additions & 0 deletions charts/avalanche/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "avalanche.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "avalanche.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "avalanche.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.http.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "avalanche.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
29 changes: 29 additions & 0 deletions charts/avalanche/templates/_helper_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
upstream {{ template "avalanche.proxyname" . }} {
server localhost:{{ .Values.service.http.port }};
}

{{- if .Values.proxy.logFormat }}
log_format rpc escape=none
{{- range .Values.proxy.logFormat }}
'{{ . }}'
{{- end }};
{{- end }}

server {
listen {{ .Values.proxy.port }};
location / {
proxy_pass http://{{ template `avalanche.proxyname` . }};
{{- if .Values.proxy.serverConfig }}
{{- range .Values.proxy.serverConfig }}
{{ . }}
{{- end }}
{{- end }}
{{- if .Values.proxy.logFormat }}
access_log /var/log/nginx/access.log rpc;
{{- end }}
}
location /nginx_status {
stub_status;
access_log off;
}
}
84 changes: 84 additions & 0 deletions charts/avalanche/templates/_helpers.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "avalanche.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 "avalanche.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 "avalanche.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for statefulset.
*/}}
{{- define "avalanche.statefulset.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "apps/v1beta2" -}}
{{- print "apps/v1beta2" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "avalanche.ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}


{{/*
Properly format optional additional arguments to avalanchego
*/}}
{{- define "avalanche.extraArgs" -}}
{{- range .Values.extraArgs -}}
{{ " " }}{{ . }}
{{- end -}}
{{- end -}}

{{/*
Determine service account name for statefulset.
*/}}
{{- define "avalanche.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{- default (include "avalanche.fullname" .) .Values.serviceAccount.name | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- default "default" .Values.serviceAccount.name -}}
{{- end -}}
{{- end -}}

{{/*
Determine proxy name for statefulset.
*/}}
{{- define "avalanche.proxyname" -}}
{{- if .Values.proxy.enabled -}}
{{- printf "%s-%s" .Chart.Name "proxy" | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
14 changes: 14 additions & 0 deletions charts/avalanche/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.proxy.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "avalanche.proxyname" . }}
labels:
app: {{ template "avalanche.name" . }}
chart: {{ template "avalanche.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
nginx.conf: |
{{ include (print $.Template.BasePath "/_helper_nginx.conf") . | indent 4 }}
{{- end }}
45 changes: 45 additions & 0 deletions charts/avalanche/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "avalanche.fullname" . -}}
{{- $servicePort := .Values.service.http.port -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: {{ template "avalanche.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "avalanche.name" . }}
chart: {{ template "avalanche.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.labels }}
{{ toYaml . | indent 4 }}
{{- end }}

{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- if . }}
host: {{ . | quote }}
{{- end }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/avalanche/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "avalanche.fullname" . }}
labels:
app: {{ template "avalanche.name" . }}
chart: {{ template "avalanche.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.http.port }}
{{- if .Values.proxy.enabled }}
targetPort: {{ .Values.proxy.port }}
{{- else }}
targetPort: {{ .Values.service.http.port }}
{{- end }}
protocol: TCP
selector:
app: {{ template "avalanche.name" . }}
release: {{ .Release.Name }}
7 changes: 7 additions & 0 deletions charts/avalanche/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "avalanche.serviceAccountName" . | quote }}
namespace: {{ .Release.Namespace | quote }}
{{- end -}}
Loading

0 comments on commit dbc9222

Please sign in to comment.