Skip to content

Commit

Permalink
Initial helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
geniass committed Aug 14, 2018
1 parent f9e74da commit f837ec6
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
21 changes: 21 additions & 0 deletions k8s-external-ip-checker/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions k8s-external-ip-checker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: k8s-external-ip-checker
version: 0.1.0
Empty file.
32 changes: 32 additions & 0 deletions k8s-external-ip-checker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-external-ip-checker.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 "k8s-external-ip-checker.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 "k8s-external-ip-checker.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
63 changes: 63 additions & 0 deletions k8s-external-ip-checker/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "k8s-external-ip-checker.fullname" . }}
labels:
app: {{ template "k8s-external-ip-checker.name" . }}
chart: {{ template "k8s-external-ip-checker.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
matchLabels:
app: {{ template "k8s-external-ip-checker.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "k8s-external-ip-checker.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sh
- -c
- |
set -eu;
trap 'echo Exiting... && exit 0' SIGTERM;
apk add --no-cache bind-tools;
while :;
do
set -e;
ip=$(dig +short myip.opendns.com @resolver1.opendns.com);
set +e;
echo $ALLOWED_IPS | grep "$ip" > /dev/null;
res=$?;
if [[ $res -eq 0 ]]
then
echo "SUCCESS - $ip is allowed"
else
echo "FAIL - $ip is not allowed"
fi
sleep {{ .Values.pollInterval }}
done
env:
- name: ALLOWED_IPS
value: {{ .Values.allowedIps }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
33 changes: 33 additions & 0 deletions k8s-external-ip-checker/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Default values for k8s-external-ip-checker.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: alpine
tag: latest
pullPolicy: IfNotPresent

# will check the external IP address every pollInternal seconds
pollInterval: 60
# comma-seperated list of allowed IP addresses
allowedIps: 127.0.0.1,192.168.1.1

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit f837ec6

Please sign in to comment.