Skip to content

Commit 9c95402

Browse files
committed
Locations api
updates on service names generation
1 parent 49f1ca1 commit 9c95402

13 files changed

Lines changed: 353 additions & 1 deletion

File tree

k8s/helm/app.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,20 @@ app: # app global settings
2222
payment: payment-api # ingress entry for payment api
2323
locations: locations-api # ingress entry for locations api
2424
marketing: marketing-api # ingress entry for marketing api
25+
svc:
26+
basket: basket # service name for basket api
27+
catalog: catalog # service name for catalog api
28+
ordering: ordering # service name for ordering api
29+
identity: identity # service name for identity api
30+
mvc: webmvc # service name for web mvc
31+
spa: webspa # service name for web spa
32+
status: webstatus # service name for web status
33+
webshoppingapigw: webshoppingapigw # service name for web shopping Agw
34+
webmarketingapigw: webmarketingapigw # service name for web mkg Agw
35+
mobilemarketingapigw: mobilemarketingapigw # service name for mobile mkg Agw
36+
mobileshoppingapigw: mobileshoppingapigw # service name for mobile shopping Agw
37+
webshoppingagg: webshoppingagg # service name for web shopping aggregator
38+
mobileshoppingagg: mobileshoppingagg # service name for mobile shopping aggregator
39+
payment: payment # service name for payment api
40+
locations: locations # service name for locations api
41+
marketing: marketing # service name for marketing api

k8s/helm/identity-api/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ template "identity-api.fullname" . }}
4+
name: {{ .Values.app.svc.identity }}
55
labels:
66
app: {{ template "identity-api.name" . }}
77
chart: {{ template "identity-api.chart" . }}

k8s/helm/inf.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ inf:
1616
user: sa # Ordering API SQL user
1717
pwd: Pass@word # Ordering API SQL pwd
1818
db: IdentityDb # Ordering API SQL db name
19+
mongo:
20+
# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used
21+
locations:
22+
database: LocationsDb
23+
marketing:
24+
database: MarketingDb
1925
redis: # inf.redis defines the redis' connection strings
2026
basket:
2127
constr: basket-data # Connection string to Redis used by Basket API

k8s/helm/locations-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/locations-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: locations-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 "locations-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 "locations-api.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "locations-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 "locations-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 "locations-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 "locations-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 "locations-api.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 "mongo-name" -}}
18+
{{- if .Values.inf.mongo.host -}}
19+
{{- .Values.inf.mongo.host -}}
20+
{{- else -}}
21+
{{- printf "%s" "nosql-data" -}}
22+
{{- end -}}
23+
{{- end -}}
24+
25+
{{- define "url-of" -}}
26+
{{- $name := first .}}
27+
{{- $ctx := last .}}
28+
{{- $suffix := include "suffix-name" $ctx -}}
29+
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
30+
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is <prefix>.<dns>/<name>
31+
{{- else -}}
32+
{{- if $ctx.Values.inf.k8s.suffix -}}
33+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is <dns>/<name>-<sufix>
34+
{{- else -}}
35+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just <dns>/<name>
36+
{{- end -}}
37+
{{- end -}}
38+
{{- end -}}
39+
40+
41+
42+
{{ define "pathBase" -}}
43+
{{- if .Values.inf.k8s.suffix -}}
44+
{{- $suffix := include "suffix-name" . -}}
45+
{{- printf "%s-%s" .Values.pathBase $suffix -}}
46+
{{- else -}}
47+
{{- .Values.pathBase -}}
48+
{{- end -}}
49+
{{- end -}}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- $name := include "locations-api.fullname" . -}}
2+
{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}}
3+
{{- $mongo := include "mongo-name" . -}}
4+
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: "cfg-{{ $name }}"
9+
labels:
10+
app: {{ template "locations-api.name" . }}
11+
chart: {{ template "locations-api.chart" .}}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
data:
15+
all__EventBusConnection: {{ .Values.inf.eventbus.constr }}
16+
all__InstrumentationKey: {{ .Values.inf.appinsights.key }}
17+
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
18+
all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}"
19+
internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }}
20+
urls__IdentityUrl: {{ $identity }}
21+
locations__ConnectionString: mongodb://{{ $mongo }}
22+
locations__Database: {{ .Values.inf.mongo.locations.database }}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{- $name := include "locations-api.fullname" . -}}
2+
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
3+
apiVersion: apps/v1beta2
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "locations-api.fullname" . }}
7+
labels:
8+
ufo: {{ $cfgname}}
9+
app: {{ template "locations-api.name" . }}
10+
chart: {{ template "locations-api.chart" . }}
11+
release: {{ .Release.Name }}
12+
heritage: {{ .Release.Service }}
13+
spec:
14+
replicas: {{ .Values.replicaCount }}
15+
selector:
16+
matchLabels:
17+
app: {{ template "locations-api.name" . }}
18+
release: {{ .Release.Name }}
19+
template:
20+
metadata:
21+
labels:
22+
app: {{ template "locations-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+

0 commit comments

Comments
 (0)