Skip to content

Commit 9c799ef

Browse files
committed
Added Region Helm Template
1 parent 4ddfc36 commit 9c799ef

File tree

9 files changed

+264
-0
lines changed

9 files changed

+264
-0
lines changed

helm/region/.helmignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

helm/region/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for Kubernetes
4+
name: region
5+
version: 0.1.0

helm/region/templates/NOTES.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "region.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "region.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "region.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "region.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl port-forward $POD_NAME 8080:80
21+
{{- end }}

helm/region/templates/_helpers.tpl

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "region.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "region.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "region.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "region.labels" -}}
38+
app.kubernetes.io/name: {{ include "region.name" . }}
39+
helm.sh/chart: {{ include "region.chart" . }}
40+
app.kubernetes.io/instance: {{ .Release.Name }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
{{- end -}}

helm/region/templates/deployment.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "region.fullname" . }}
5+
labels:
6+
{{ include "region.labels" . | indent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: {{ include "region.name" . }}
12+
app.kubernetes.io/instance: {{ .Release.Name }}
13+
template:
14+
metadata:
15+
labels:
16+
app.kubernetes.io/name: {{ include "region.name" . }}
17+
app.kubernetes.io/instance: {{ .Release.Name }}
18+
spec:
19+
{{- with .Values.imagePullSecrets }}
20+
imagePullSecrets:
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
containers:
24+
- name: {{ .Chart.Name }}
25+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
26+
args:
27+
- "-text={{ .Values.region }}"
28+
imagePullPolicy: {{ .Values.image.pullPolicy }}
29+
ports:
30+
- name: http
31+
containerPort: 5678
32+
protocol: TCP
33+
livenessProbe:
34+
httpGet:
35+
path: /
36+
port: http
37+
readinessProbe:
38+
httpGet:
39+
path: /
40+
port: http
41+
resources:
42+
{{- toYaml .Values.resources | nindent 12 }}
43+
{{- with .Values.nodeSelector }}
44+
nodeSelector:
45+
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- with .Values.affinity }}
48+
affinity:
49+
{{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
{{- with .Values.tolerations }}
52+
tolerations:
53+
{{- toYaml . | nindent 8 }}
54+
{{- end }}

helm/region/templates/ingress.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "region.fullname" . -}}
3+
apiVersion: extensions/v1beta1
4+
kind: Ingress
5+
metadata:
6+
name: {{ $fullName }}
7+
labels:
8+
{{ include "region.labels" . | indent 4 }}
9+
{{- with .Values.ingress.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
{{- if .Values.ingress.tls }}
15+
tls:
16+
{{- range .Values.ingress.tls }}
17+
- hosts:
18+
{{- range .hosts }}
19+
- {{ . | quote }}
20+
{{- end }}
21+
secretName: {{ .secretName }}
22+
{{- end }}
23+
{{- end }}
24+
rules:
25+
{{- range .Values.ingress.hosts }}
26+
- host: {{ .host | quote }}
27+
http:
28+
paths:
29+
{{- range .paths }}
30+
- path: {{ . }}
31+
backend:
32+
serviceName: {{ $fullName }}
33+
servicePort: http
34+
{{- end }}
35+
{{- end }}
36+
{{- end }}

helm/region/templates/service.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "region.fullname" . }}
5+
labels:
6+
{{ include "region.labels" . | indent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
app.kubernetes.io/name: {{ include "region.name" . }}
16+
app.kubernetes.io/instance: {{ .Release.Name }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "region.fullname" . }}-test-connection"
5+
labels:
6+
{{ include "region.labels" . | indent 4 }}
7+
annotations:
8+
"helm.sh/hook": test-success
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "region.fullname" . }}:{{ .Values.service.port }}']
15+
restartPolicy: Never

helm/region/values.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Default values for region.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: hashicorp/http-echo
9+
tag: latest
10+
pullPolicy: IfNotPresent
11+
12+
imagePullSecrets: []
13+
nameOverride: ""
14+
fullnameOverride: ""
15+
16+
service:
17+
type: ClusterIP
18+
port: 5678
19+
20+
ingress:
21+
enabled: false
22+
annotations: {}
23+
# kubernetes.io/ingress.class: nginx
24+
# kubernetes.io/tls-acme: "true"
25+
hosts:
26+
- host: chart-example.local
27+
paths: []
28+
29+
tls: []
30+
# - secretName: chart-example-tls
31+
# hosts:
32+
# - chart-example.local
33+
34+
resources: {}
35+
# We usually recommend not to specify default resources and to leave this as a conscious
36+
# choice for the user. This also increases chances charts run on environments with little
37+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
38+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
39+
# limits:
40+
# cpu: 100m
41+
# memory: 128Mi
42+
# requests:
43+
# cpu: 100m
44+
# memory: 128Mi
45+
46+
nodeSelector: {}
47+
48+
tolerations: []
49+
50+
affinity: {}

0 commit comments

Comments
 (0)