Skip to content

Commit 9258508

Browse files
committed
Web marketing apigw
1 parent 7be2b53 commit 9258508

14 files changed

Lines changed: 367 additions & 2 deletions

k8s/helm/apigwmm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
replicaCount: 1
22
clusterName: eshop-aks
3-
pathBase: /apigwmm
3+
pathBase: /mobilemarketingapigw
44

55
image:
66
repository: eshop/ocelotapigw

k8s/helm/apigwms/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
replicaCount: 1
22
clusterName: eshop-aks
3-
pathBase: /apigwms
3+
pathBase: /mobileshoppingapigw
44

55
image:
66
repository: eshop/ocelotapigw

k8s/helm/apigwwm/.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/apigwwm/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: apigwwm
5+
version: 0.1.0
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"ReRoutes": [
3+
{
4+
"DownstreamPathTemplate": "/api/{version}/{everything}",
5+
"DownstreamScheme": "http",
6+
"DownstreamHostAndPorts": [
7+
{
8+
"Host": "marketing",
9+
"Port": 80
10+
}
11+
],
12+
"UpstreamPathTemplate": "/api/{version}/m/{everything}",
13+
"UpstreamHttpMethod": []
14+
},
15+
{
16+
"DownstreamPathTemplate": "/api/{version}/{everything}",
17+
"DownstreamScheme": "http",
18+
"DownstreamHostAndPorts": [
19+
{
20+
"Host": "locations",
21+
"Port": 80
22+
}
23+
],
24+
"UpstreamPathTemplate": "/api/{version}/l/{everything}",
25+
"UpstreamHttpMethod": []
26+
}
27+
28+
],
29+
"GlobalConfiguration": {
30+
"RequestIdKey": "OcRequestId",
31+
"AdministrationPath": "/administration"
32+
}
33+
}
34+
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 "apigwwm.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 "apigwwm.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwwm.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 "apigwwm.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 "apigwwm.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 "apigwwm.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 "apigwwm.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 "apigwwm.fullname" . -}}
2+
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: "cfg-{{ $name }}"
7+
labels:
8+
app: {{ template "apigwwm.name" . }}
9+
chart: {{ template "apigwwm.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 "apigwwm.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 "apigwwm.fullname" . }}
8+
labels:
9+
ufo: {{ $cfgname}}
10+
app: {{ template "apigwwm.name" . }}
11+
chart: {{ template "apigwwm.chart" . }}
12+
release: {{ .Release.Name }}
13+
heritage: {{ .Release.Service }}
14+
spec:
15+
replicas: {{ .Values.replicaCount }}
16+
selector:
17+
matchLabels:
18+
app: {{ template "apigwwm.name" . }}
19+
release: {{ .Release.Name }}
20+
template:
21+
metadata:
22+
labels:
23+
app: {{ template "apigwwm.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: wm
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)