Browse Source

web shopping apigw

pull/867/head
eiximenis 6 years ago
parent
commit
59729c74ea
12 changed files with 485 additions and 0 deletions
  1. +21
    -0
      k8s/helm/apigwws/.helmignore
  2. +5
    -0
      k8s/helm/apigwws/Chart.yaml
  3. +154
    -0
      k8s/helm/apigwws/configuration-web-shopping.json
  4. +19
    -0
      k8s/helm/apigwws/templates/NOTES.txt
  5. +32
    -0
      k8s/helm/apigwws/templates/_helpers.tpl
  6. +49
    -0
      k8s/helm/apigwws/templates/_names.tpl
  7. +14
    -0
      k8s/helm/apigwws/templates/configmap.yaml
  8. +84
    -0
      k8s/helm/apigwws/templates/deployment.yaml
  9. +34
    -0
      k8s/helm/apigwws/templates/ingress.yaml
  10. +15
    -0
      k8s/helm/apigwws/templates/ocelot-cm.yaml
  11. +19
    -0
      k8s/helm/apigwws/templates/service.yaml
  12. +39
    -0
      k8s/helm/apigwws/values.yaml

+ 21
- 0
k8s/helm/apigwws/.helmignore View File

@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj

+ 5
- 0
k8s/helm/apigwws/Chart.yaml View File

@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: apigwws
version: 0.1.0

+ 154
- 0
k8s/helm/apigwws/configuration-web-shopping.json View File

@ -0,0 +1,154 @@
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/{version}/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "catalog",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
"UpstreamHttpMethod": [ "GET" ]
},
{
"DownstreamPathTemplate": "/api/{version}/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "basket",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
"UpstreamHttpMethod": [],
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": []
}
},
{
"DownstreamPathTemplate": "/api/{version}/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "ordering",
"Port": 80
}
],
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
"UpstreamHttpMethod": [],
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": []
}
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "webshoppingagg",
"Port": 80
}
],
"UpstreamPathTemplate": "/{everything}",
"UpstreamHttpMethod": [ "POST", "PUT", "GET" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "IdentityApiKey",
"AllowedScopes": []
}
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "ordering",
"Port": 80
}
],
"UpstreamPathTemplate": "/orders-api/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "ordering-signalrhub",
"Port": 80
}
],
"UpstreamPathTemplate": "/hub/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "basket",
"Port": 80
}
],
"UpstreamPathTemplate": "/basket-api/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "catalog",
"Port": 80
}
],
"UpstreamPathTemplate": "/catalog-api/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "marketing",
"Port": 80
}
],
"UpstreamPathTemplate": "/marketing-api/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "payment",
"Port": 80
}
],
"UpstreamPathTemplate": "/payment-api/{everything}",
"UpstreamHttpMethod": []
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "locations.api",
"Port": 80
}
],
"UpstreamPathTemplate": "/location-api/{everything}",
"UpstreamHttpMethod": []
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration"
}
}

+ 19
- 0
k8s/helm/apigwws/templates/NOTES.txt View File

@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwws.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "apigwws.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwws.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwws.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}

+ 32
- 0
k8s/helm/apigwws/templates/_helpers.tpl View File

@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "apigwws.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "apigwws.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "apigwws.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

+ 49
- 0
k8s/helm/apigwws/templates/_names.tpl View File

@ -0,0 +1,49 @@
{{- define "suffix-name" -}}
{{- if .Values.app.name -}}
{{- .Values.app.name -}}
{{- else -}}
{{- .Release.Name -}}
{{- end -}}
{{- end -}}
{{- define "sql-name" -}}
{{- if .Values.inf.sql.host -}}
{{- .Values.inf.sql.host -}}
{{- else -}}
{{- printf "%s" "sql-data" -}}
{{- end -}}
{{- end -}}
{{- define "mongo-name" -}}
{{- if .Values.inf.mongo.host -}}
{{- .Values.inf.mongo.host -}}
{{- else -}}
{{- printf "%s" "nosql-data" -}}
{{- end -}}
{{- end -}}
{{- define "url-of" -}}
{{- $name := first .}}
{{- $ctx := last .}}
{{- $suffix := include "suffix-name" $ctx -}}
{{- if $ctx.Values.inf.k8s.dnsprefix -}}
{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is <prefix>.<dns>/<name> */}}
{{- else -}}
{{- if $ctx.Values.inf.k8s.suffix -}}
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is <dns>/<name>-<sufix> */}}
{{- else -}}
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just <dns>/<name> */}}
{{- end -}}
{{- end -}}
{{- end -}}
{{ define "pathBase" -}}
{{- if .Values.inf.k8s.suffix -}}
{{- $suffix := include "suffix-name" . -}}
{{- printf "%s-%s" .Values.pathBase $suffix -}}
{{- else -}}
{{- .Values.pathBase -}}
{{- end -}}
{{- end -}}

+ 14
- 0
k8s/helm/apigwws/templates/configmap.yaml View File

@ -0,0 +1,14 @@
{{- $name := include "apigwws.fullname" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: "cfg-{{ $name }}"
labels:
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" .}}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
internalurls__identity: http://{{ .Values.app.svc.identity }}

+ 84
- 0
k8s/helm/apigwws/templates/deployment.yaml View File

@ -0,0 +1,84 @@
{{- $name := include "apigwws.fullname" . -}}
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}}
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "apigwws.fullname" . }}
labels:
ufo: {{ $cfgname}}
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "apigwws.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "apigwws.name" . }}
release: {{ .Release.Name }}
spec:
{{ if .Values.imagePullSecrets -}}
imagePullSecrets:
{{ range .Values.imagePullSecrets -}}
- name: {{ .name }}
{{- end -}}
{{- end }}
volumes:
- name: config
configMap:
name: {{ $ocelotcfgname }}
items:
- key: ws
path: configuration.json
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: config
mountPath: /app/configuration
env:
- name: PATH_BASE
value: {{ include "pathBase" . }}
- name: k8sname
value: {{ .Values.clusterName }}
{{- if .Values.env.values -}}
{{- range .Values.env.values }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end -}}
{{- end -}}
{{- if .Values.env.configmap -}}
{{- range .Values.env.configmap }}
- name: {{ .name }}
valueFrom:
configMapKeyRef:
name: {{ $cfgname }}
key: {{ .key }}
{{- end -}}
{{- end }}
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

+ 34
- 0
k8s/helm/apigwws/templates/ingress.yaml View File

@ -0,0 +1,34 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "apigwws.fullname" . -}}
{{- $ingressPath := include "pathBase" . -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
- {{ .Values.inf.k8s.dns }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ .Values.inf.k8s.dns }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}

+ 15
- 0
k8s/helm/apigwws/templates/ocelot-cm.yaml View File

@ -0,0 +1,15 @@
{{- $name := include "apigwws.fullname" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: "ocelot-{{ $name }}"
labels:
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" .}}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
ws: |-
{{ (.Files.Glob "configuration-web-shopping.json").AsConfig }}

+ 19
- 0
k8s/helm/apigwws/templates/service.yaml View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.app.svc.webshoppingapigw }}
labels:
app: {{ template "apigwws.name" . }}
chart: {{ template "apigwws.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ template "apigwws.name" . }}
release: {{ .Release.Name }}

+ 39
- 0
k8s/helm/apigwws/values.yaml View File

@ -0,0 +1,39 @@
replicaCount: 1
clusterName: eshop-aks
pathBase: /webshoppingapigw
image:
repository: eshop/ocelotapigw
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
tls: []
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}
# env defines the environment variables that will be declared in the pod
env:
urls:
# configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap).
configmap:
- name: urls__identity
key: internalurls__identity
# values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value)
values:
- name: ASPNETCORE_ENVIRONMENT
value: Development

Loading…
Cancel
Save