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

feat/helm #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions k8s/helm/coolbeans/.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 k8s/helm/coolbeans/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: coolbeans
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: "v0.1.10"
91 changes: 91 additions & 0 deletions k8s/helm/coolbeans/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "coolbeans.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 "coolbeans.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 }}

# {{- define "coolbeans.fullname.proxy" -}}
# {{- 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-proxy" .Release.Name $name | trunc 63 | trimSuffix "-" }}
# {{- end }}
# {{- end }}
# {{- end }}

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

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

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

{{/*
Selector labels
*/}}
{{- define "coolbeans.selectorLabels" -}}
app.kubernetes.io/name: {{ include "coolbeans.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: node
{{- end }}

{{- define "coolbeans.selectorLabels.proxy" -}}
app.kubernetes.io/name: {{ include "coolbeans.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: proxy
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "coolbeans.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "coolbeans.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions k8s/helm/coolbeans/templates/node/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "coolbeans.fullname" . }}
labels:
{{- include "coolbeans.labels" . | nindent 4 }}
data:
PEERS_ADDRS: "{{ include "coolbeans.fullname" . }}-node-0.{{ include "coolbeans.fullname" . }}-node.{{ .Release.Namespace }}.svc.cluster.local:11000,{{ include "coolbeans.fullname" . }}-node-1.{{ include "coolbeans.fullname" . }}-node.{{ .Release.Namespace }}.svc.cluster.local:11000,{{ include "coolbeans.fullname" . }}-node-2.{{ include "coolbeans.fullname" . }}-node.{{ .Release.Namespace }}.svc.cluster.local:11000"
BOOTSTRAP_NODE_ID: "{{ include "coolbeans.fullname" . }}-node-0"
ADDR_SUFFIX: "{{ include "coolbeans.fullname" . }}-node.{{ .Release.Namespace }}.svc.cluster.local"
BEANSTALKD_PORT: "{{ .Values.clusterNode.config.beanstalkd_port | default "11300" }}"
COOLBEANS_RAFT_PORT: "{{ .Values.clusterNode.config.coolbeans_raft_port | default "21000" }}"
COOLBEANS_RPC_PORT: "{{ .Values.clusterNode.config.coolbeans_rpc_port | default "11000" }}"
DATA_DIR: "{{ .Values.clusterNode.config.data_dir | default "/root/data" }}"
SNAPSHOT_THRESHOLD: "{{ .Values.clusterNode.config.snapshot_threshold | default "100" }}"
TRAILING_LOG_COUNT: "{{ .Values.clusterNode.config.trailing_log_count | default "10240" }}"
SNAPSHOT_INTERVAL_SECS: "{{ .Values.clusterNode.config.snapshot_interval_secs | default "30" }}"
MAX_JOB_SIZE_BYTES: "{{ .Values.clusterNode.config.max_job_size_bytes | default "65535" }}"
PROMETHEUS_PORT: "{{ .Values.clusterNode.config.prometheus_port | default "2020" }}"
RETAIN_SNAPSHOT_COUNT: "{{ .Values.clusterNode.config.retain_snapshot_count | default "3" }}"
28 changes: 28 additions & 0 deletions k8s/helm/coolbeans/templates/node/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.clusterNode.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "coolbeans.fullname" . }}-node
labels:
{{- include "coolbeans.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "coolbeans.fullname" . }}-node
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions k8s/helm/coolbeans/templates/node/pdr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ if or (eq (.Values.clusterNode.replicaCount | float64) 3.0) (eq (.Values.clusterNode.replicaCount | float64) 5.0) }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "coolbeans.fullname" . }}-node
labels:
{{- include "coolbeans.labels" . | nindent 4 }}
spec:
{{ if eq (.Values.clusterNode.replicaCount | float64) 3.0 }}
minAvailable: 2
{{ else if eq (.Values.clusterNode.replicaCount | float64) 5.0 }}
minAvailable: 3
{{ end }}
selector:
matchLabels:
{{- include "coolbeans.selectorLabels" . | nindent 6 }}
{{ end }}
21 changes: 21 additions & 0 deletions k8s/helm/coolbeans/templates/node/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

apiVersion: v1
kind: Service
metadata:
name: {{ include "coolbeans.fullname" . }}-node
labels:
{{- include "coolbeans.labels" . | nindent 4 }}
spec:
clusterIP: None
ports:
- name: grpc-server
port: {{ .Values.clusterNode.config.coolbeans_rpc_port | default "11000" }}
targetPort: grpc-server
- name: raft-tcp
port: {{ .Values.clusterNode.config.coolbeans_raft_port | default "21000" }}
targetPort: raft-tcp
- name: metrics
port: {{ .Values.clusterNode.config.prometheus_port | default "2020" }}
targetPort: metrics
selector:
{{- include "coolbeans.selectorLabels" . | nindent 4 }}
Loading