Skip to content

Commit 85b1ae6

Browse files
committed
helm charts for eshop (catalog api, basket api, common inf)
1 parent fcff8e4 commit 85b1ae6

22 files changed

Lines changed: 672 additions & 0 deletions

k8s/helm/app.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This heml values file defines app-based settings
2+
# Charts use those values, so this file must be included in all chart releases
3+
4+
app:
5+
name: "my-eshop" # Override for custom application names.
6+
ingress:
7+
suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist)

k8s/helm/basket-api/.helmignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

k8s/helm/basket-api/Chart.yaml

Lines changed: 5 additions & 0 deletions
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: basket-api
5+
version: 0.1.0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range .Values.ingress.hosts }}
4+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
5+
{{- end }}
6+
{{- else if contains "NodePort" .Values.service.type }}
7+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "basket-api.fullname" . }})
8+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
9+
echo http://$NODE_IP:$NODE_PORT
10+
{{- else if contains "LoadBalancer" .Values.service.type }}
11+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
12+
You can watch the status of by running 'kubectl get svc -w {{ template "basket-api.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "basket-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
14+
echo http://$SERVICE_IP:{{ .Values.service.port }}
15+
{{- else if contains "ClusterIP" .Values.service.type }}
16+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "basket-api.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
17+
echo "Visit http://127.0.0.1:8080 to use your application"
18+
kubectl port-forward $POD_NAME 8080:80
19+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "basket-api.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 "basket-api.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 "basket-api.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- define "suffix-name" -}}
2+
{{- if .Values.app.name -}}
3+
{{- .Values.app.name -}}
4+
{{- else -}}
5+
{{- .Release.Name -}}
6+
{{- end -}}
7+
{{- end -}}
8+
9+
{{- define "sql-name" -}}
10+
{{- if .Values.inf.sql.host -}}
11+
{{- .Values.inf.sql.host -}}
12+
{{- else -}}
13+
{{- printf "%s" "sql-data" -}}
14+
{{- end -}}
15+
{{- end -}}
16+
17+
{{- define "url-identity" -}}
18+
{{- if .Values.app.ingress.suffix -}}
19+
{{- $suffix := include "suffix-name" . -}}
20+
{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}}
21+
{{- else -}}
22+
{{- printf "%s/identity-api" .Values.inf.k8s.dns -}}
23+
{{- end -}}
24+
{{- end -}}
25+
26+
{{ define "pathBase" -}}
27+
{{- if .Values.app.ingress.suffix -}}
28+
{{- $suffix := include "suffix-name" . -}}
29+
{{- printf "%s-%s" .Values.pathBase $suffix -}}
30+
{{- else -}}
31+
{{- .Values.pathBase -}}
32+
{{- end -}}
33+
{{- end -}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- $name := include "basket-api.fullname" . -}}
2+
{{- $identity := include "url-identity" . -}}
3+
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: "cfg-{{ $name }}"
8+
labels:
9+
app: {{ template "basket-api.name" . }}
10+
chart: {{ template "basket-api.chart" .}}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Release.Service }}
13+
data:
14+
basket__ConnectionString: {{ .Values.inf.redis.basket.constr }}
15+
urls__IdentityUrl: http://{{ $identity }}
16+
basket__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}"
17+
all__EventBusConnection: {{ .Values.inf.eventbus.constr }}
18+
all__InstrumentationKey: {{ .Values.inf.appinsights.key }}
19+
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{- $name := include "basket-api.fullname" . -}}
2+
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
3+
apiVersion: apps/v1beta2
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "basket-api.fullname" . }}
7+
labels:
8+
ufo: {{ $cfgname}}
9+
app: {{ template "basket-api.name" . }}
10+
chart: {{ template "basket-api.chart" . }}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Release.Service }}
13+
spec:
14+
replicas: {{ .Values.replicaCount }}
15+
selector:
16+
matchLabels:
17+
app: {{ template "basket-api.name" . }}
18+
release: {{ .Release.Name }}
19+
template:
20+
metadata:
21+
labels:
22+
app: {{ template "basket-api.name" . }}
23+
release: {{ .Release.Name }}
24+
spec:
25+
{{ if .Values.imagePullSecrets -}}
26+
imagePullSecrets:
27+
{{ range .Values.imagePullSecrets -}}
28+
- name: {{ .name }}
29+
{{- end -}}
30+
{{- end }}
31+
containers:
32+
- name: {{ .Chart.Name }}
33+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
34+
imagePullPolicy: {{ .Values.image.pullPolicy }}
35+
env:
36+
- name: PATH_BASE
37+
value: {{ include "pathBase" . }}
38+
- name: k8sname
39+
value: {{ .Values.clusterName }}
40+
{{- if .Values.env.values -}}
41+
{{- range .Values.env.values }}
42+
- name: {{ .name }}
43+
value: {{ .value | quote }}
44+
{{- end -}}
45+
{{- end -}}
46+
{{- if .Values.env.configmap -}}
47+
{{- range .Values.env.configmap }}
48+
- name: {{ .name }}
49+
valueFrom:
50+
configMapKeyRef:
51+
name: {{ $cfgname }}
52+
key: {{ .key }}
53+
{{- end -}}
54+
{{- end }}
55+
ports:
56+
- name: http
57+
containerPort: 80
58+
protocol: TCP
59+
resources:
60+
{{ toYaml .Values.resources | indent 12 }}
61+
{{- with .Values.nodeSelector }}
62+
nodeSelector:
63+
{{ toYaml . | indent 8 }}
64+
{{- end }}
65+
{{- with .Values.affinity }}
66+
affinity:
67+
{{ toYaml . | indent 8 }}
68+
{{- end }}
69+
{{- with .Values.tolerations }}
70+
tolerations:
71+
{{ toYaml . | indent 8 }}
72+
{{- end }}
73+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "basket-api.fullname" . -}}
3+
{{- $ingressPath := include "pathBase" . -}}
4+
apiVersion: extensions/v1beta1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
app: {{ template "basket-api.name" . }}
10+
chart: {{ template "basket-api.chart" . }}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Release.Service }}
13+
{{- with .Values.ingress.annotations }}
14+
annotations:
15+
{{ toYaml . | indent 4 }}
16+
{{- end }}
17+
spec:
18+
{{- if .Values.ingress.tls }}
19+
tls:
20+
{{- range .Values.ingress.tls }}
21+
- hosts:
22+
{{- range .hosts }}
23+
- {{ . }}
24+
{{- end }}
25+
secretName: {{ .secretName }}
26+
{{- end }}
27+
{{- end }}
28+
rules:
29+
{{- range .Values.ingress.hosts }}
30+
- host: {{ . }}
31+
http:
32+
paths:
33+
- path: {{ $ingressPath }}
34+
backend:
35+
serviceName: {{ $fullName }}
36+
servicePort: http
37+
{{- end }}
38+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "basket-api.fullname" . }}
5+
labels:
6+
app: {{ template "basket-api.name" . }}
7+
chart: {{ template "basket-api.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
type: {{ .Values.service.type }}
12+
ports:
13+
- port: {{ .Values.service.port }}
14+
targetPort: http
15+
protocol: TCP
16+
name: http
17+
selector:
18+
app: {{ template "basket-api.name" . }}
19+
release: {{ .Release.Name }}

0 commit comments

Comments
 (0)