Skip to content

Commit 3b6d08c

Browse files
committed
ordering api helm chart
1 parent 85b1ae6 commit 3b6d08c

12 files changed

Lines changed: 344 additions & 1 deletion

File tree

k8s/helm/catalog-api/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ inf:
2424
user: sa
2525
pwd: Pass@word
2626
db: CatalogDb
27+
eventbus:
28+
constr: rabbitmq
29+
useAzure: false
30+
appinsights:
31+
key: ""
32+
k8s:
33+
dns: ""
34+
misc:
35+
useAzureStorage: false
36+
2737

2838
resources: {}
2939

k8s/helm/inf.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
inf:
55
sql: # inf.sql defines the sql server databases & logins
66
# host: my-sql-server # Uncomment to specify a custom sql-server to be used. By default "sql-data-<appname>" will be used
7-
catalog: # sql settings for the catalog-api sql (user, pwd, db)
7+
catalog: # inf.sql.catalog: settings for the catalog-api sql (user, pwd, db)
88
user: sa # Catalog API SQL user
99
pwd: Pass@word # Catalog API SQL pwd
1010
db: CatalogDb # Catalog API SQL db name
11+
ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db)
12+
user: sa # Ordering API SQL user
13+
pwd: Pass@word # Ordering API SQL pwd
14+
db: OrderingDb # Ordering API SQL db name
1115
redis: # inf.redis defines the redis' connection strings
1216
basket:
1317
constr: basket-data # Connection string to Redis used by Basket API

k8s/helm/ordering-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/ordering-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: ordering-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 "ordering-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 "ordering-api.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-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 "ordering-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 "ordering-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 "ordering-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 "ordering-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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- $name := include "ordering-api.fullname" . -}}
2+
{{- $sqlsrv := include "sql-name" . -}}
3+
{{- $identity := include "url-identity" . -}}
4+
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: "cfg-{{ $name }}"
9+
labels:
10+
app: {{ template "ordering-api.name" . }}
11+
chart: {{ template "ordering-api.chart" .}}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
data:
15+
ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.ordering.user }};Password={{ .Values.inf.sql.ordering.pwd }};
16+
ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}"
17+
urls__IdentityUrl: http://{{ $identity }}
18+
all__EventBusConnection: {{ .Values.inf.eventbus.constr }}
19+
all__InstrumentationKey: {{ .Values.inf.appinsights.key }}
20+
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 "ordering-api.fullname" . -}}
2+
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
3+
apiVersion: apps/v1beta2
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "ordering-api.fullname" . }}
7+
labels:
8+
ufo: {{ $cfgname}}
9+
app: {{ template "ordering-api.name" . }}
10+
chart: {{ template "ordering-api.chart" . }}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Release.Service }}
13+
spec:
14+
replicas: {{ .Values.replicaCount }}
15+
selector:
16+
matchLabels:
17+
app: {{ template "ordering-api.name" . }}
18+
release: {{ .Release.Name }}
19+
template:
20+
metadata:
21+
labels:
22+
app: {{ template "ordering-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 "ordering-api.fullname" . -}}
3+
{{- $ingressPath := include "pathBase" . -}}
4+
apiVersion: extensions/v1beta1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
app: {{ template "ordering-api.name" . }}
10+
chart: {{ template "ordering-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 }}

0 commit comments

Comments
 (0)