diff --git a/k8s/helm/aks-httpaddon-cfg.yaml b/k8s/helm/aks-httpaddon-cfg.yaml new file mode 100644 index 000000000..b9576b0b6 --- /dev/null +++ b/k8s/helm/aks-httpaddon-cfg.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: +# addonmanager.kubernetes.io/mode: Reconcile + app: addon-http-application-routing-ingress-nginx + kubernetes.io/cluster-service: "true" + name: addon-http-application-routing-nginx-configuration + namespace: kube-system +data: + proxy-buffer-size: "128k" + proxy-buffers: "4 256k" diff --git a/k8s/helm/apigwmm/.helmignore b/k8s/helm/apigwmm/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/apigwmm/.helmignore @@ -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 diff --git a/k8s/helm/apigwmm/Chart.yaml b/k8s/helm/apigwmm/Chart.yaml new file mode 100644 index 000000000..50b3d07c6 --- /dev/null +++ b/k8s/helm/apigwmm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: apigwmm +version: 0.1.0 diff --git a/k8s/helm/apigwmm/configuration-mobile-marketing.json b/k8s/helm/apigwmm/configuration-mobile-marketing.json new file mode 100644 index 000000000..666df1633 --- /dev/null +++ b/k8s/helm/apigwmm/configuration-mobile-marketing.json @@ -0,0 +1,34 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} + \ No newline at end of file diff --git a/k8s/helm/apigwmm/templates/NOTES.txt b/k8s/helm/apigwmm/templates/NOTES.txt new file mode 100644 index 000000000..30ef33447 --- /dev/null +++ b/k8s/helm/apigwmm/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop API Gateway for Mobile Marketing services installed +---------------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwmm/templates/_helpers.tpl b/k8s/helm/apigwmm/templates/_helpers.tpl new file mode 100644 index 000000000..fd3d89212 --- /dev/null +++ b/k8s/helm/apigwmm/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "apigwmm.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 "apigwmm.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 "apigwmm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/apigwmm/templates/_names.tpl b/k8s/helm/apigwmm/templates/_names.tpl new file mode 100644 index 000000000..a6eeb9965 --- /dev/null +++ b/k8s/helm/apigwmm/templates/_names.tpl @@ -0,0 +1,53 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} +{{- else -}} +{{- printf "/%s" $name -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwmm/templates/configmap.yaml b/k8s/helm/apigwmm/templates/configmap.yaml new file mode 100644 index 000000000..2bd39aff5 --- /dev/null +++ b/k8s/helm/apigwmm/templates/configmap.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwmm.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "apigwmm.name" . }} + chart: {{ template "apigwmm.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + internalurls__identity: http://{{ .Values.app.svc.identity }} + diff --git a/k8s/helm/apigwmm/templates/deployment.yaml b/k8s/helm/apigwmm/templates/deployment.yaml new file mode 100644 index 000000000..2e30c78e7 --- /dev/null +++ b/k8s/helm/apigwmm/templates/deployment.yaml @@ -0,0 +1,82 @@ +{{- $name := include "apigwmm.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "apigwmm.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "apigwmm.name" . }} + chart: {{ template "apigwmm.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "apigwmm.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "apigwmm.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: configuration-mobile-marketing.json + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) }} + - 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 }} + diff --git a/k8s/helm/apigwmm/templates/ingress.yaml b/k8s/helm/apigwmm/templates/ingress.yaml new file mode 100644 index 000000000..28e2aa84d --- /dev/null +++ b/k8s/helm/apigwmm/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "apigwmm.fullname" . }} + labels: + app: {{ template "apigwmm.name" . }} + chart: {{ template "apigwmm.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: {{ .Values.app.svc.mobilemarketingapigw }} + servicePort: http +{{- end }} diff --git a/k8s/helm/apigwmm/templates/ocelot-cm.yaml b/k8s/helm/apigwmm/templates/ocelot-cm.yaml new file mode 100644 index 000000000..c7c20ce06 --- /dev/null +++ b/k8s/helm/apigwmm/templates/ocelot-cm.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwmm.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "ocelot-{{ $name }}" + labels: + app: {{ template "apigwmm.name" . }} + chart: {{ template "apigwmm.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + {{ (.Files.Glob "configuration-mobile-marketing.json").AsConfig | indent 2 }} + diff --git a/k8s/helm/apigwmm/templates/service.yaml b/k8s/helm/apigwmm/templates/service.yaml new file mode 100644 index 000000000..dac59b23a --- /dev/null +++ b/k8s/helm/apigwmm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.mobilemarketingapigw }} + labels: + app: {{ template "apigwmm.name" . }} + chart: {{ template "apigwmm.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 "apigwmm.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/apigwmm/values.yaml b/k8s/helm/apigwmm/values.yaml new file mode 100644 index 000000000..eeb379c38 --- /dev/null +++ b/k8s/helm/apigwmm/values.yaml @@ -0,0 +1,39 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /mobilemarketingapigw + +image: + repository: eshop/ocelotapigw + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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 + diff --git a/k8s/helm/apigwms/.helmignore b/k8s/helm/apigwms/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/apigwms/.helmignore @@ -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 diff --git a/k8s/helm/apigwms/Chart.yaml b/k8s/helm/apigwms/Chart.yaml new file mode 100644 index 000000000..3ad3fdf46 --- /dev/null +++ b/k8s/helm/apigwms/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: apigwms +version: 0.1.0 diff --git a/k8s/helm/apigwms/configuration-mobile-shopping.json b/k8s/helm/apigwms/configuration-mobile-shopping.json new file mode 100644 index 000000000..cf3a48aff --- /dev/null +++ b/k8s/helm/apigwms/configuration-mobile-shopping.json @@ -0,0 +1,142 @@ +{ + "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": "mobileshoppingagg", + "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": "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" + } + } + \ No newline at end of file diff --git a/k8s/helm/apigwms/templates/NOTES.txt b/k8s/helm/apigwms/templates/NOTES.txt new file mode 100644 index 000000000..74b3eedda --- /dev/null +++ b/k8s/helm/apigwms/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop API Gateway for Mobile Shopping services installed +-------------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwms/templates/_helpers.tpl b/k8s/helm/apigwms/templates/_helpers.tpl new file mode 100644 index 000000000..2ae403c2f --- /dev/null +++ b/k8s/helm/apigwms/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "apigwms.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 "apigwms.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 "apigwms.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/apigwms/templates/_names.tpl b/k8s/helm/apigwms/templates/_names.tpl new file mode 100644 index 000000000..1e840c56c --- /dev/null +++ b/k8s/helm/apigwms/templates/_names.tpl @@ -0,0 +1,54 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} +{{- else -}} +{{- printf "/%s" $name -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwms/templates/configmap.yaml b/k8s/helm/apigwms/templates/configmap.yaml new file mode 100644 index 000000000..7e93362d8 --- /dev/null +++ b/k8s/helm/apigwms/templates/configmap.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwms.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + internalurls__identity: http://{{ .Values.app.svc.identity }} + diff --git a/k8s/helm/apigwms/templates/deployment.yaml b/k8s/helm/apigwms/templates/deployment.yaml new file mode 100644 index 000000000..2c8a43050 --- /dev/null +++ b/k8s/helm/apigwms/templates/deployment.yaml @@ -0,0 +1,82 @@ +{{- $name := include "apigwms.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "apigwms.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "apigwms.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "apigwms.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: configuration-mobile-shopping.json + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) }} + - 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 }} + diff --git a/k8s/helm/apigwms/templates/ingress.yaml b/k8s/helm/apigwms/templates/ingress.yaml new file mode 100644 index 000000000..7dd50d8dd --- /dev/null +++ b/k8s/helm/apigwms/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "apigwms.fullname" . }} + labels: + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.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: {{ .Values.app.svc.mobileshoppingapigw }} + servicePort: http +{{- end }} diff --git a/k8s/helm/apigwms/templates/ocelot-cm.yaml b/k8s/helm/apigwms/templates/ocelot-cm.yaml new file mode 100644 index 000000000..5f92ca409 --- /dev/null +++ b/k8s/helm/apigwms/templates/ocelot-cm.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwms.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "ocelot-{{ $name }}" + labels: + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + {{ (.Files.Glob "configuration-mobile-shopping.json").AsConfig | indent 2 }} + diff --git a/k8s/helm/apigwms/templates/service.yaml b/k8s/helm/apigwms/templates/service.yaml new file mode 100644 index 000000000..2a37d3c14 --- /dev/null +++ b/k8s/helm/apigwms/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.mobileshoppingapigw }} + labels: + app: {{ template "apigwms.name" . }} + chart: {{ template "apigwms.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 "apigwms.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/apigwms/values.yaml b/k8s/helm/apigwms/values.yaml new file mode 100644 index 000000000..2659cb8cb --- /dev/null +++ b/k8s/helm/apigwms/values.yaml @@ -0,0 +1,39 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /mobileshoppingapigw + +image: + repository: eshop/ocelotapigw + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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 + diff --git a/k8s/helm/apigwwm/.helmignore b/k8s/helm/apigwwm/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/apigwwm/.helmignore @@ -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 diff --git a/k8s/helm/apigwwm/Chart.yaml b/k8s/helm/apigwwm/Chart.yaml new file mode 100644 index 000000000..4c2082969 --- /dev/null +++ b/k8s/helm/apigwwm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: apigwwm +version: 0.1.0 diff --git a/k8s/helm/apigwwm/configuration-web-marketing.json b/k8s/helm/apigwwm/configuration-web-marketing.json new file mode 100644 index 000000000..666df1633 --- /dev/null +++ b/k8s/helm/apigwwm/configuration-web-marketing.json @@ -0,0 +1,34 @@ +{ + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "marketing", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/m/{everything}", + "UpstreamHttpMethod": [] + }, + { + "DownstreamPathTemplate": "/api/{version}/{everything}", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "locations", + "Port": 80 + } + ], + "UpstreamPathTemplate": "/api/{version}/l/{everything}", + "UpstreamHttpMethod": [] + } + + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration" + } +} + \ No newline at end of file diff --git a/k8s/helm/apigwwm/templates/NOTES.txt b/k8s/helm/apigwwm/templates/NOTES.txt new file mode 100644 index 000000000..3420c97c8 --- /dev/null +++ b/k8s/helm/apigwwm/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop API Gateway for Web Marketing services installed +------------------------------------------------------ \ No newline at end of file diff --git a/k8s/helm/apigwwm/templates/_helpers.tpl b/k8s/helm/apigwwm/templates/_helpers.tpl new file mode 100644 index 000000000..194cf96ca --- /dev/null +++ b/k8s/helm/apigwwm/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "apigwwm.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 "apigwwm.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 "apigwwm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/apigwwm/templates/_names.tpl b/k8s/helm/apigwwm/templates/_names.tpl new file mode 100644 index 000000000..1e840c56c --- /dev/null +++ b/k8s/helm/apigwwm/templates/_names.tpl @@ -0,0 +1,54 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} +{{- else -}} +{{- printf "/%s" $name -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwwm/templates/configmap.yaml b/k8s/helm/apigwwm/templates/configmap.yaml new file mode 100644 index 000000000..2e27194d1 --- /dev/null +++ b/k8s/helm/apigwwm/templates/configmap.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwwm.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "apigwwm.name" . }} + chart: {{ template "apigwwm.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + internalurls__identity: http://{{ .Values.app.svc.identity }} + diff --git a/k8s/helm/apigwwm/templates/deployment.yaml b/k8s/helm/apigwwm/templates/deployment.yaml new file mode 100644 index 000000000..1e0e58888 --- /dev/null +++ b/k8s/helm/apigwwm/templates/deployment.yaml @@ -0,0 +1,82 @@ +{{- $name := include "apigwwm.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "apigwwm.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "apigwwm.name" . }} + chart: {{ template "apigwwm.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "apigwwm.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "apigwwm.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: configuration-web-marketing.json + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) }} + - 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 }} + diff --git a/k8s/helm/apigwwm/templates/ingress.yaml b/k8s/helm/apigwwm/templates/ingress.yaml new file mode 100644 index 000000000..0a79c4660 --- /dev/null +++ b/k8s/helm/apigwwm/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "apigwwm.fullname" . }} + labels: + app: {{ template "apigwwm.name" . }} + chart: {{ template "apigwwm.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: {{ .Values.app.svc.webmarketingapigw }} + servicePort: http +{{- end }} diff --git a/k8s/helm/apigwwm/templates/ocelot-cm.yaml b/k8s/helm/apigwwm/templates/ocelot-cm.yaml new file mode 100644 index 000000000..3de28b1a1 --- /dev/null +++ b/k8s/helm/apigwwm/templates/ocelot-cm.yaml @@ -0,0 +1,14 @@ +{{- $name := include "apigwwm.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "ocelot-{{ $name }}" + labels: + app: {{ template "apigwwm.name" . }} + chart: {{ template "apigwwm.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + {{ (.Files.Glob "configuration-web-marketing.json").AsConfig | indent 2 -}} + diff --git a/k8s/helm/apigwwm/templates/service.yaml b/k8s/helm/apigwwm/templates/service.yaml new file mode 100644 index 000000000..0ee3c4fb0 --- /dev/null +++ b/k8s/helm/apigwwm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.webmarketingapigw }} + labels: + app: {{ template "apigwwm.name" . }} + chart: {{ template "apigwwm.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 "apigwwm.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/apigwwm/values.yaml b/k8s/helm/apigwwm/values.yaml new file mode 100644 index 000000000..989a5c8c6 --- /dev/null +++ b/k8s/helm/apigwwm/values.yaml @@ -0,0 +1,39 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /webmarketingapigw + +image: + repository: eshop/ocelotapigw + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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 + diff --git a/k8s/helm/apigwws/.helmignore b/k8s/helm/apigwws/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/apigwws/.helmignore @@ -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 diff --git a/k8s/helm/apigwws/Chart.yaml b/k8s/helm/apigwws/Chart.yaml new file mode 100644 index 000000000..0a6c34e62 --- /dev/null +++ b/k8s/helm/apigwws/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: apigwws +version: 0.1.0 diff --git a/k8s/helm/apigwws/configuration-web-shopping.json b/k8s/helm/apigwws/configuration-web-shopping.json new file mode 100644 index 000000000..021056f43 --- /dev/null +++ b/k8s/helm/apigwws/configuration-web-shopping.json @@ -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" + } + } + \ No newline at end of file diff --git a/k8s/helm/apigwws/templates/NOTES.txt b/k8s/helm/apigwws/templates/NOTES.txt new file mode 100644 index 000000000..8214afb1e --- /dev/null +++ b/k8s/helm/apigwws/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop API Gateway for Web Shopping services installed +----------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwws/templates/_helpers.tpl b/k8s/helm/apigwws/templates/_helpers.tpl new file mode 100644 index 000000000..b6aa6b483 --- /dev/null +++ b/k8s/helm/apigwws/templates/_helpers.tpl @@ -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 -}} diff --git a/k8s/helm/apigwws/templates/_names.tpl b/k8s/helm/apigwws/templates/_names.tpl new file mode 100644 index 000000000..a6eeb9965 --- /dev/null +++ b/k8s/helm/apigwws/templates/_names.tpl @@ -0,0 +1,53 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} +{{- else -}} +{{- printf "/%s" $name -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwws/templates/configmap.yaml b/k8s/helm/apigwws/templates/configmap.yaml new file mode 100644 index 000000000..e5dc17201 --- /dev/null +++ b/k8s/helm/apigwws/templates/configmap.yaml @@ -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 }} + diff --git a/k8s/helm/apigwws/templates/deployment.yaml b/k8s/helm/apigwws/templates/deployment.yaml new file mode 100644 index 000000000..b52e77042 --- /dev/null +++ b/k8s/helm/apigwws/templates/deployment.yaml @@ -0,0 +1,82 @@ +{{- $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.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: configuration-web-shopping.json + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) }} + - 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 }} + diff --git a/k8s/helm/apigwws/templates/ingress.yaml b/k8s/helm/apigwws/templates/ingress.yaml new file mode 100644 index 000000000..ee1f681ad --- /dev/null +++ b/k8s/helm/apigwws/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "apigwws.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: {{ .Values.app.svc.webshoppingapigw }} + servicePort: http +{{- end }} diff --git a/k8s/helm/apigwws/templates/ocelot-cm.yaml b/k8s/helm/apigwws/templates/ocelot-cm.yaml new file mode 100644 index 000000000..39b27f29a --- /dev/null +++ b/k8s/helm/apigwws/templates/ocelot-cm.yaml @@ -0,0 +1,14 @@ +{{- $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: + {{ (.Files.Glob "configuration-web-shopping.json").AsConfig | indent 2 }} + diff --git a/k8s/helm/apigwws/templates/service.yaml b/k8s/helm/apigwws/templates/service.yaml new file mode 100644 index 000000000..5d74c2ad0 --- /dev/null +++ b/k8s/helm/apigwws/templates/service.yaml @@ -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 }} diff --git a/k8s/helm/apigwws/values.yaml b/k8s/helm/apigwws/values.yaml new file mode 100644 index 000000000..f2f839a05 --- /dev/null +++ b/k8s/helm/apigwws/values.yaml @@ -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: true + 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 + diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml new file mode 100644 index 000000000..6ca5d9d31 --- /dev/null +++ b/k8s/helm/app.yaml @@ -0,0 +1,43 @@ +# This heml values file defines app-based settings +# Charts use those values, so this file **MUST** be included in all chart releases + + +app: # app global settings + name: "my-eshop" # Override for custom app name + ingress: # ingress related settings + entries: + basket: basket-api # ingress entry for basket api + catalog: catalog-api # ingress entry for catalog api + ordering: ordering-api # ingress entry for ordering api + identity: identity # ingress entry for identity api + mvc: webmvc # ingress entry for web mvc + spa: "" # ingress entry for web spa + status: webstatus # ingress entry for web status + webshoppingapigw: webshoppingapigw # ingress entry for web shopping Agw + webmarketingapigw: webmarketingapigw # ingress entry for web mkg Agw + mobilemarketingapigw: mobilemarketingapigw # ingress entry for mobile mkg Agw + mobileshoppingapigw: mobileshoppingapigw # ingress entry for mobile shopping Agw + webshoppingagg: webshoppingagg # ingress entry for web shopping aggregator + mobileshoppingagg: mobileshoppingagg # ingress entry for mobile shopping aggregator + payment: payment-api # ingress entry for payment api + locations: locations-api # ingress entry for locations api + marketing: marketing-api # ingress entry for marketing api + svc: + basket: basket # service name for basket api + catalog: catalog # service name for catalog api + ordering: ordering # service name for ordering api + orderingbackgroundtasks: orderingbackgroundtasks # service name for orderingbackgroundtasks + orderingsignalrhub: orderingsignalrhub # service name for orderingsignalrhub + identity: identity # service name for identity api + mvc: webmvc # service name for web mvc + spa: webspa # service name for web spa + status: webstatus # service name for web status + webshoppingapigw: webshoppingapigw # service name for web shopping Agw + webmarketingapigw: webmarketingapigw # service name for web mkg Agw + mobilemarketingapigw: mobilemarketingapigw # service name for mobile mkg Agw + mobileshoppingapigw: mobileshoppingapigw # service name for mobile shopping Agw + webshoppingagg: webshoppingagg # service name for web shopping aggregator + mobileshoppingagg: mobileshoppingagg # service name for mobile shopping aggregator + payment: payment # service name for payment api + locations: locations # service name for locations api + marketing: marketing # service name for marketing ap diff --git a/k8s/helm/basket-api/.helmignore b/k8s/helm/basket-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/basket-api/.helmignore @@ -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 diff --git a/k8s/helm/basket-api/Chart.yaml b/k8s/helm/basket-api/Chart.yaml new file mode 100644 index 000000000..fd3e01486 --- /dev/null +++ b/k8s/helm/basket-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: basket-api +version: 0.1.0 diff --git a/k8s/helm/basket-api/templates/NOTES.txt b/k8s/helm/basket-api/templates/NOTES.txt new file mode 100644 index 000000000..8ba2c89ee --- /dev/null +++ b/k8s/helm/basket-api/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Basket API installed. +-------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "basket-api.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 \ No newline at end of file diff --git a/k8s/helm/basket-api/templates/_helpers.tpl b/k8s/helm/basket-api/templates/_helpers.tpl new file mode 100644 index 000000000..550eb2e6c --- /dev/null +++ b/k8s/helm/basket-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "basket-api.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 "basket-api.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 "basket-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/basket-api/templates/configmap.yaml b/k8s/helm/basket-api/templates/configmap.yaml new file mode 100644 index 000000000..c851de359 --- /dev/null +++ b/k8s/helm/basket-api/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- $name := include "basket-api.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "basket-api.name" . }} + chart: {{ template "basket-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + basket__ConnectionString: {{ .Values.inf.redis.basket.constr }} + urls__IdentityUrl: http://{{ $identity }} + basket__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/k8s/helm/basket-api/templates/deployment.yaml b/k8s/helm/basket-api/templates/deployment.yaml new file mode 100644 index 000000000..ee283122c --- /dev/null +++ b/k8s/helm/basket-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "basket-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "basket-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "basket-api.name" . }} + chart: {{ template "basket-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "basket-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "basket-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/basket-api/templates/service.yaml b/k8s/helm/basket-api/templates/service.yaml new file mode 100644 index 000000000..20224c3b5 --- /dev/null +++ b/k8s/helm/basket-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.basket }} + labels: + app: {{ template "basket-api.name" . }} + chart: {{ template "basket-api.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 "basket-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/basket-api/values.yaml b/k8s/helm/basket-api/values.yaml new file mode 100644 index 000000000..892fdf584 --- /dev/null +++ b/k8s/helm/basket-api/values.yaml @@ -0,0 +1,43 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /basket-api + +image: + repository: eshop/basket.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +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: ConnectionString + key: basket__ConnectionString + - name: EventBusConnection + key: all__EventBusConnection + - name: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: IdentityUrl + key: urls__IdentityUrl + - name: UseLoadTest + key: basket__EnableLoadTest + # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) + values: + - name: OrchestratorType + value: 'K8S' diff --git a/k8s/helm/basket-data/.helmignore b/k8s/helm/basket-data/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/basket-data/.helmignore @@ -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 diff --git a/k8s/helm/basket-data/Chart.yaml b/k8s/helm/basket-data/Chart.yaml new file mode 100644 index 000000000..67ceddee1 --- /dev/null +++ b/k8s/helm/basket-data/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: basket-data +version: 0.1.0 diff --git a/k8s/helm/basket-data/templates/NOTES.txt b/k8s/helm/basket-data/templates/NOTES.txt new file mode 100644 index 000000000..c10513333 --- /dev/null +++ b/k8s/helm/basket-data/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Redis for keystore data installed +---------------------------------------- + +Redis is not directly exposed outside cluster. If need to access it from outside use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "basket-data.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 \ No newline at end of file diff --git a/k8s/helm/basket-data/templates/_helpers.tpl b/k8s/helm/basket-data/templates/_helpers.tpl new file mode 100644 index 000000000..74b51b089 --- /dev/null +++ b/k8s/helm/basket-data/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "basket-data.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 "basket-data.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 "basket-data.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/basket-data/templates/deployment.yaml b/k8s/helm/basket-data/templates/deployment.yaml new file mode 100644 index 000000000..8ccceceeb --- /dev/null +++ b/k8s/helm/basket-data/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "basket-data.fullname" . }} + labels: + app: {{ template "basket-data.name" . }} + chart: {{ template "basket-data.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "basket-data.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "basket-data.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 6379 + 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 }} diff --git a/k8s/helm/basket-data/templates/service.yaml b/k8s/helm/basket-data/templates/service.yaml new file mode 100644 index 000000000..98b8cc3bd --- /dev/null +++ b/k8s/helm/basket-data/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.inf.redis.basket.svc }} + labels: + app: {{ template "basket-data.name" . }} + chart: {{ template "basket-data.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 "basket-data.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/basket-data/values.yaml b/k8s/helm/basket-data/values.yaml new file mode 100644 index 000000000..17cc75ee7 --- /dev/null +++ b/k8s/helm/basket-data/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: redis + tag: 4.0.10 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 6379 + + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/helm/catalog-api/.helmignore b/k8s/helm/catalog-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/catalog-api/.helmignore @@ -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 diff --git a/k8s/helm/catalog-api/Chart.yaml b/k8s/helm/catalog-api/Chart.yaml new file mode 100644 index 000000000..a143a0afe --- /dev/null +++ b/k8s/helm/catalog-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: catalog-api +version: 0.1.0 diff --git a/k8s/helm/catalog-api/templates/NOTES.txt b/k8s/helm/catalog-api/templates/NOTES.txt new file mode 100644 index 000000000..1f01a2b92 --- /dev/null +++ b/k8s/helm/catalog-api/templates/NOTES.txt @@ -0,0 +1,9 @@ +eShop Catalog API installed. +---------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "catalog-api.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 + diff --git a/k8s/helm/catalog-api/templates/_helpers.tpl b/k8s/helm/catalog-api/templates/_helpers.tpl new file mode 100644 index 000000000..6fd128e77 --- /dev/null +++ b/k8s/helm/catalog-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "catalog-api.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 "catalog-api.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 "catalog-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/catalog-api/templates/configmap.yaml b/k8s/helm/catalog-api/templates/configmap.yaml new file mode 100644 index 000000000..95d8f2f9b --- /dev/null +++ b/k8s/helm/catalog-api/templates/configmap.yaml @@ -0,0 +1,20 @@ +{{- $name := include "catalog-api.fullname" . -}} +{{- $sqlsrv := include "sql-name" . -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "catalog-api.name" . }} + chart: {{ template "catalog-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + catalog__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.catalog.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; + catalog__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/ + catalog__AzureStorageEnabled: "{{ .Values.inf.misc.useAzureStorage }}" + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/k8s/helm/catalog-api/templates/deployment.yaml b/k8s/helm/catalog-api/templates/deployment.yaml new file mode 100644 index 000000000..99e270af9 --- /dev/null +++ b/k8s/helm/catalog-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "catalog-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "catalog-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "catalog-api.name" . }} + chart: {{ template "catalog-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "catalog-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "catalog-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/catalog-api/templates/service.yaml b/k8s/helm/catalog-api/templates/service.yaml new file mode 100644 index 000000000..e63d4a4fc --- /dev/null +++ b/k8s/helm/catalog-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.catalog }} + labels: + app: {{ template "catalog-api.name" . }} + chart: {{ template "catalog-api.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 "catalog-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/catalog-api/values.yaml b/k8s/helm/catalog-api/values.yaml new file mode 100644 index 000000000..e0306a824 --- /dev/null +++ b/k8s/helm/catalog-api/values.yaml @@ -0,0 +1,47 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /catalog-api + +image: + repository: eshop/catalog.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + + +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: ConnectionString + key: catalog__ConnectionString + - name: PicBaseUrl + key: catalog__PicBaseUrl + - name: AzureStorageEnabled + key: catalog__AzureStorageEnabled + - name: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/deploy-all.ps1 b/k8s/helm/deploy-all.ps1 new file mode 100644 index 000000000..1239cc7af --- /dev/null +++ b/k8s/helm/deploy-all.ps1 @@ -0,0 +1,81 @@ +Param( + [parameter(Mandatory=$false)][string]$registry, + [parameter(Mandatory=$false)][string]$dockerUser, + [parameter(Mandatory=$false)][string]$dockerPassword, + [parameter(Mandatory=$false)][string]$externalDns, + [parameter(Mandatory=$false)][string]$appName="eshop", + [parameter(Mandatory=$false)][bool]$deployInfrastructure=$true, + [parameter(Mandatory=$false)][bool]$clean=$true, + [parameter(Mandatory=$false)][string]$aksName="", + [parameter(Mandatory=$false)][string]$aksRg="", + [parameter(Mandatory=$false)][string]$imageTag="latest" +) + +$dns = $externalDns + +if ($externalDns -eq "aks") { + if ([string]::IsNullOrEmpty($aksName) -or [string]::IsNullOrEmpty($aksRg)) { + Write-Host "Error: When using -dns aks, MUST set -aksName and -aksRg too." -ForegroundColor Red + exit 1 + } + Write-Host "Getting DNS of AKS of AKS $aksName (in resource group $aksRg)..." -ForegroundColor Green + $dns = $(az aks show -n $aksName -g $aksRg --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName) + if ([string]::IsNullOrEmpty($dns)) { + Write-Host "Error getting DNS of AKS $aksName (in resource group $aksRg). Please ensure AKS has httpRouting enabled AND Azure CLI is logged & in version 2.0.37 or higher" -ForegroundColor Red + exit 1 + } + $dns = $dns -replace '[\"]' + Write-Host "DNS base found is $dns. Will use $appName.$dns for the app!" -ForegroundColor Green + $dns = "$appName.$dns" +} + +# Initialization & check commands +if ([string]::IsNullOrEmpty($dns)) { + Write-Host "No DNS specified. Ingress resources will be bound to public ip" -ForegroundColor Yellow +} + +if ($clean) { + Write-Host "Cleaning previous helm releases..." -ForegroundColor Green + helm delete --purge $(helm ls -q) + Write-Host "Previous releases deleted" -ForegroundColor Green +} + +$useCustomRegistry=$false + +if (-not [string]::IsNullOrEmpty($registry)) { + $useCustomRegistry=$true + if ([string]::IsNullOrEmpty($dockerUser) -or [string]::IsNullOrEmpty($dockerPassword)) { + Write-Host "Error: Must use -dockerUser AND -dockerPassword if specifying custom registry" -ForegroundColor Red + exit 1 + } +} + +Write-Host "Begin eShopOnContainers installation using Helm" -ForegroundColor Green + +$infras = ("sql-data", "nosql-data", "rabbitmq", "keystore-data", "basket-data") +$charts = ("eshop-common", "apigwmm", "apigwms", "apigwwm", "apigwws", "basket-api","catalog-api", "identity-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus") + +if ($deployInfrastructure) { + foreach ($infra in $infras) { + Write-Host "Installing infrastructure: $infra" -ForegroundColor Green + helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra + } +} + +foreach ($chart in $charts) { + Write-Host "Installing: $chart" -ForegroundColor Green + if ($useCustomRegistry) { + helm install --set inf.registry.server=$registry --set inf.registry.login=$dockerUser --set inf.registry.pwd=$dockerPassword --set inf.registry.secretName=eshop-docker-scret --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart + } + else { + if ($chart -ne "eshop-common") { # eshop-common is ignored when no secret must be deployed + helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --set image.pullPolicy=Always --name="$appName-$chart" $chart + } + } +} + +Write-Host "helm charts installed." -ForegroundColor Green + + + + diff --git a/k8s/helm/eshop-common/.helmignore b/k8s/helm/eshop-common/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/eshop-common/.helmignore @@ -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 diff --git a/k8s/helm/eshop-common/Chart.yaml b/k8s/helm/eshop-common/Chart.yaml new file mode 100644 index 000000000..cd5e7b2fe --- /dev/null +++ b/k8s/helm/eshop-common/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: eshop-common +version: 0.1.0 diff --git a/k8s/helm/eshop-common/templates/NOTES.txt b/k8s/helm/eshop-common/templates/NOTES.txt new file mode 100644 index 000000000..1cc59f58a --- /dev/null +++ b/k8s/helm/eshop-common/templates/NOTES.txt @@ -0,0 +1,7 @@ +Common eShop resources installed: + +{{- if .Values.inf.registry -}} +* Docker registry secret ({{ .Values.inf.registry.secretName }}) +{{- end -}} + ++++ Done +++ \ No newline at end of file diff --git a/k8s/helm/eshop-common/templates/_helpers.tpl b/k8s/helm/eshop-common/templates/_helpers.tpl new file mode 100644 index 000000000..4a3c6324b --- /dev/null +++ b/k8s/helm/eshop-common/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "eshop-common.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 "eshop-common.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 "eshop-common.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/eshop-common/templates/_names.tpl b/k8s/helm/eshop-common/templates/_names.tpl new file mode 100644 index 000000000..7cdfb80d6 --- /dev/null +++ b/k8s/helm/eshop-common/templates/_names.tpl @@ -0,0 +1,3 @@ +{{- define "imagePullSecret" }} +{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.inf.registry.server (printf "%s:%s" .Values.inf.registry.login .Values.inf.registry.pwd | b64enc) | b64enc }} +{{- end }} \ No newline at end of file diff --git a/k8s/helm/eshop-common/templates/secret.yaml b/k8s/helm/eshop-common/templates/secret.yaml new file mode 100644 index 000000000..285ec85e7 --- /dev/null +++ b/k8s/helm/eshop-common/templates/secret.yaml @@ -0,0 +1,9 @@ +{{- if .Values.inf.registry -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.inf.registry.secretName }} +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "imagePullSecret" . }} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/eshop-common/values.yaml b/k8s/helm/eshop-common/values.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/k8s/helm/identity-api/.helmignore b/k8s/helm/identity-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/identity-api/.helmignore @@ -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 diff --git a/k8s/helm/identity-api/Chart.yaml b/k8s/helm/identity-api/Chart.yaml new file mode 100644 index 000000000..7b9290ada --- /dev/null +++ b/k8s/helm/identity-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: identity-api +version: 0.1.0 diff --git a/k8s/helm/identity-api/templates/NOTES.txt b/k8s/helm/identity-api/templates/NOTES.txt new file mode 100644 index 000000000..48fbbe9b4 --- /dev/null +++ b/k8s/helm/identity-api/templates/NOTES.txt @@ -0,0 +1,4 @@ +eShop Identity API installed. +----------------------------- + +Access this API through ingress. \ No newline at end of file diff --git a/k8s/helm/identity-api/templates/_helpers.tpl b/k8s/helm/identity-api/templates/_helpers.tpl new file mode 100644 index 000000000..fb47187b4 --- /dev/null +++ b/k8s/helm/identity-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "identity-api.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 "identity-api.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 "identity-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl new file mode 100644 index 000000000..39ee485ef --- /dev/null +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -0,0 +1,51 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/identity-api/templates/configmap.yaml b/k8s/helm/identity-api/templates/configmap.yaml new file mode 100644 index 000000000..3a71f1a81 --- /dev/null +++ b/k8s/helm/identity-api/templates/configmap.yaml @@ -0,0 +1,35 @@ +{{- $name := include "identity-api.fullname" . -}} +{{- $sqlsrv := include "sql-name" . -}} +{{- $mvc_url := include "url-of" (list .Values.app.ingress.entries.mvc .) -}} +{{- $spa_url := include "url-of" (list .Values.app.ingress.entries.spa .) -}} +{{- $locations_url := include "url-of" (list .Values.app.ingress.entries.locations .) -}} +{{- $marketing_url := include "url-of" (list .Values.app.ingress.entries.marketing .) -}} +{{- $basket_url := include "url-of" (list .Values.app.ingress.entries.basket .) -}} +{{- $ordering_url := include "url-of" (list .Values.app.ingress.entries.ordering .) -}} +{{- $mobileshoppingagg := include "url-of" (list .Values.app.ingress.entries.mobileshoppingagg .) -}} +{{- $webhoppingagg := include "url-of" (list .Values.app.ingress.entries.webshoppingagg .) -}} +{{- $xamarincallback := include "url-of" (list "xamarincallback" .) -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "identity-api.name" . }} + chart: {{ template "identity-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + identity__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.identity.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; + identity__keystore: {{ .Values.inf.redis.keystore.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + mvc_e: http://{{ $mvc_url }} + spa_e: http://{{ $spa_url }} + locations_e: http://{{ $locations_url }} + marketing_e: http://{{ $marketing_url }} + basket_e: http://{{ $basket_url }} + ordering_e: http://{{ $ordering_url }} + mobileshoppingagg_e: http://{{ $mobileshoppingagg }} + webshoppingagg_e: http://{{ $webhoppingagg }} + xamarin_callback_e: http://{{ $xamarincallback }} + diff --git a/k8s/helm/identity-api/templates/deployment.yaml b/k8s/helm/identity-api/templates/deployment.yaml new file mode 100644 index 000000000..753725a9f --- /dev/null +++ b/k8s/helm/identity-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "identity-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "identity-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "identity-api.name" . }} + chart: {{ template "identity-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "identity-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "identity-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/identity-api/templates/ingress.yaml b/k8s/helm/identity-api/templates/ingress.yaml new file mode 100644 index 000000000..5824f91e2 --- /dev/null +++ b/k8s/helm/identity-api/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "identity-api.fullname" . }} + labels: + app: {{ template "identity-api.name" . }} + chart: {{ template "identity-api.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: {{ .Values.app.svc.identity }} + servicePort: http +{{- end }} diff --git a/k8s/helm/identity-api/templates/service.yaml b/k8s/helm/identity-api/templates/service.yaml new file mode 100644 index 000000000..bca200389 --- /dev/null +++ b/k8s/helm/identity-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.identity }} + labels: + app: {{ template "identity-api.name" . }} + chart: {{ template "identity-api.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 "identity-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/identity-api/values.yaml b/k8s/helm/identity-api/values.yaml new file mode 100644 index 000000000..9777db355 --- /dev/null +++ b/k8s/helm/identity-api/values.yaml @@ -0,0 +1,64 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /identity + +image: + repository: eshop/identity.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + annotations: {} + hosts: + - chart-example.local + tls: [] + +resources: {} + + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +env: + urls: + configmap: + - name: ConnectionString + key: identity__ConnectionString + - name: DPConnectionString + key: identity__keystore + - name: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: MvcClient + key: mvc_e + - name: SpaClient + key: spa_e + - name: LocationApiClient + key: locations_e + - name: MarketingApiClient + key: marketing_e + - name: BasketApiClient + key: basket_e + - name: OrderingApiClient + key: ordering_e + - name: MobileShoppingAggClient + key: mobileshoppingagg_e + - name: WebShoppingAggClient + key: webshoppingagg_e + - name: XamarinCallback + key: xamarin_callback_e + values: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + value: 'True' + diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml new file mode 100644 index 000000000..4c0180f45 --- /dev/null +++ b/k8s/helm/inf.yaml @@ -0,0 +1,46 @@ +# This heml values file defines all infrastructure used by eShopOnContainers. +# It is used on all charts, so ** MUST BE INCLUDED ** on every deployment + +inf: + sql: # inf.sql defines the sql server databases & logins +# host: my-sql-server # Uncomment to specify a custom sql-server to be used. By default "sql-data-" will be used + common: + user: sa # SQL user + pwd: Pass@word # SQL pwd + pid: Developer + catalog: # inf.sql.catalog: settings for the catalog-api sql (user, pwd, db) + db: CatalogDb # Catalog API SQL db name + ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db) + db: OrderingDb # Ordering API SQL db name + identity: + db: IdentityDb # Ordering API SQL db name + mongo: +# host: my-nosql-data # Uncomment to use specify custom mongo host. By default nosql-data is used + locations: + database: LocationsDb + marketing: + database: MarketingDb + redis: # inf.redis defines the redis' connection strings + basket: + svc: basket-data # Name of k8s svc for basket redis + constr: basket-data # Connection string to Redis used by Basket API + keystore: + svc: keystore-data # Name of k8s svc for keystore-data redis + constr: keystore-data # Connection string to Redis used as a Keystore (by Identity API) + eventbus: + svc: rabbitmq # Name of k8s svc for rabbitmq + constr: rabbitmq # Event bus connection string + useAzure: false # true if use Azure Service Bus. False if RabbitMQ + appinsights: + key: "" # App insights to use + k8s: # inf.k8s defines Kubernetes cluster global config + dns: "" # k8s external DNS. This value or ip value MUST BE PROVIDED + misc: # inf.misc contains miscellaneous configuration related to infrastructure + useLoadTest: false # If running under loading test or not + useAzureStorage: false # If catalog api uses azure storage or not +# registry: # Uncomment "registry" to specify registry secret +# secretName: # secretName is the name of the secret inside k8s +# server: # Registry login server +# login: # User login +# pwd: # User pwd + diff --git a/k8s/helm/ingress_values.yaml b/k8s/helm/ingress_values.yaml new file mode 100644 index 000000000..88540574d --- /dev/null +++ b/k8s/helm/ingress_values.yaml @@ -0,0 +1,5 @@ +ingress: + annotations: + kubernetes.io/ingress.class: addon-http-application-routing + ingress.kubernetes.io/ssl-redirect: "false" + nginx.ingress.kubernetes.io/ssl-redirect: "false" diff --git a/k8s/helm/keystore-data/.helmignore b/k8s/helm/keystore-data/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/keystore-data/.helmignore @@ -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 diff --git a/k8s/helm/keystore-data/Chart.yaml b/k8s/helm/keystore-data/Chart.yaml new file mode 100644 index 000000000..0cfa515f9 --- /dev/null +++ b/k8s/helm/keystore-data/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: keystore-data +version: 0.1.0 diff --git a/k8s/helm/keystore-data/templates/NOTES.txt b/k8s/helm/keystore-data/templates/NOTES.txt new file mode 100644 index 000000000..bec3a1f0f --- /dev/null +++ b/k8s/helm/keystore-data/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Redis for keystore data installed +---------------------------------------- + +Redis is not directly exposed outside cluster. If need to access it from outside use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "keystore-data.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 \ No newline at end of file diff --git a/k8s/helm/keystore-data/templates/_helpers.tpl b/k8s/helm/keystore-data/templates/_helpers.tpl new file mode 100644 index 000000000..18786752f --- /dev/null +++ b/k8s/helm/keystore-data/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "keystore-data.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 "keystore-data.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 "keystore-data.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/keystore-data/templates/deployment.yaml b/k8s/helm/keystore-data/templates/deployment.yaml new file mode 100644 index 000000000..34f1fe074 --- /dev/null +++ b/k8s/helm/keystore-data/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "keystore-data.fullname" . }} + labels: + app: {{ template "keystore-data.name" . }} + chart: {{ template "keystore-data.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "keystore-data.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "keystore-data.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 6379 + 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 }} diff --git a/k8s/helm/keystore-data/templates/service.yaml b/k8s/helm/keystore-data/templates/service.yaml new file mode 100644 index 000000000..38e9a4273 --- /dev/null +++ b/k8s/helm/keystore-data/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.inf.redis.keystore.svc }} + labels: + app: {{ template "keystore-data.name" . }} + chart: {{ template "keystore-data.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 "keystore-data.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/keystore-data/values.yaml b/k8s/helm/keystore-data/values.yaml new file mode 100644 index 000000000..17cc75ee7 --- /dev/null +++ b/k8s/helm/keystore-data/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: redis + tag: 4.0.10 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 6379 + + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/helm/locations-api/.helmignore b/k8s/helm/locations-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/locations-api/.helmignore @@ -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 diff --git a/k8s/helm/locations-api/Chart.yaml b/k8s/helm/locations-api/Chart.yaml new file mode 100644 index 000000000..5126fe847 --- /dev/null +++ b/k8s/helm/locations-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: locations-api +version: 0.1.0 diff --git a/k8s/helm/locations-api/templates/NOTES.txt b/k8s/helm/locations-api/templates/NOTES.txt new file mode 100644 index 000000000..3b48889bf --- /dev/null +++ b/k8s/helm/locations-api/templates/NOTES.txt @@ -0,0 +1,9 @@ +eShop Locations API installed. +------------------------------ + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "locations-api.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 + diff --git a/k8s/helm/locations-api/templates/_helpers.tpl b/k8s/helm/locations-api/templates/_helpers.tpl new file mode 100644 index 000000000..086a461ba --- /dev/null +++ b/k8s/helm/locations-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "locations-api.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 "locations-api.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 "locations-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/locations-api/templates/_names.tpl b/k8s/helm/locations-api/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/locations-api/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/locations-api/templates/configmap.yaml b/k8s/helm/locations-api/templates/configmap.yaml new file mode 100644 index 000000000..84881087d --- /dev/null +++ b/k8s/helm/locations-api/templates/configmap.yaml @@ -0,0 +1,22 @@ +{{- $name := include "locations-api.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} +{{- $mongo := include "mongo-name" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "locations-api.name" . }} + chart: {{ template "locations-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} + urls__IdentityUrl: {{ $identity }} + locations__ConnectionString: mongodb://{{ $mongo }} + locations__Database: {{ .Values.inf.mongo.locations.database }} \ No newline at end of file diff --git a/k8s/helm/locations-api/templates/deployment.yaml b/k8s/helm/locations-api/templates/deployment.yaml new file mode 100644 index 000000000..c8f3f00cd --- /dev/null +++ b/k8s/helm/locations-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "locations-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "locations-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "locations-api.name" . }} + chart: {{ template "locations-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "locations-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "locations-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/locations-api/templates/service.yaml b/k8s/helm/locations-api/templates/service.yaml new file mode 100644 index 000000000..abd628beb --- /dev/null +++ b/k8s/helm/locations-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.locations }} + labels: + app: {{ template "locations-api.name" . }} + chart: {{ template "locations-api.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 "locations-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/locations-api/values.yaml b/k8s/helm/locations-api/values.yaml new file mode 100644 index 000000000..99c130def --- /dev/null +++ b/k8s/helm/locations-api/values.yaml @@ -0,0 +1,55 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /locations-api + +image: + repository: eshop/locations.api + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: UseLoadTest + key: all_EnableLoadTest + - name: IdentityUrl + key: internalurls__IdentityUrl + - name: IdentityUrlExternal + key: urls__IdentityUrl + - name: ConnectionString + key: locations__ConnectionString + - name: Database + key: locations__Database + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/marketing-api/.helmignore b/k8s/helm/marketing-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/marketing-api/.helmignore @@ -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 diff --git a/k8s/helm/marketing-api/Chart.yaml b/k8s/helm/marketing-api/Chart.yaml new file mode 100644 index 000000000..173f94fd6 --- /dev/null +++ b/k8s/helm/marketing-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: marketing-api +version: 0.1.0 diff --git a/k8s/helm/marketing-api/templates/NOTES.txt b/k8s/helm/marketing-api/templates/NOTES.txt new file mode 100644 index 000000000..7fa66ed47 --- /dev/null +++ b/k8s/helm/marketing-api/templates/NOTES.txt @@ -0,0 +1,9 @@ +eShop Marketing API installed. +------------------------------ + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "marketing-api.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 + diff --git a/k8s/helm/marketing-api/templates/_helpers.tpl b/k8s/helm/marketing-api/templates/_helpers.tpl new file mode 100644 index 000000000..c252aeeac --- /dev/null +++ b/k8s/helm/marketing-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "marketing-api.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 "marketing-api.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 "marketing-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/marketing-api/templates/_names.tpl b/k8s/helm/marketing-api/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/marketing-api/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/marketing-api/templates/configmap.yaml b/k8s/helm/marketing-api/templates/configmap.yaml new file mode 100644 index 000000000..ea99a1b5a --- /dev/null +++ b/k8s/helm/marketing-api/templates/configmap.yaml @@ -0,0 +1,24 @@ +{{- $name := include "marketing-api.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} +{{- $mongo := include "mongo-name" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "marketing-api.name" . }} + chart: {{ template "marketing-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} + urls__IdentityUrl: {{ $identity }} + marketing__ConnectionString: mongodb://{{ $mongo }} + marketing__Database: {{ .Values.inf.mongo.marketing.database }} + marketing__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/ \ No newline at end of file diff --git a/k8s/helm/marketing-api/templates/deployment.yaml b/k8s/helm/marketing-api/templates/deployment.yaml new file mode 100644 index 000000000..e0cbeb3ce --- /dev/null +++ b/k8s/helm/marketing-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "marketing-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "marketing-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "marketing-api.name" . }} + chart: {{ template "marketing-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "marketing-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "marketing-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/marketing-api/templates/service.yaml b/k8s/helm/marketing-api/templates/service.yaml new file mode 100644 index 000000000..0e9bfbea2 --- /dev/null +++ b/k8s/helm/marketing-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.marketing }} + labels: + app: {{ template "marketing-api.name" . }} + chart: {{ template "marketing-api.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 "marketing-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/marketing-api/values.yaml b/k8s/helm/marketing-api/values.yaml new file mode 100644 index 000000000..8779685d6 --- /dev/null +++ b/k8s/helm/marketing-api/values.yaml @@ -0,0 +1,57 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /marketing-api + +image: + repository: eshop/marketing.api + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: UseLoadTest + key: all_EnableLoadTest + - name: IdentityUrl + key: internalurls__IdentityUrl + - name: IdentityUrlExternal + key: urls__IdentityUrl + - name: ConnectionString + key: marketing__ConnectionString + - name: Database + key: marketing__Database + - name: PicBaseUrl + key: marketing__PicBaseUrl + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/mobileshoppingagg/.helmignore b/k8s/helm/mobileshoppingagg/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/.helmignore @@ -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 diff --git a/k8s/helm/mobileshoppingagg/Chart.yaml b/k8s/helm/mobileshoppingagg/Chart.yaml new file mode 100644 index 000000000..957edd619 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: mobileshoppingagg +version: 0.1.0 diff --git a/k8s/helm/mobileshoppingagg/templates/NOTES.txt b/k8s/helm/mobileshoppingagg/templates/NOTES.txt new file mode 100644 index 000000000..61971f717 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Mobile Marketing Aggregator is installed +---------------------------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "mobileshoppingagg.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 diff --git a/k8s/helm/mobileshoppingagg/templates/_helpers.tpl b/k8s/helm/mobileshoppingagg/templates/_helpers.tpl new file mode 100644 index 000000000..b3aace0e7 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mobileshoppingagg.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 "mobileshoppingagg.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 "mobileshoppingagg.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/mobileshoppingagg/templates/_names.tpl b/k8s/helm/mobileshoppingagg/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/mobileshoppingagg/templates/configmap.yaml b/k8s/helm/mobileshoppingagg/templates/configmap.yaml new file mode 100644 index 000000000..10eb543b2 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- $name := include "mobileshoppingagg.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "mobileshoppingagg.name" . }} + chart: {{ template "mobileshoppingagg.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + mobileshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} + internalurls__basket: http://{{ .Values.app.svc.basket }} + internalurls__catalog: http://{{ .Values.app.svc.catalog }} + internalurls__identity: http://{{ .Values.app.svc.identity }} + internalurls__ordering: http://{{ .Values.app.svc.ordering }} diff --git a/k8s/helm/mobileshoppingagg/templates/deployment.yaml b/k8s/helm/mobileshoppingagg/templates/deployment.yaml new file mode 100644 index 000000000..5e81da7bf --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "mobileshoppingagg.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "mobileshoppingagg.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "mobileshoppingagg.name" . }} + chart: {{ template "mobileshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "mobileshoppingagg.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "mobileshoppingagg.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/mobileshoppingagg/templates/service.yaml b/k8s/helm/mobileshoppingagg/templates/service.yaml new file mode 100644 index 000000000..ef6726e88 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.mobileshoppingagg }} + labels: + app: {{ template "mobileshoppingagg.name" . }} + chart: {{ template "mobileshoppingagg.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 "mobileshoppingagg.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/mobileshoppingagg/values.yaml b/k8s/helm/mobileshoppingagg/values.yaml new file mode 100644 index 000000000..039695024 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/values.yaml @@ -0,0 +1,53 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /mobileshoppingagg + +image: + repository: eshop/mobileshoppingagg + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: urls__basket + key: internalurls__basket + - name: urls__catalog + key: internalurls__catalog + - name: urls__orders + key: internalurls__ordering + - 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 + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + value: 'True' + diff --git a/k8s/helm/nosql-data/.helmignore b/k8s/helm/nosql-data/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/nosql-data/.helmignore @@ -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 diff --git a/k8s/helm/nosql-data/Chart.yaml b/k8s/helm/nosql-data/Chart.yaml new file mode 100644 index 000000000..848a11cbb --- /dev/null +++ b/k8s/helm/nosql-data/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: nosql-data +version: 0.1.0 diff --git a/k8s/helm/nosql-data/templates/NOTES.txt b/k8s/helm/nosql-data/templates/NOTES.txt new file mode 100644 index 000000000..116c3c4e0 --- /dev/null +++ b/k8s/helm/nosql-data/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop MongoDb Installed +----------------------- + +MongoDb is not exposed outside the cluster. If need to access it from outside, use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "nosql-data.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 \ No newline at end of file diff --git a/k8s/helm/nosql-data/templates/_helpers.tpl b/k8s/helm/nosql-data/templates/_helpers.tpl new file mode 100644 index 000000000..99be734f7 --- /dev/null +++ b/k8s/helm/nosql-data/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "nosql-data.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 "nosql-data.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 "nosql-data.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/nosql-data/templates/_names.tpl b/k8s/helm/nosql-data/templates/_names.tpl new file mode 100644 index 000000000..56fb974fc --- /dev/null +++ b/k8s/helm/nosql-data/templates/_names.tpl @@ -0,0 +1,8 @@ + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} diff --git a/k8s/helm/nosql-data/templates/deployment.yaml b/k8s/helm/nosql-data/templates/deployment.yaml new file mode 100644 index 000000000..9b1f32319 --- /dev/null +++ b/k8s/helm/nosql-data/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "nosql-data.fullname" . }} + labels: + app: {{ template "nosql-data.name" . }} + chart: {{ template "nosql-data.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "nosql-data.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "nosql-data.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 27017 + 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 }} diff --git a/k8s/helm/nosql-data/templates/service.yaml b/k8s/helm/nosql-data/templates/service.yaml new file mode 100644 index 000000000..478cadfea --- /dev/null +++ b/k8s/helm/nosql-data/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "mongo-name" . }} + labels: + app: {{ template "nosql-data.name" . }} + chart: {{ template "nosql-data.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 "nosql-data.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/nosql-data/values.yaml b/k8s/helm/nosql-data/values.yaml new file mode 100644 index 000000000..1a380e6b4 --- /dev/null +++ b/k8s/helm/nosql-data/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: mongo + tag: 3.6.5-jessie + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 27017 + + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/helm/ordering-api/.helmignore b/k8s/helm/ordering-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/ordering-api/.helmignore @@ -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 diff --git a/k8s/helm/ordering-api/Chart.yaml b/k8s/helm/ordering-api/Chart.yaml new file mode 100644 index 000000000..b65ca4b9a --- /dev/null +++ b/k8s/helm/ordering-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ordering-api +version: 0.1.0 diff --git a/k8s/helm/ordering-api/templates/NOTES.txt b/k8s/helm/ordering-api/templates/NOTES.txt new file mode 100644 index 000000000..43bfd2fdf --- /dev/null +++ b/k8s/helm/ordering-api/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Ordering API installed. +----------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-api.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 diff --git a/k8s/helm/ordering-api/templates/_helpers.tpl b/k8s/helm/ordering-api/templates/_helpers.tpl new file mode 100644 index 000000000..978c08c64 --- /dev/null +++ b/k8s/helm/ordering-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ordering-api.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 "ordering-api.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 "ordering-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl new file mode 100644 index 000000000..39ee485ef --- /dev/null +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -0,0 +1,51 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/ordering-api/templates/configmap.yaml b/k8s/helm/ordering-api/templates/configmap.yaml new file mode 100644 index 000000000..de4cb2d7a --- /dev/null +++ b/k8s/helm/ordering-api/templates/configmap.yaml @@ -0,0 +1,20 @@ +{{- $name := include "ordering-api.fullname" . -}} +{{- $sqlsrv := include "sql-name" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "ordering-api.name" . }} + chart: {{ template "ordering-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; + ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + urls__IdentityUrl: http://{{ $identity }} + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/k8s/helm/ordering-api/templates/deployment.yaml b/k8s/helm/ordering-api/templates/deployment.yaml new file mode 100644 index 000000000..19845c251 --- /dev/null +++ b/k8s/helm/ordering-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "ordering-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "ordering-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "ordering-api.name" . }} + chart: {{ template "ordering-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "ordering-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ordering-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/ordering-api/templates/service.yaml b/k8s/helm/ordering-api/templates/service.yaml new file mode 100644 index 000000000..bedfd6f01 --- /dev/null +++ b/k8s/helm/ordering-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.ordering }} + labels: + app: {{ template "ordering-api.name" . }} + chart: {{ template "ordering-api.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 "ordering-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/ordering-api/values.yaml b/k8s/helm/ordering-api/values.yaml new file mode 100644 index 000000000..c4a7cdf99 --- /dev/null +++ b/k8s/helm/ordering-api/values.yaml @@ -0,0 +1,53 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /ordering-api + +image: + repository: eshop/ordering.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - chart-example.local + 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: ConnectionString + key: ordering__ConnectionString + - name: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: UseLoadTest + key: ordering__EnableLoadTest + - name: IdentityUrl + key: urls__IdentityUrl + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/ordering-backgroundtasks/.helmignore b/k8s/helm/ordering-backgroundtasks/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/.helmignore @@ -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 diff --git a/k8s/helm/ordering-backgroundtasks/Chart.yaml b/k8s/helm/ordering-backgroundtasks/Chart.yaml new file mode 100644 index 000000000..6ad4f47e6 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ordering-backgroundtasks +version: 0.1.0 diff --git a/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt new file mode 100644 index 000000000..54e1b49ea --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt @@ -0,0 +1,3 @@ +eShop Ordering Background Tasks installed. +------------------------------------------ + diff --git a/k8s/helm/ordering-backgroundtasks/templates/_helpers.tpl b/k8s/helm/ordering-backgroundtasks/templates/_helpers.tpl new file mode 100644 index 000000000..e61b78285 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ordering-backgroundtasks.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 "ordering-backgroundtasks.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 "ordering-backgroundtasks.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl new file mode 100644 index 000000000..39ee485ef --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -0,0 +1,51 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml new file mode 100644 index 000000000..54fec785b --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml @@ -0,0 +1,20 @@ +{{- $name := include "ordering-backgroundtasks.fullname" . -}} +{{- $sqlsrv := include "sql-name" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "ordering-backgroundtasks.name" . }} + chart: {{ template "ordering-backgroundtasks.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; + ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + graceperiodmanager__CheckUpdateTime: "{{ .Values.cfg.checkUpdateTime }}" + graceperiodmanager__GracePeriodTime: "{{ .Values.cfg.gracePeriodTime }}" \ No newline at end of file diff --git a/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml b/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml new file mode 100644 index 000000000..cb57ca18d --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "ordering-backgroundtasks.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "ordering-backgroundtasks.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "ordering-backgroundtasks.name" . }} + chart: {{ template "ordering-backgroundtasks.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "ordering-backgroundtasks.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ordering-backgroundtasks.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/ordering-backgroundtasks/templates/service.yaml b/k8s/helm/ordering-backgroundtasks/templates/service.yaml new file mode 100644 index 000000000..d8fcba036 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.orderingbackgroundtasks }} + labels: + app: {{ template "ordering-backgroundtasks.name" . }} + chart: {{ template "ordering-backgroundtasks.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 "ordering-backgroundtasks.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/ordering-backgroundtasks/values.yaml b/k8s/helm/ordering-backgroundtasks/values.yaml new file mode 100644 index 000000000..adfa20c03 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/values.yaml @@ -0,0 +1,59 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /ordering-backgroundtasks + +image: + repository: eshop/ordering.backgroundtasks + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - chart-example.local + tls: [] + +cfg: + checkUpdateTime: "15000" + gracePeriodTime: "1" + +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: ConnectionString + key: ordering__ConnectionString + - name: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: UseLoadTest + key: ordering__EnableLoadTest + - name: CheckUpdateTime + key: graceperiodmanager__CheckUpdateTime + - name: GracePeriodTime + key: graceperiodmanager__GracePeriodTime + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/ordering-signalrhub/.helmignore b/k8s/helm/ordering-signalrhub/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/.helmignore @@ -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 diff --git a/k8s/helm/ordering-signalrhub/Chart.yaml b/k8s/helm/ordering-signalrhub/Chart.yaml new file mode 100644 index 000000000..d43e83bf0 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ordering-signalrhub +version: 0.1.0 diff --git a/k8s/helm/ordering-signalrhub/templates/NOTES.txt b/k8s/helm/ordering-signalrhub/templates/NOTES.txt new file mode 100644 index 000000000..fc55c9dfa --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Ordering SignalR Hub installed +------------------------------------ + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-signalrhub.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 diff --git a/k8s/helm/ordering-signalrhub/templates/_helpers.tpl b/k8s/helm/ordering-signalrhub/templates/_helpers.tpl new file mode 100644 index 000000000..2c11ddb51 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ordering-signalrhub.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 "ordering-signalrhub.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 "ordering-signalrhub.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/ordering-signalrhub/templates/_names.tpl b/k8s/helm/ordering-signalrhub/templates/_names.tpl new file mode 100644 index 000000000..39ee485ef --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/_names.tpl @@ -0,0 +1,51 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/ordering-signalrhub/templates/configmap.yaml b/k8s/helm/ordering-signalrhub/templates/configmap.yaml new file mode 100644 index 000000000..cec9565f0 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/configmap.yaml @@ -0,0 +1,18 @@ +{{- $name := include "ordering-signalrhub.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "ordering-signalrhub.name" . }} + chart: {{ template "ordering-signalrhub.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + signalr__StoreConnectionString: {{ .Values.inf.redis.keystore.constr }} + urls__IdentityUrl: {{ $identity }} \ No newline at end of file diff --git a/k8s/helm/ordering-signalrhub/templates/deployment.yaml b/k8s/helm/ordering-signalrhub/templates/deployment.yaml new file mode 100644 index 000000000..af3867ea5 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/deployment.yaml @@ -0,0 +1,70 @@ +{{- $name := include "ordering-signalrhub.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "ordering-signalrhub.fullname" . }} + labels: + app: {{ template "ordering-signalrhub.name" . }} + chart: {{ template "ordering-signalrhub.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "ordering-signalrhub.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ordering-signalrhub.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/ordering-signalrhub/templates/service.yaml b/k8s/helm/ordering-signalrhub/templates/service.yaml new file mode 100644 index 000000000..501539923 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.orderingsignalrhub }} + labels: + app: {{ template "ordering-signalrhub.name" . }} + chart: {{ template "ordering-signalrhub.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 "ordering-signalrhub.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/ordering-signalrhub/values.yaml b/k8s/helm/ordering-signalrhub/values.yaml new file mode 100644 index 000000000..19099b147 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/values.yaml @@ -0,0 +1,57 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /ordering-signalrhub + +image: + repository: eshop/ordering.signalrhub + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - chart-example.local + tls: [] + +cfg: + checkUpdateTime: "15000" + gracePeriodTime: "1" + +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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + - name: IdentityUrl + key: urls__IdentityUrl + - name: SignalrStoreConnectionString + key: signalr__StoreConnectionString + # 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 + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + values: 'True' + diff --git a/k8s/helm/payment-api/.helmignore b/k8s/helm/payment-api/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/payment-api/.helmignore @@ -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 diff --git a/k8s/helm/payment-api/Chart.yaml b/k8s/helm/payment-api/Chart.yaml new file mode 100644 index 000000000..b7dba9341 --- /dev/null +++ b/k8s/helm/payment-api/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: payment-api +version: 0.1.0 diff --git a/k8s/helm/payment-api/templates/NOTES.txt b/k8s/helm/payment-api/templates/NOTES.txt new file mode 100644 index 000000000..6d178f344 --- /dev/null +++ b/k8s/helm/payment-api/templates/NOTES.txt @@ -0,0 +1,9 @@ +eShop Payment API installed. +---------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "payment-api.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 + diff --git a/k8s/helm/payment-api/templates/_helpers.tpl b/k8s/helm/payment-api/templates/_helpers.tpl new file mode 100644 index 000000000..2f98d7ea2 --- /dev/null +++ b/k8s/helm/payment-api/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "payment-api.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 "payment-api.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 "payment-api.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/payment-api/templates/_names.tpl b/k8s/helm/payment-api/templates/_names.tpl new file mode 100644 index 000000000..39ee485ef --- /dev/null +++ b/k8s/helm/payment-api/templates/_names.tpl @@ -0,0 +1,51 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/payment-api/templates/configmap.yaml b/k8s/helm/payment-api/templates/configmap.yaml new file mode 100644 index 000000000..6717705b5 --- /dev/null +++ b/k8s/helm/payment-api/templates/configmap.yaml @@ -0,0 +1,15 @@ +{{- $name := include "payment-api.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "payment-api.name" . }} + chart: {{ template "payment-api.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__EventBusConnection: {{ .Values.inf.eventbus.constr }} + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/k8s/helm/payment-api/templates/deployment.yaml b/k8s/helm/payment-api/templates/deployment.yaml new file mode 100644 index 000000000..8b414145f --- /dev/null +++ b/k8s/helm/payment-api/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "payment-api.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "payment-api.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "payment-api.name" . }} + chart: {{ template "payment-api.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "payment-api.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "payment-api.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/payment-api/templates/service.yaml b/k8s/helm/payment-api/templates/service.yaml new file mode 100644 index 000000000..14fc7479c --- /dev/null +++ b/k8s/helm/payment-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.payment }} + labels: + app: {{ template "payment-api.name" . }} + chart: {{ template "payment-api.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 "payment-api.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/payment-api/values.yaml b/k8s/helm/payment-api/values.yaml new file mode 100644 index 000000000..0ee6dd4d9 --- /dev/null +++ b/k8s/helm/payment-api/values.yaml @@ -0,0 +1,45 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /payment-api + +image: + repository: eshop/payment.api + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: EventBusConnection + key: all__EventBusConnection + - name: AzureServiceBusEnabled + key: all__UseAzureServiceBus + # 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 + - name: OrchestratorType + value: 'K8S' + diff --git a/k8s/helm/rabbitmq/.helmignore b/k8s/helm/rabbitmq/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/rabbitmq/.helmignore @@ -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 diff --git a/k8s/helm/rabbitmq/Chart.yaml b/k8s/helm/rabbitmq/Chart.yaml new file mode 100644 index 000000000..2d955858e --- /dev/null +++ b/k8s/helm/rabbitmq/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: rabbitmq +version: 0.1.0 diff --git a/k8s/helm/rabbitmq/templates/NOTES.txt b/k8s/helm/rabbitmq/templates/NOTES.txt new file mode 100644 index 000000000..49edf7f9c --- /dev/null +++ b/k8s/helm/rabbitmq/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop rabbitmq installed +------------------------- + +rabbitmq is not directly exposed outside cluster. If need to access it from outside use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "rabbitmq.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 \ No newline at end of file diff --git a/k8s/helm/rabbitmq/templates/_helpers.tpl b/k8s/helm/rabbitmq/templates/_helpers.tpl new file mode 100644 index 000000000..bbbb2e33d --- /dev/null +++ b/k8s/helm/rabbitmq/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "rabbitmq.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 "rabbitmq.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 "rabbitmq.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/rabbitmq/templates/_names.tpl b/k8s/helm/rabbitmq/templates/_names.tpl new file mode 100644 index 000000000..be0a9b800 --- /dev/null +++ b/k8s/helm/rabbitmq/templates/_names.tpl @@ -0,0 +1,8 @@ + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "rabbitmq" -}} +{{- end -}} +{{- end -}} diff --git a/k8s/helm/rabbitmq/templates/deployment.yaml b/k8s/helm/rabbitmq/templates/deployment.yaml new file mode 100644 index 000000000..9819a6455 --- /dev/null +++ b/k8s/helm/rabbitmq/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "rabbitmq.fullname" . }} + labels: + app: {{ template "rabbitmq.name" . }} + chart: {{ template "rabbitmq.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "rabbitmq.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "rabbitmq.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 5672 + 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 }} diff --git a/k8s/helm/rabbitmq/templates/service.yaml b/k8s/helm/rabbitmq/templates/service.yaml new file mode 100644 index 000000000..5de39e0a8 --- /dev/null +++ b/k8s/helm/rabbitmq/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.inf.eventbus.svc }} + labels: + app: {{ template "rabbitmq.name" . }} + chart: {{ template "rabbitmq.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 "rabbitmq.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/rabbitmq/values.yaml b/k8s/helm/rabbitmq/values.yaml new file mode 100644 index 000000000..5e9efd521 --- /dev/null +++ b/k8s/helm/rabbitmq/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: rabbitmq + tag: 3-management + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 5672 + + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/helm/sql-data/.helmignore b/k8s/helm/sql-data/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/sql-data/.helmignore @@ -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 diff --git a/k8s/helm/sql-data/Chart.yaml b/k8s/helm/sql-data/Chart.yaml new file mode 100644 index 000000000..6e5d726c5 --- /dev/null +++ b/k8s/helm/sql-data/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: sql-data +version: 0.1.0 diff --git a/k8s/helm/sql-data/templates/NOTES.txt b/k8s/helm/sql-data/templates/NOTES.txt new file mode 100644 index 000000000..468a155b0 --- /dev/null +++ b/k8s/helm/sql-data/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop SQL Server Installed +-------------------------- + +SQL server is not exposed outside the cluster. If need to access it from outside, use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "sql-data.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 \ No newline at end of file diff --git a/k8s/helm/sql-data/templates/_helpers.tpl b/k8s/helm/sql-data/templates/_helpers.tpl new file mode 100644 index 000000000..ee953f2f8 --- /dev/null +++ b/k8s/helm/sql-data/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "sql-data.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 "sql-data.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 "sql-data.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/sql-data/templates/_names.tpl b/k8s/helm/sql-data/templates/_names.tpl new file mode 100644 index 000000000..dc35d62fe --- /dev/null +++ b/k8s/helm/sql-data/templates/_names.tpl @@ -0,0 +1,8 @@ + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/sql-data/templates/deployment.yaml b/k8s/helm/sql-data/templates/deployment.yaml new file mode 100644 index 000000000..4b2f589ef --- /dev/null +++ b/k8s/helm/sql-data/templates/deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "sql-data.fullname" . }} + labels: + app: {{ template "sql-data.name" . }} + chart: {{ template "sql-data.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "sql-data.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "sql-data.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: ACCEPT_EULA + value: "Y" + - name: MSSQL_PID + value: {{ .Values.inf.sql.common.pid }} + - name: MSSQL_SA_PASSWORD + value: {{ .Values.inf.sql.common.pwd }} + ports: + - name: http + containerPort: 1433 + 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 }} diff --git a/k8s/helm/sql-data/templates/service.yaml b/k8s/helm/sql-data/templates/service.yaml new file mode 100644 index 000000000..b9b8d59fc --- /dev/null +++ b/k8s/helm/sql-data/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "sql-name" . }} + labels: + app: {{ template "sql-data.name" . }} + chart: {{ template "sql-data.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 "sql-data.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/sql-data/values.yaml b/k8s/helm/sql-data/values.yaml new file mode 100644 index 000000000..0ed76556a --- /dev/null +++ b/k8s/helm/sql-data/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: microsoft/mssql-server-linux + tag: 2017-CU7 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 1433 + + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/helm/webmvc/.helmignore b/k8s/helm/webmvc/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/webmvc/.helmignore @@ -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 diff --git a/k8s/helm/webmvc/Chart.yaml b/k8s/helm/webmvc/Chart.yaml new file mode 100644 index 000000000..c63e8924a --- /dev/null +++ b/k8s/helm/webmvc/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: webmvc +version: 0.1.0 diff --git a/k8s/helm/webmvc/templates/NOTES.txt b/k8s/helm/webmvc/templates/NOTES.txt new file mode 100644 index 000000000..06e02a45d --- /dev/null +++ b/k8s/helm/webmvc/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop WebMVC installed. +----------------------- diff --git a/k8s/helm/webmvc/templates/_helpers.tpl b/k8s/helm/webmvc/templates/_helpers.tpl new file mode 100644 index 000000000..2e3bcef56 --- /dev/null +++ b/k8s/helm/webmvc/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "webmvc.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 "webmvc.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 "webmvc.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/webmvc/templates/_names.tpl b/k8s/helm/webmvc/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/webmvc/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/webmvc/templates/configmap.yaml b/k8s/helm/webmvc/templates/configmap.yaml new file mode 100644 index 000000000..9d120fe7b --- /dev/null +++ b/k8s/helm/webmvc/templates/configmap.yaml @@ -0,0 +1,32 @@ +{{- $name := include "webmvc.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} +{{- $mvc := include "url-of" (list .Values.app.ingress.entries.mvc .) -}} +{{- $mongo := include "mongo-name" . -}} + + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "webmvc.name" . }} + chart: {{ template "webmvc.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + webmvc__keystore: {{ .Values.inf.redis.keystore.constr }} + internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} + internalurls__apigwwm: http://{{ .Values.app.svc.webmarketingapigw }} + internalurls__basket__hc: http://{{ .Values.app.svc.basket }}/hc + internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc + internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc + internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc + internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc + internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc + urls__apigwws: http://{{ $webshoppingapigw }} + urls__mvc: http://{{ $mvc }} + urls__IdentityUrl: http://{{ $identity }} diff --git a/k8s/helm/webmvc/templates/deployment.yaml b/k8s/helm/webmvc/templates/deployment.yaml new file mode 100644 index 000000000..d972db448 --- /dev/null +++ b/k8s/helm/webmvc/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "webmvc.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "webmvc.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "webmvc.name" . }} + chart: {{ template "webmvc.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "webmvc.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "webmvc.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/webmvc/templates/ingress.yaml b/k8s/helm/webmvc/templates/ingress.yaml new file mode 100644 index 000000000..abfb62b2f --- /dev/null +++ b/k8s/helm/webmvc/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "webmvc.fullname" . }} + labels: + app: {{ template "webmvc.name" . }} + chart: {{ template "webmvc.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: {{ .Values.app.svc.mvc }} + servicePort: http +{{- end }} diff --git a/k8s/helm/webmvc/templates/service.yaml b/k8s/helm/webmvc/templates/service.yaml new file mode 100644 index 000000000..74d87673f --- /dev/null +++ b/k8s/helm/webmvc/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.mvc }} + labels: + app: {{ template "webmvc.name" . }} + chart: {{ template "webmvc.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 "webmvc.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/webmvc/values.yaml b/k8s/helm/webmvc/values.yaml new file mode 100644 index 000000000..f37dc104e --- /dev/null +++ b/k8s/helm/webmvc/values.yaml @@ -0,0 +1,71 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /webmvc + +image: + repository: eshop/webmvc + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: UseLoadTest + key: all_EnableLoadTest + - name: DPConnectionString + key: webmvc__keystore + - name: PurchaseUrl + key: internalurls__apigwws + - name: ExternalPurchaseUrl + key: urls__apigwws + - name: CallBackUrl + key: urls__mvc + - name: IdentityUrl + key: urls__IdentityUrl + - name: MarketingUrl + key: internalurls__apigwwm + - name: BasketUrlHC + key: internalurls__basket__hc + - name: CatalogUrlHC + key: internalurls__catalog__hc + - name: IdentityUrlHC + key: internalurls__identity__hc + - name: OrderingUrlHC + key: internalurls__ordering__hc + - name: MarketingUrlHC + key: internalurls__marketing__hc + - name: PaymentUrlHC + key: internalurls__payment__hc + - name: SignalrHubUrl + key: urls__apigwws + # 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 + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + value: 'True' + diff --git a/k8s/helm/webshoppingagg/.helmignore b/k8s/helm/webshoppingagg/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/webshoppingagg/.helmignore @@ -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 diff --git a/k8s/helm/webshoppingagg/Chart.yaml b/k8s/helm/webshoppingagg/Chart.yaml new file mode 100644 index 000000000..cd7541025 --- /dev/null +++ b/k8s/helm/webshoppingagg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: webshoppingagg +version: 0.1.0 diff --git a/k8s/helm/webshoppingagg/templates/NOTES.txt b/k8s/helm/webshoppingagg/templates/NOTES.txt new file mode 100644 index 000000000..f55946f36 --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/NOTES.txt @@ -0,0 +1,8 @@ +eShop Web Shopping Aggregator installed. +---------------------------------------- + +This API is not directly exposed outside cluster. If need to access it use: + +export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webshoppingagg.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 diff --git a/k8s/helm/webshoppingagg/templates/_helpers.tpl b/k8s/helm/webshoppingagg/templates/_helpers.tpl new file mode 100644 index 000000000..f13dc791d --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "webshoppingagg.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 "webshoppingagg.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 "webshoppingagg.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/webshoppingagg/templates/_names.tpl b/k8s/helm/webshoppingagg/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/webshoppingagg/templates/configmap.yaml b/k8s/helm/webshoppingagg/templates/configmap.yaml new file mode 100644 index 000000000..c03f2272d --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- $name := include "webshoppingagg.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + webshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} + internalurls__basket: http://{{ .Values.app.svc.basket }} + internalurls__catalog: http://{{ .Values.app.svc.catalog }} + internalurls__identity: http://{{ .Values.app.svc.identity }} + internalurls__ordering: http://{{ .Values.app.svc.ordering }} diff --git a/k8s/helm/webshoppingagg/templates/deployment.yaml b/k8s/helm/webshoppingagg/templates/deployment.yaml new file mode 100644 index 000000000..9d557b0e0 --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "webshoppingagg.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "webshoppingagg.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "webshoppingagg.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "webshoppingagg.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/webshoppingagg/templates/service.yaml b/k8s/helm/webshoppingagg/templates/service.yaml new file mode 100644 index 000000000..8f0cb8bd5 --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.webshoppingagg }} + labels: + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.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 "webshoppingagg.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/webshoppingagg/values.yaml b/k8s/helm/webshoppingagg/values.yaml new file mode 100644 index 000000000..9f855d796 --- /dev/null +++ b/k8s/helm/webshoppingagg/values.yaml @@ -0,0 +1,53 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /webshoppingagg + +image: + repository: eshop/webshoppingagg + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: urls__basket + key: internalurls__basket + - name: urls__catalog + key: internalurls__catalog + - name: urls__orders + key: internalurls__ordering + - 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 + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + value: 'True' + diff --git a/k8s/helm/webspa/.helmignore b/k8s/helm/webspa/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/webspa/.helmignore @@ -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 diff --git a/k8s/helm/webspa/Chart.yaml b/k8s/helm/webspa/Chart.yaml new file mode 100644 index 000000000..c16616489 --- /dev/null +++ b/k8s/helm/webspa/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: webspa +version: 0.1.0 diff --git a/k8s/helm/webspa/templates/NOTES.txt b/k8s/helm/webspa/templates/NOTES.txt new file mode 100644 index 000000000..c8e1622db --- /dev/null +++ b/k8s/helm/webspa/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop WebSPA installed +---------------------- \ No newline at end of file diff --git a/k8s/helm/webspa/templates/_helpers.tpl b/k8s/helm/webspa/templates/_helpers.tpl new file mode 100644 index 000000000..585f9f001 --- /dev/null +++ b/k8s/helm/webspa/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "webspa.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 "webspa.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 "webspa.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/webspa/templates/_names.tpl b/k8s/helm/webspa/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/webspa/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/webspa/templates/configmap.yaml b/k8s/helm/webspa/templates/configmap.yaml new file mode 100644 index 000000000..bf03ff8cd --- /dev/null +++ b/k8s/helm/webspa/templates/configmap.yaml @@ -0,0 +1,32 @@ +{{- $name := include "webspa.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} +{{- $webmarketingapigw := include "url-of" (list .Values.app.ingress.entries.webmarketingapigw .) -}} +{{- $spa := include "url-of" (list .Values.app.ingress.entries.spa .) -}} +{{- $mongo := include "mongo-name" . -}} + + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "webspa.name" . }} + chart: {{ template "webspa.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + webspa__keystore: {{ .Values.inf.redis.keystore.constr }} + internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} + internalurls__basket__hc: http://{{ .Values.app.svc.basket }}/hc + internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc + internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc + internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc + internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc + internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc + urls__apigwws: http://{{ $webshoppingapigw }} + urls__spa: http://{{ $spa }} + urls__IdentityUrl: http://{{ $identity }} + urls__apigwwm: http://{{ $webmarketingapigw }} \ No newline at end of file diff --git a/k8s/helm/webspa/templates/deployment.yaml b/k8s/helm/webspa/templates/deployment.yaml new file mode 100644 index 000000000..62af2d8b1 --- /dev/null +++ b/k8s/helm/webspa/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "webspa.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "webspa.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "webspa.name" . }} + chart: {{ template "webspa.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "webspa.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "webspa.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/webspa/templates/ingress.yaml b/k8s/helm/webspa/templates/ingress.yaml new file mode 100644 index 000000000..85419f8e7 --- /dev/null +++ b/k8s/helm/webspa/templates/ingress.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "webspa.fullname" . }} + labels: + app: {{ template "webspa.name" . }} + chart: {{ template "webspa.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: {{ .Values.app.svc.spa }} + servicePort: http +{{- end }} diff --git a/k8s/helm/webspa/templates/service.yaml b/k8s/helm/webspa/templates/service.yaml new file mode 100644 index 000000000..2eab5d02e --- /dev/null +++ b/k8s/helm/webspa/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.spa }} + labels: + app: {{ template "webspa.name" . }} + chart: {{ template "webspa.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 "webspa.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/webspa/values.yaml b/k8s/helm/webspa/values.yaml new file mode 100644 index 000000000..e07909f6e --- /dev/null +++ b/k8s/helm/webspa/values.yaml @@ -0,0 +1,71 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: / + +image: + repository: eshop/webspa + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: UseLoadTest + key: all_EnableLoadTest + - name: DPConnectionString + key: webspa__keystore + - name: PurchaseUrl + key: urls__apigwws + - name: CallBackUrl + key: urls__spa + - name: IdentityUrl + key: urls__IdentityUrl + - name: MarketingUrl + key: urls__apigwwm + - name: BasketUrlHC + key: internalurls__basket__hc + - name: CatalogUrlHC + key: internalurls__catalog__hc + - name: IdentityUrlHC + key: internalurls__identity__hc + - name: OrderingUrlHC + key: internalurls__ordering__hc + - name: MarketingUrlHC + key: internalurls__marketing__hc + - name: PaymentUrlHC + key: internalurls__payment__hc + - name: SignalrHubUrl + key: urls__apigwws + # 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 + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: OrchestratorType + value: 'K8S' + - name: IsClusterEnv + value: 'True' + diff --git a/k8s/helm/webstatus/.helmignore b/k8s/helm/webstatus/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/webstatus/.helmignore @@ -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 diff --git a/k8s/helm/webstatus/Chart.yaml b/k8s/helm/webstatus/Chart.yaml new file mode 100644 index 000000000..9ee2783f4 --- /dev/null +++ b/k8s/helm/webstatus/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: webstatus +version: 0.1.0 diff --git a/k8s/helm/webstatus/templates/NOTES.txt b/k8s/helm/webstatus/templates/NOTES.txt new file mode 100644 index 000000000..5d9d4570d --- /dev/null +++ b/k8s/helm/webstatus/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop WebStatus installed. +-------------------------- \ No newline at end of file diff --git a/k8s/helm/webstatus/templates/_helpers.tpl b/k8s/helm/webstatus/templates/_helpers.tpl new file mode 100644 index 000000000..65b290af7 --- /dev/null +++ b/k8s/helm/webstatus/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "webstatus.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 "webstatus.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 "webstatus.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/webstatus/templates/_names.tpl b/k8s/helm/webstatus/templates/_names.tpl new file mode 100644 index 000000000..d44859fea --- /dev/null +++ b/k8s/helm/webstatus/templates/_names.tpl @@ -0,0 +1,52 @@ +{{- 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 .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/webstatus/templates/configmap.yaml b/k8s/helm/webstatus/templates/configmap.yaml new file mode 100644 index 000000000..805e33165 --- /dev/null +++ b/k8s/helm/webstatus/templates/configmap.yaml @@ -0,0 +1,36 @@ +{{- $name := include "webstatus.fullname" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} +{{- $mvc := include "url-of" (list .Values.app.ingress.entries.mvc .) -}} +{{- $mongo := include "mongo-name" . -}} + + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "webstatus.name" . }} + chart: {{ template "webstatus.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + all__InstrumentationKey: {{ .Values.inf.appinsights.key }} + all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" + all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" + webstatus__keystore: {{ .Values.inf.redis.keystore.constr }} + internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} + internalurls__apigwwm: http://{{ .Values.app.svc.webmarketingapigw }} + internalurls__basket__hc: http://{{ .Values.app.svc.basket }}/hc + internalurls__catalog__hc: http://{{ .Values.app.svc.catalog }}/hc + internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc + internalurls__ordering__hc: http://{{ .Values.app.svc.ordering }}/hc + internalurls__marketing__hc: http://{{ .Values.app.svc.marketing }}/hc + internalurls__payment__hc: http://{{ .Values.app.svc.payment }}/hc + internalurls__locations__hc: http://{{ .Values.app.svc.locations }}/hc + internalurls__orderingbackground__hc: http://{{ .Values.app.svc.orderingbackgroundtasks }}/hc + internalurls__mvc__hc: http://{{ .Values.app.svc.mvc }}/hc + internalurls__spa__hc: http://{{ .Values.app.svc.spa }}/hc + urls__apigwws: http://{{ $webshoppingapigw }} + urls__mvc: http://{{ $mvc }} + urls__IdentityUrl: http://{{ $identity }} diff --git a/k8s/helm/webstatus/templates/deployment.yaml b/k8s/helm/webstatus/templates/deployment.yaml new file mode 100644 index 000000000..6f96f81fb --- /dev/null +++ b/k8s/helm/webstatus/templates/deployment.yaml @@ -0,0 +1,71 @@ +{{- $name := include "webstatus.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "webstatus.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "webstatus.name" . }} + chart: {{ template "webstatus.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "webstatus.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "webstatus.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.inf.registry -}} + imagePullSecrets: + - name: {{ .Values.inf.registry.secretName }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + 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 }} + diff --git a/k8s/helm/webstatus/templates/ingress.yaml b/k8s/helm/webstatus/templates/ingress.yaml new file mode 100644 index 000000000..1ab4e5e22 --- /dev/null +++ b/k8s/helm/webstatus/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "webstatus.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "webstatus.fullname" . }} + labels: + app: {{ template "webstatus.name" . }} + chart: {{ template "webstatus.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: {{ .Values.app.svc.status }} + servicePort: http +{{- end }} diff --git a/k8s/helm/webstatus/templates/service.yaml b/k8s/helm/webstatus/templates/service.yaml new file mode 100644 index 000000000..37fff50c6 --- /dev/null +++ b/k8s/helm/webstatus/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.status }} + labels: + app: {{ template "webstatus.name" . }} + chart: {{ template "webstatus.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 "webstatus.name" . }} + release: {{ .Release.Name }} diff --git a/k8s/helm/webstatus/values.yaml b/k8s/helm/webstatus/values.yaml new file mode 100644 index 000000000..8e5912fda --- /dev/null +++ b/k8s/helm/webstatus/values.yaml @@ -0,0 +1,62 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /webstatus + +image: + repository: eshop/webstatus + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + 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: ApplicationInsights__InstrumentationKey + key: all__InstrumentationKey + - name: BasketUrl + key: internalurls__basket__hc + - name: CatalogUrl + key: internalurls__catalog__hc + - name: IdentityUrl + key: internalurls__identity__hc + - name: OrderingUrl + key: internalurls__ordering__hc + - name: OrderingBackgroundTasksUrl + key: internalurls__orderingbackground__hc + - name: LocationsUrl + key: internalurls__locations__hc + - name: MarketingUrl + key: internalurls__marketing__hc + - name: IdentityUrlHC + key: internalurls__identity__hc + - name: mvc + key: internalurls__mvc__hc + - name: spa + key: internalurls__spa__hc + - name: PaymentUrl + key: internalurls__payment__hc + # 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 + - name: OrchestratorType + value: 'K8S' diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index f564043ae..255bb82b5 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -151,6 +151,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API await next(); }); + app.UseForwardedHeaders(); // Adds IdentityServer app.UseIdentityServer();