Skip to content

Commit

Permalink
fix: add chart files
Browse files Browse the repository at this point in the history
  • Loading branch information
m-yosefpor committed Oct 21, 2021
1 parent ef7ae6d commit 57ef5cb
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ $RECYCLE.BIN/
# End of https://www.toptal.com/developers/gitignore/api/go,jetbrains+all,visualstudiocode,sublimetext,macos,osx,windows,linux

# Custom
health_exporter
health-exporter
app
config.yaml

Expand Down
23 changes: 23 additions & 0 deletions charts/health-exporter/.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/
8 changes: 8 additions & 0 deletions charts/health-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: health-exporter
home: https://github.com/snapp-cab/health-exporter
sources:
- https://github.com/snapp-cab/health-exporter.git
type: application
version: 0.3.0
appVersion: 1.0.0
1 change: 1 addition & 0 deletions charts/health-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Helm chart for health-exporter
32 changes: 32 additions & 0 deletions charts/health-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

{{/*
Expand the name of the chart.
*/}}
{{- define "health_exporter.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 "health_exporter.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 "health_exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
8 changes: 8 additions & 0 deletions charts/health-exporter/templates/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: '{{ template "health_exporter.fullname" . }}'
namespace: '{{ .Release.Namespace }}'
data:
config.yaml: |
{{- toYaml .Values.config | default "{}" | nindent 4 }}
70 changes: 70 additions & 0 deletions charts/health-exporter/templates/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: '{{ template "health_exporter.fullname" . }}'
namespace: '{{ .Release.Namespace }}'
labels:
app: '{{ template "health_exporter.fullname" . }}'
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: '{{ template "health_exporter.fullname" . }}'
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 0
template:
metadata:
labels:
app: '{{ template "health_exporter.fullname" . }}'
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- '{{ template "health_exporter.fullname" . }}'
topologyKey: "kubernetes.io/hostname"
containers:
- name: health-exporter
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
volumeMounts:
- mountPath: /app/config.yaml
name: config
subPath: config.yaml
imagePullPolicy: Always
resources:
{{- toYaml .Values.resources | nindent 10 }}
ports:
- containerPort: '{{ .Values.config.listen }}'
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: '{{ .Values.config.listen }}'
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: '{{ .Values.config.listen }}'
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
volumes:
- name: config
configMap:
defaultMode: 420
name: '{{ template "health_exporter.fullname" . }}'
items:
- key: config.yaml
path: config.yaml
28 changes: 28 additions & 0 deletions charts/health-exporter/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "health_exporter.fullname" . }}
labels:
{{- include "health_exporter.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "health_exporter.fullname" . }}
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 }}
13 changes: 13 additions & 0 deletions charts/health-exporter/templates/svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: '{{ template "health_exporter.fullname" . }}'
namespace: '{{ .Release.Namespace }}'
spec:
ports:
- name: web
port: 8080
protocol: TCP
targetPort: '{{ .Values.config.listen }}'
selector:
app: '{{ template "health_exporter.fullname" . }}'
39 changes: 39 additions & 0 deletions charts/health-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Default values for health-exporter.
image:
repository: "spc35771/health-exporter"
tag: "latest"
replicas: 1
resources:
limits:
memory: "100Mi"
cpu: "1"
requests:
memory: "100Mi"
cpu: "1"

autoscaling:
enabled: false
minReplicas: 2
maxReplicas: 4
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80

config:
listen: ':9876'
targets:
http:
- name: 'sample'
url: 'http://google.com'
rps: 0.5
timeout: '5s'
- name: 'google-tls'
url: 'https://google.com'
rps: 0.5
timeout: '5s'
tls_skip_verify: true
dns:
- name: 'google'
domain: 'google.com'
record_type: 'A'
rps: 0.5
timeout: '2s'

0 comments on commit 57ef5cb

Please sign in to comment.