Skip to content

Commit 7be2b53

Browse files
committed
Mobile Shopping apigw
1 parent fce8326 commit 7be2b53

13 files changed

Lines changed: 474 additions & 1 deletion

File tree

k8s/helm/apigwmm/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: {{ .Values.app.svc.apigwmm }}
4+
name: {{ .Values.app.svc.mobilemarketingapigw }}
55
labels:
66
app: {{ template "apigwmm.name" . }}
77
chart: {{ template "apigwmm.chart" . }}

k8s/helm/apigwms/.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/apigwms/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: apigwms
5+
version: 0.1.0
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"ReRoutes": [
3+
{
4+
"DownstreamPathTemplate": "/api/{version}/{everything}",
5+
"DownstreamScheme": "http",
6+
"DownstreamHostAndPorts": [
7+
{
8+
"Host": "catalog",
9+
"Port": 80
10+
}
11+
],
12+
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
13+
"UpstreamHttpMethod": [ "GET" ]
14+
},
15+
{
16+
"DownstreamPathTemplate": "/api/{version}/{everything}",
17+
"DownstreamScheme": "http",
18+
"DownstreamHostAndPorts": [
19+
{
20+
"Host": "basket",
21+
"Port": 80
22+
}
23+
],
24+
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
25+
"UpstreamHttpMethod": [],
26+
"AuthenticationOptions": {
27+
"AuthenticationProviderKey": "IdentityApiKey",
28+
"AllowedScopes": []
29+
}
30+
},
31+
{
32+
"DownstreamPathTemplate": "/api/{version}/{everything}",
33+
"DownstreamScheme": "http",
34+
"DownstreamHostAndPorts": [
35+
{
36+
"Host": "ordering",
37+
"Port": 80
38+
}
39+
],
40+
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
41+
"UpstreamHttpMethod": [],
42+
"AuthenticationOptions": {
43+
"AuthenticationProviderKey": "IdentityApiKey",
44+
"AllowedScopes": []
45+
}
46+
},
47+
{
48+
"DownstreamPathTemplate": "/{everything}",
49+
"DownstreamScheme": "http",
50+
"DownstreamHostAndPorts": [
51+
{
52+
"Host": "mobileshoppingagg",
53+
"Port": 80
54+
}
55+
],
56+
"UpstreamPathTemplate": "/{everything}",
57+
"UpstreamHttpMethod": [ "POST", "PUT", "GET" ],
58+
"AuthenticationOptions": {
59+
"AuthenticationProviderKey": "IdentityApiKey",
60+
"AllowedScopes": []
61+
}
62+
},
63+
{
64+
"DownstreamPathTemplate": "/{everything}",
65+
"DownstreamScheme": "http",
66+
"DownstreamHostAndPorts": [
67+
{
68+
"Host": "ordering",
69+
"Port": 80
70+
}
71+
],
72+
"UpstreamPathTemplate": "/orders-api/{everything}",
73+
"UpstreamHttpMethod": []
74+
},
75+
{
76+
"DownstreamPathTemplate": "/{everything}",
77+
"DownstreamScheme": "http",
78+
"DownstreamHostAndPorts": [
79+
{
80+
"Host": "basket",
81+
"Port": 80
82+
}
83+
],
84+
"UpstreamPathTemplate": "/basket-api/{everything}",
85+
"UpstreamHttpMethod": []
86+
},
87+
{
88+
"DownstreamPathTemplate": "/{everything}",
89+
"DownstreamScheme": "http",
90+
"DownstreamHostAndPorts": [
91+
{
92+
"Host": "catalog",
93+
"Port": 80
94+
}
95+
],
96+
"UpstreamPathTemplate": "/catalog-api/{everything}",
97+
"UpstreamHttpMethod": []
98+
},
99+
{
100+
"DownstreamPathTemplate": "/{everything}",
101+
"DownstreamScheme": "http",
102+
"DownstreamHostAndPorts": [
103+
{
104+
"Host": "marketing",
105+
"Port": 80
106+
}
107+
],
108+
"UpstreamPathTemplate": "/marketing-api/{everything}",
109+
"UpstreamHttpMethod": []
110+
},
111+
{
112+
"DownstreamPathTemplate": "/{everything}",
113+
"DownstreamScheme": "http",
114+
"DownstreamHostAndPorts": [
115+
{
116+
"Host": "payment",
117+
"Port": 80
118+
}
119+
],
120+
"UpstreamPathTemplate": "/payment-api/{everything}",
121+
"UpstreamHttpMethod": []
122+
},
123+
{
124+
"DownstreamPathTemplate": "/{everything}",
125+
"DownstreamScheme": "http",
126+
"DownstreamHostAndPorts": [
127+
{
128+
"Host": "locations.api",
129+
"Port": 80
130+
}
131+
],
132+
"UpstreamPathTemplate": "/location-api/{everything}",
133+
"UpstreamHttpMethod": []
134+
}
135+
136+
],
137+
"GlobalConfiguration": {
138+
"RequestIdKey": "OcRequestId",
139+
"AdministrationPath": "/administration"
140+
}
141+
}
142+
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 "apigwms.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 "apigwms.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwms.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 "apigwms.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 "apigwms.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 "apigwms.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 "apigwms.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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- $name := include "apigwms.fullname" . -}}
2+
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: "cfg-{{ $name }}"
7+
labels:
8+
app: {{ template "apigwms.name" . }}
9+
chart: {{ template "apigwms.chart" .}}
10+
release: {{ .Release.Name }}
11+
heritage: {{ .Release.Service }}
12+
data:
13+
internalurls__identity: http://{{ .Values.app.svc.identity }}
14+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{{- $name := include "apigwms.fullname" . -}}
2+
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
3+
{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}}
4+
apiVersion: apps/v1beta2
5+
kind: Deployment
6+
metadata:
7+
name: {{ template "apigwms.fullname" . }}
8+
labels:
9+
ufo: {{ $cfgname}}
10+
app: {{ template "apigwms.name" . }}
11+
chart: {{ template "apigwms.chart" . }}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
spec:
15+
replicas: {{ .Values.replicaCount }}
16+
selector:
17+
matchLabels:
18+
app: {{ template "apigwms.name" . }}
19+
release: {{ .Release.Name }}
20+
template:
21+
metadata:
22+
labels:
23+
app: {{ template "apigwms.name" . }}
24+
release: {{ .Release.Name }}
25+
spec:
26+
{{ if .Values.imagePullSecrets -}}
27+
imagePullSecrets:
28+
{{ range .Values.imagePullSecrets -}}
29+
- name: {{ .name }}
30+
{{- end -}}
31+
{{- end }}
32+
volumes:
33+
- name: config
34+
configMap:
35+
name: {{ $ocelotcfgname }}
36+
items:
37+
- key: ms
38+
path: configuration.json
39+
containers:
40+
- name: {{ .Chart.Name }}
41+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
42+
imagePullPolicy: {{ .Values.image.pullPolicy }}
43+
volumeMounts:
44+
- name: config
45+
mountPath: /app/configuration
46+
env:
47+
- name: PATH_BASE
48+
value: {{ include "pathBase" . }}
49+
- name: k8sname
50+
value: {{ .Values.clusterName }}
51+
{{- if .Values.env.values -}}
52+
{{- range .Values.env.values }}
53+
- name: {{ .name }}
54+
value: {{ .value | quote }}
55+
{{- end -}}
56+
{{- end -}}
57+
{{- if .Values.env.configmap -}}
58+
{{- range .Values.env.configmap }}
59+
- name: {{ .name }}
60+
valueFrom:
61+
configMapKeyRef:
62+
name: {{ $cfgname }}
63+
key: {{ .key }}
64+
{{- end -}}
65+
{{- end }}
66+
ports:
67+
- name: http
68+
containerPort: 80
69+
protocol: TCP
70+
resources:
71+
{{ toYaml .Values.resources | indent 12 }}
72+
{{- with .Values.nodeSelector }}
73+
nodeSelector:
74+
{{ toYaml . | indent 8 }}
75+
{{- end }}
76+
{{- with .Values.affinity }}
77+
affinity:
78+
{{ toYaml . | indent 8 }}
79+
{{- end }}
80+
{{- with .Values.tolerations }}
81+
tolerations:
82+
{{ toYaml . | indent 8 }}
83+
{{- end }}
84+

0 commit comments

Comments
 (0)