From 85b1ae63ad0d9f4620216c50d8cef6aeb794a0ba Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 11:39:56 +0200 Subject: [PATCH 01/29] helm charts for eshop (catalog api, basket api, common inf) --- k8s/helm/app.yaml | 7 ++ k8s/helm/basket-api/.helmignore | 21 ++++++ k8s/helm/basket-api/Chart.yaml | 5 ++ k8s/helm/basket-api/templates/NOTES.txt | 19 +++++ k8s/helm/basket-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/basket-api/templates/_names.tpl | 33 +++++++++ k8s/helm/basket-api/templates/configmap.yaml | 19 +++++ k8s/helm/basket-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/basket-api/templates/ingress.yaml | 38 ++++++++++ k8s/helm/basket-api/templates/service.yaml | 19 +++++ k8s/helm/basket-api/values.yaml | 64 ++++++++++++++++ k8s/helm/catalog-api/.helmignore | 21 ++++++ k8s/helm/catalog-api/Chart.yaml | 5 ++ k8s/helm/catalog-api/templates/NOTES.txt | 19 +++++ k8s/helm/catalog-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/catalog-api/templates/_names.tpl | 33 +++++++++ k8s/helm/catalog-api/templates/configmap.yaml | 19 +++++ .../catalog-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/catalog-api/templates/ingress.yaml | 38 ++++++++++ k8s/helm/catalog-api/templates/service.yaml | 19 +++++ k8s/helm/catalog-api/values.yaml | 60 +++++++++++++++ k8s/helm/inf.yaml | 23 ++++++ 22 files changed, 672 insertions(+) create mode 100644 k8s/helm/app.yaml create mode 100644 k8s/helm/basket-api/.helmignore create mode 100644 k8s/helm/basket-api/Chart.yaml create mode 100644 k8s/helm/basket-api/templates/NOTES.txt create mode 100644 k8s/helm/basket-api/templates/_helpers.tpl create mode 100644 k8s/helm/basket-api/templates/_names.tpl create mode 100644 k8s/helm/basket-api/templates/configmap.yaml create mode 100644 k8s/helm/basket-api/templates/deployment.yaml create mode 100644 k8s/helm/basket-api/templates/ingress.yaml create mode 100644 k8s/helm/basket-api/templates/service.yaml create mode 100644 k8s/helm/basket-api/values.yaml create mode 100644 k8s/helm/catalog-api/.helmignore create mode 100644 k8s/helm/catalog-api/Chart.yaml create mode 100644 k8s/helm/catalog-api/templates/NOTES.txt create mode 100644 k8s/helm/catalog-api/templates/_helpers.tpl create mode 100644 k8s/helm/catalog-api/templates/_names.tpl create mode 100644 k8s/helm/catalog-api/templates/configmap.yaml create mode 100644 k8s/helm/catalog-api/templates/deployment.yaml create mode 100644 k8s/helm/catalog-api/templates/ingress.yaml create mode 100644 k8s/helm/catalog-api/templates/service.yaml create mode 100644 k8s/helm/catalog-api/values.yaml create mode 100644 k8s/helm/inf.yaml diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml new file mode 100644 index 000000000..92a878363 --- /dev/null +++ b/k8s/helm/app.yaml @@ -0,0 +1,7 @@ +# This heml values file defines app-based settings +# Charts use those values, so this file must be included in all chart releases + +app: + name: "my-eshop" # Override for custom application names. + ingress: + suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) \ No newline at end of file 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..ea08df066 --- /dev/null +++ b/k8s/helm/basket-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "basket-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "basket-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "basket-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..56d0cac88 --- /dev/null +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -0,0 +1,33 @@ +{{- 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 "url-identity" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- else -}} +{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- end -}} +{{- end -}} + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- 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..ae2f0d241 --- /dev/null +++ b/k8s/helm/basket-api/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- $name := include "basket-api.fullname" . -}} +{{- $identity := include "url-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..911818231 --- /dev/null +++ b/k8s/helm/basket-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/basket-api/templates/ingress.yaml new file mode 100644 index 000000000..9a47bb33f --- /dev/null +++ b/k8s/helm/basket-api/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "basket-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "basket-api.name" . }} + chart: {{ template "basket-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: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- 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..c3b4be3e3 --- /dev/null +++ b/k8s/helm/basket-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "basket-api.fullname" . }} + 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..c5d8ab1d8 --- /dev/null +++ b/k8s/helm/basket-api/values.yaml @@ -0,0 +1,64 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /basket-api + +image: + repository: eshop/basket.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - chart-example.local + tls: [] + +inf: # inf - see comments in ../inf.yaml file for info + redis: + basket: + constr: basket-data + eventbus: + constr: rabbitmq + useAzure: false + appinsights: + key: "" + k8s: + dns: "" + misc: + useLoadTest: false + +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/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..a44a24644 --- /dev/null +++ b/k8s/helm/catalog-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "catalog-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "catalog-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "catalog-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..56d0cac88 --- /dev/null +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -0,0 +1,33 @@ +{{- 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 "url-identity" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- else -}} +{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- end -}} +{{- end -}} + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- 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..75cf686f9 --- /dev/null +++ b/k8s/helm/catalog-api/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- $name := include "catalog-api.fullname" . -}} +{{- $sqlsrv := include "sql-name" . -}} + +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.catalog.user }};Password={{ .Values.inf.sql.catalog.pwd }}; + catalog__PicBaseUrl: http://{{ .Values.inf.k8s.dns }}/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..d508cd3ae --- /dev/null +++ b/k8s/helm/catalog-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/catalog-api/templates/ingress.yaml new file mode 100644 index 000000000..0833fb717 --- /dev/null +++ b/k8s/helm/catalog-api/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "catalog-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "catalog-api.name" . }} + chart: {{ template "catalog-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: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- 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..0291e6fac --- /dev/null +++ b/k8s/helm/catalog-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "catalog-api.fullname" . }} + 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..77fe93d19 --- /dev/null +++ b/k8s/helm/catalog-api/values.yaml @@ -0,0 +1,60 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /catalog-api + +image: + repository: eshop/catalog.api + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - chart-example.local + tls: [] + +inf: + sql: + catalog: + user: sa + pwd: Pass@word + db: CatalogDb + +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/inf.yaml b/k8s/helm/inf.yaml new file mode 100644 index 000000000..00be37261 --- /dev/null +++ b/k8s/helm/inf.yaml @@ -0,0 +1,23 @@ +# This heml values file defines all infrastructure used by eShopOnContainers. +# Any chart redefines its needed part, but this file allows an easy override of the whole infrastructure settings + +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 + catalog: # sql settings for the catalog-api sql (user, pwd, db) + user: sa # Catalog API SQL user + pwd: Pass@word # Catalog API SQL pwd + db: CatalogDb # Catalog API SQL db name + redis: # inf.redis defines the redis' connection strings + basket: + constr: basket-data # Connection string to Redis used by Basket API + eventbus: + constr: rabbitmq # Event bus connection strin g + 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 IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) + 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 From 3b6d08c0a0369722e940087d7f77aabb4e207863 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 11:59:05 +0200 Subject: [PATCH 02/29] ordering api helm chart --- k8s/helm/catalog-api/values.yaml | 10 +++ k8s/helm/inf.yaml | 6 +- k8s/helm/ordering-api/.helmignore | 21 ++++++ k8s/helm/ordering-api/Chart.yaml | 5 ++ k8s/helm/ordering-api/templates/NOTES.txt | 19 +++++ k8s/helm/ordering-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/ordering-api/templates/_names.tpl | 33 +++++++++ .../ordering-api/templates/configmap.yaml | 20 +++++ .../ordering-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/ordering-api/templates/ingress.yaml | 38 ++++++++++ k8s/helm/ordering-api/templates/service.yaml | 19 +++++ k8s/helm/ordering-api/values.yaml | 69 ++++++++++++++++++ 12 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 k8s/helm/ordering-api/.helmignore create mode 100644 k8s/helm/ordering-api/Chart.yaml create mode 100644 k8s/helm/ordering-api/templates/NOTES.txt create mode 100644 k8s/helm/ordering-api/templates/_helpers.tpl create mode 100644 k8s/helm/ordering-api/templates/_names.tpl create mode 100644 k8s/helm/ordering-api/templates/configmap.yaml create mode 100644 k8s/helm/ordering-api/templates/deployment.yaml create mode 100644 k8s/helm/ordering-api/templates/ingress.yaml create mode 100644 k8s/helm/ordering-api/templates/service.yaml create mode 100644 k8s/helm/ordering-api/values.yaml diff --git a/k8s/helm/catalog-api/values.yaml b/k8s/helm/catalog-api/values.yaml index 77fe93d19..c2f164ce6 100644 --- a/k8s/helm/catalog-api/values.yaml +++ b/k8s/helm/catalog-api/values.yaml @@ -24,6 +24,16 @@ inf: user: sa pwd: Pass@word db: CatalogDb + eventbus: + constr: rabbitmq + useAzure: false + appinsights: + key: "" + k8s: + dns: "" + misc: + useAzureStorage: false + resources: {} diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index 00be37261..bc91749a1 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -4,10 +4,14 @@ 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 - catalog: # sql settings for the catalog-api sql (user, pwd, db) + catalog: # inf.sql.catalog: settings for the catalog-api sql (user, pwd, db) user: sa # Catalog API SQL user pwd: Pass@word # Catalog API SQL pwd db: CatalogDb # Catalog API SQL db name + ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db) + user: sa # Ordering API SQL user + pwd: Pass@word # Ordering API SQL pwd + db: OrderingDb # Ordering API SQL db name redis: # inf.redis defines the redis' connection strings basket: constr: basket-data # Connection string to Redis used by Basket API 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..b44f4af4e --- /dev/null +++ b/k8s/helm/ordering-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "ordering-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..56d0cac88 --- /dev/null +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -0,0 +1,33 @@ +{{- 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 "url-identity" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- else -}} +{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- end -}} +{{- end -}} + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- 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..b59e1c934 --- /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-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.ordering.user }};Password={{ .Values.inf.sql.ordering.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..54ab5a6ed --- /dev/null +++ b/k8s/helm/ordering-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/ordering-api/templates/ingress.yaml new file mode 100644 index 000000000..3bb61dbc7 --- /dev/null +++ b/k8s/helm/ordering-api/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "ordering-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "ordering-api.name" . }} + chart: {{ template "ordering-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: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- 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..83545e5f8 --- /dev/null +++ b/k8s/helm/ordering-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ordering-api.fullname" . }} + 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..ee2bb2bb6 --- /dev/null +++ b/k8s/helm/ordering-api/values.yaml @@ -0,0 +1,69 @@ +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: [] + +inf: + sql: + ordering: + user: sa + pwd: Pass@word + db: CatalogDb + eventbus: + constr: rabbitmq + useAzure: false + appinsights: + key: "" + k8s: + dns: "" + misc: + useLoadTest: false + +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' + From 4ec4ecd92f91e9b792c815d49b504ab3f69dcb82 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 12:51:35 +0200 Subject: [PATCH 03/29] Ordering background tasks helm chart --- k8s/helm/ordering-backgroundtasks/.helmignore | 21 +++++ k8s/helm/ordering-backgroundtasks/Chart.yaml | 5 ++ .../templates/NOTES.txt | 19 +++++ .../templates/_helpers.tpl | 32 ++++++++ .../templates/_names.tpl | 33 ++++++++ .../templates/configmap.yaml | 20 +++++ .../templates/deployment.yaml | 73 ++++++++++++++++++ .../templates/ingress.yaml | 38 +++++++++ .../templates/service.yaml | 19 +++++ k8s/helm/ordering-backgroundtasks/values.yaml | 77 +++++++++++++++++++ 10 files changed, 337 insertions(+) create mode 100644 k8s/helm/ordering-backgroundtasks/.helmignore create mode 100644 k8s/helm/ordering-backgroundtasks/Chart.yaml create mode 100644 k8s/helm/ordering-backgroundtasks/templates/NOTES.txt create mode 100644 k8s/helm/ordering-backgroundtasks/templates/_helpers.tpl create mode 100644 k8s/helm/ordering-backgroundtasks/templates/_names.tpl create mode 100644 k8s/helm/ordering-backgroundtasks/templates/configmap.yaml create mode 100644 k8s/helm/ordering-backgroundtasks/templates/deployment.yaml create mode 100644 k8s/helm/ordering-backgroundtasks/templates/ingress.yaml create mode 100644 k8s/helm/ordering-backgroundtasks/templates/service.yaml create mode 100644 k8s/helm/ordering-backgroundtasks/values.yaml 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..7dbe60ba0 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-graceperiod.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "ordering-graceperiod.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-graceperiod.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-graceperiod.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..56d0cac88 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -0,0 +1,33 @@ +{{- 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 "url-identity" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- else -}} +{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- end -}} +{{- end -}} + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- 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..2e778b220 --- /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.ordering.user }};Password={{ .Values.inf.sql.ordering.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..16dc73400 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml new file mode 100644 index 000000000..1b2e5f66e --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "ordering-backgroundtasks.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "ordering-backgroundtasks.name" . }} + chart: {{ template "ordering-backgroundtasks.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: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- 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..c1738bd51 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ordering-backgroundtasks.fullname" . }} + 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..fdb297940 --- /dev/null +++ b/k8s/helm/ordering-backgroundtasks/values.yaml @@ -0,0 +1,77 @@ +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" + +inf: + sql: + ordering: + user: sa + pwd: Pass@word + db: CatalogDb + eventbus: + constr: rabbitmq + useAzure: false + appinsights: + key: "" + k8s: + dns: "" + misc: + useLoadTest: false + +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: IdentityUrl + key: urls__IdentityUrl + - 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' + From 74ae4de08b920f16c5f1525cf548cd4ae6b1aa76 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 13:33:17 +0200 Subject: [PATCH 04/29] Fixed configmap for ordering backgroundtasks --- k8s/helm/ordering-backgroundtasks/templates/configmap.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml index 2e778b220..60b2fe1ae 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml @@ -16,5 +16,5 @@ data: 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 + graceperiodmanager__CheckUpdateTime: "{{ .Values.cfg.checkUpdateTime }}" + graceperiodmanager__GracePeriodTime : "{{ .Values.cfg.gracePeriodTime }}" \ No newline at end of file From da97a7d3d8600ce2f5c376146e7eb7de38882a18 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 13:33:42 +0200 Subject: [PATCH 05/29] unwanted spaces :( --- k8s/helm/ordering-backgroundtasks/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml index 60b2fe1ae..ceaa7ea89 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml @@ -17,4 +17,4 @@ data: 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 + graceperiodmanager__GracePeriodTime: "{{ .Values.cfg.gracePeriodTime }}" \ No newline at end of file From c84ddb7f40d4549e57f108319b861a5d3df8557e Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 14 Jun 2018 16:30:29 +0200 Subject: [PATCH 06/29] Identity api some refactor on common templates --- k8s/helm/app.yaml | 28 +++++-- k8s/helm/identity-api/.helmignore | 21 ++++++ k8s/helm/identity-api/Chart.yaml | 5 ++ k8s/helm/identity-api/templates/NOTES.txt | 19 +++++ k8s/helm/identity-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/identity-api/templates/_names.tpl | 37 ++++++++++ .../identity-api/templates/configmap.yaml | 36 +++++++++ .../identity-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/identity-api/templates/ingress.yaml | 38 ++++++++++ k8s/helm/identity-api/templates/service.yaml | 19 +++++ k8s/helm/identity-api/values.yaml | 64 ++++++++++++++++ k8s/helm/inf.yaml | 8 +- 12 files changed, 374 insertions(+), 6 deletions(-) create mode 100644 k8s/helm/identity-api/.helmignore create mode 100644 k8s/helm/identity-api/Chart.yaml create mode 100644 k8s/helm/identity-api/templates/NOTES.txt create mode 100644 k8s/helm/identity-api/templates/_helpers.tpl create mode 100644 k8s/helm/identity-api/templates/_names.tpl create mode 100644 k8s/helm/identity-api/templates/configmap.yaml create mode 100644 k8s/helm/identity-api/templates/deployment.yaml create mode 100644 k8s/helm/identity-api/templates/ingress.yaml create mode 100644 k8s/helm/identity-api/templates/service.yaml create mode 100644 k8s/helm/identity-api/values.yaml diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index 92a878363..946a6f594 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -1,7 +1,25 @@ # This heml values file defines app-based settings -# Charts use those values, so this file must be included in all chart releases +# Charts use those values, so this file **MUST** be included in all chart releases -app: - name: "my-eshop" # Override for custom application names. - ingress: - suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) \ No newline at end of file + +app: # app global settings + name: "my-eshop" # Override for custom app name + ingress: # ingress related settings + suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) + 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: webspa # 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 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..a232b3af6 --- /dev/null +++ b/k8s/helm/identity-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "identity-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "identity-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "identity-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "identity-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 +{{- end }} 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..bbf3888d5 --- /dev/null +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -0,0 +1,37 @@ +{{- 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 "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- 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..d3dd2b9a7 --- /dev/null +++ b/k8s/helm/identity-api/templates/configmap.yaml @@ -0,0 +1,36 @@ +{{- $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.identity.user }};Password={{ .Values.inf.sql.identity.pwd }}; + identity__keystore: http://{{ .Values.inf.redis.keystore.constr }} + all__InstrumentationKey: http://{{ .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..6cd425afd --- /dev/null +++ b/k8s/helm/identity-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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..40822737c --- /dev/null +++ b/k8s/helm/identity-api/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "identity-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- 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..406bb3544 --- /dev/null +++ b/k8s/helm/identity-api/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "identity-api.fullname" . }} + 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..77609b12b --- /dev/null +++ b/k8s/helm/identity-api/values.yaml @@ -0,0 +1,64 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /identity + +image: + repository: eshop/ordering.backgroundtasks + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + 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 index bc91749a1..04814a97b 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -1,5 +1,5 @@ # This heml values file defines all infrastructure used by eShopOnContainers. -# Any chart redefines its needed part, but this file allows an easy override of the whole infrastructure settings +# It is used on all charts, so ** MUST BE INCLUDED ** on every deployment inf: sql: # inf.sql defines the sql server databases & logins @@ -12,9 +12,15 @@ inf: user: sa # Ordering API SQL user pwd: Pass@word # Ordering API SQL pwd db: OrderingDb # Ordering API SQL db name + identity: + user: sa # Ordering API SQL user + pwd: Pass@word # Ordering API SQL pwd + db: IdentityDb # Ordering API SQL db name redis: # inf.redis defines the redis' connection strings basket: constr: basket-data # Connection string to Redis used by Basket API + keystore: + constr: keystore-data # Connection string to Redis used as a Keystore (by Identity API) eventbus: constr: rabbitmq # Event bus connection strin g useAzure: false # true if use Azure Service Bus. False if RabbitMQ From cb605938a89effdf259844a19ee8cd06793baebb Mon Sep 17 00:00:00 2001 From: eiximenis Date: Fri, 15 Jun 2018 15:27:18 +0200 Subject: [PATCH 07/29] WIP on helm charts --- k8s/helm/basket-api/templates/_names.tpl | 14 ++- k8s/helm/basket-api/templates/configmap.yaml | 2 +- k8s/helm/basket-api/values.yaml | 14 --- k8s/helm/catalog-api/templates/_names.tpl | 14 ++- k8s/helm/catalog-api/values.yaml | 17 ---- k8s/helm/eshoponcontainers/.helmignore | 21 ++++ k8s/helm/eshoponcontainers/Chart.yaml | 5 + .../eshoponcontainers/templates/NOTES.txt | 19 ++++ .../eshoponcontainers/templates/_helpers.tpl | 32 ++++++ .../eshoponcontainers/templates/_names.tpl | 37 +++++++ k8s/helm/eshoponcontainers/values.yaml | 98 +++++++++++++++++++ .../identity-api/templates/configmap.yaml | 1 - k8s/helm/ordering-api/templates/_names.tpl | 14 ++- .../ordering-api/templates/configmap.yaml | 2 +- k8s/helm/ordering-api/values.yaml | 16 --- .../templates/NOTES.txt | 8 +- .../templates/_names.tpl | 14 ++- k8s/helm/ordering-backgroundtasks/values.yaml | 16 --- 18 files changed, 254 insertions(+), 90 deletions(-) create mode 100644 k8s/helm/eshoponcontainers/.helmignore create mode 100644 k8s/helm/eshoponcontainers/Chart.yaml create mode 100644 k8s/helm/eshoponcontainers/templates/NOTES.txt create mode 100644 k8s/helm/eshoponcontainers/templates/_helpers.tpl create mode 100644 k8s/helm/eshoponcontainers/templates/_names.tpl create mode 100644 k8s/helm/eshoponcontainers/values.yaml diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index 56d0cac88..bbf3888d5 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -14,15 +14,19 @@ {{- end -}} {{- end -}} -{{- define "url-identity" -}} -{{- if .Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{- else -}} -{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{- end -}} {{- end -}} + + {{ define "pathBase" -}} {{- if .Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" . -}} diff --git a/k8s/helm/basket-api/templates/configmap.yaml b/k8s/helm/basket-api/templates/configmap.yaml index ae2f0d241..c851de359 100644 --- a/k8s/helm/basket-api/templates/configmap.yaml +++ b/k8s/helm/basket-api/templates/configmap.yaml @@ -1,5 +1,5 @@ {{- $name := include "basket-api.fullname" . -}} -{{- $identity := include "url-identity" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} apiVersion: v1 kind: ConfigMap diff --git a/k8s/helm/basket-api/values.yaml b/k8s/helm/basket-api/values.yaml index c5d8ab1d8..95ba3a9d9 100644 --- a/k8s/helm/basket-api/values.yaml +++ b/k8s/helm/basket-api/values.yaml @@ -18,20 +18,6 @@ ingress: - chart-example.local tls: [] -inf: # inf - see comments in ../inf.yaml file for info - redis: - basket: - constr: basket-data - eventbus: - constr: rabbitmq - useAzure: false - appinsights: - key: "" - k8s: - dns: "" - misc: - useLoadTest: false - resources: {} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index 56d0cac88..bbf3888d5 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -14,15 +14,19 @@ {{- end -}} {{- end -}} -{{- define "url-identity" -}} -{{- if .Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{- else -}} -{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{- end -}} {{- end -}} + + {{ define "pathBase" -}} {{- if .Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" . -}} diff --git a/k8s/helm/catalog-api/values.yaml b/k8s/helm/catalog-api/values.yaml index c2f164ce6..28d5c6521 100644 --- a/k8s/helm/catalog-api/values.yaml +++ b/k8s/helm/catalog-api/values.yaml @@ -18,23 +18,6 @@ ingress: - chart-example.local tls: [] -inf: - sql: - catalog: - user: sa - pwd: Pass@word - db: CatalogDb - eventbus: - constr: rabbitmq - useAzure: false - appinsights: - key: "" - k8s: - dns: "" - misc: - useAzureStorage: false - - resources: {} diff --git a/k8s/helm/eshoponcontainers/.helmignore b/k8s/helm/eshoponcontainers/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/k8s/helm/eshoponcontainers/.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/eshoponcontainers/Chart.yaml b/k8s/helm/eshoponcontainers/Chart.yaml new file mode 100644 index 000000000..50190946e --- /dev/null +++ b/k8s/helm/eshoponcontainers/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: Umbrella Chart for eShopOnContainers +name: eshoponcontainers +version: 0.1.0 diff --git a/k8s/helm/eshoponcontainers/templates/NOTES.txt b/k8s/helm/eshoponcontainers/templates/NOTES.txt new file mode 100644 index 000000000..80822d767 --- /dev/null +++ b/k8s/helm/eshoponcontainers/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "eshoponcontainers.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "eshoponcontainers.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "eshoponcontainers.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "eshoponcontainers.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/k8s/helm/eshoponcontainers/templates/_helpers.tpl b/k8s/helm/eshoponcontainers/templates/_helpers.tpl new file mode 100644 index 000000000..e3175d5c1 --- /dev/null +++ b/k8s/helm/eshoponcontainers/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "eshoponcontainers.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 "eshoponcontainers.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 "eshoponcontainers.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/k8s/helm/eshoponcontainers/templates/_names.tpl b/k8s/helm/eshoponcontainers/templates/_names.tpl new file mode 100644 index 000000000..bbf3888d5 --- /dev/null +++ b/k8s/helm/eshoponcontainers/templates/_names.tpl @@ -0,0 +1,37 @@ +{{- 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 "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/k8s/helm/eshoponcontainers/values.yaml b/k8s/helm/eshoponcontainers/values.yaml new file mode 100644 index 000000000..e931cf463 --- /dev/null +++ b/k8s/helm/eshoponcontainers/values.yaml @@ -0,0 +1,98 @@ +# Default values for eshoponcontainers. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + tag: stable + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +global: + app: # app global settings + name: "my-eshop" # Override for custom app name + ingress: # ingress related settings + suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) + 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: webspa # 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 + 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 + catalog: # inf.sql.catalog: settings for the catalog-api sql (user, pwd, db) + user: sa # Catalog API SQL user + pwd: Pass@word # Catalog API SQL pwd + db: CatalogDb # Catalog API SQL db name + ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db) + user: sa # Ordering API SQL user + pwd: Pass@word # Ordering API SQL pwd + db: OrderingDb # Ordering API SQL db name + identity: + user: sa # Ordering API SQL user + pwd: Pass@word # Ordering API SQL pwd + db: IdentityDb # Ordering API SQL db name + redis: # inf.redis defines the redis' connection strings + basket: + constr: basket-data # Connection string to Redis used by Basket API + keystore: + constr: keystore-data # Connection string to Redis used as a Keystore (by Identity API) + eventbus: + constr: rabbitmq # Event bus connection strin g + 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 IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) + 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 diff --git a/k8s/helm/identity-api/templates/configmap.yaml b/k8s/helm/identity-api/templates/configmap.yaml index d3dd2b9a7..f0ad8de3f 100644 --- a/k8s/helm/identity-api/templates/configmap.yaml +++ b/k8s/helm/identity-api/templates/configmap.yaml @@ -10,7 +10,6 @@ {{- $webhoppingagg := include "url-of" (list .Values.app.ingress.entries.webshoppingagg .) -}} {{- $xamarincallback := include "url-of" (list "xamarincallback" .) -}} - apiVersion: v1 kind: ConfigMap metadata: diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index 56d0cac88..bbf3888d5 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -14,15 +14,19 @@ {{- end -}} {{- end -}} -{{- define "url-identity" -}} -{{- if .Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{- else -}} -{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{- end -}} {{- end -}} + + {{ define "pathBase" -}} {{- if .Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" . -}} diff --git a/k8s/helm/ordering-api/templates/configmap.yaml b/k8s/helm/ordering-api/templates/configmap.yaml index b59e1c934..a43663308 100644 --- a/k8s/helm/ordering-api/templates/configmap.yaml +++ b/k8s/helm/ordering-api/templates/configmap.yaml @@ -1,6 +1,6 @@ {{- $name := include "ordering-api.fullname" . -}} {{- $sqlsrv := include "sql-name" . -}} -{{- $identity := include "url-identity" . -}} +{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}} apiVersion: v1 kind: ConfigMap diff --git a/k8s/helm/ordering-api/values.yaml b/k8s/helm/ordering-api/values.yaml index ee2bb2bb6..c4a7cdf99 100644 --- a/k8s/helm/ordering-api/values.yaml +++ b/k8s/helm/ordering-api/values.yaml @@ -18,22 +18,6 @@ ingress: - chart-example.local tls: [] -inf: - sql: - ordering: - user: sa - pwd: Pass@word - db: CatalogDb - eventbus: - constr: rabbitmq - useAzure: false - appinsights: - key: "" - k8s: - dns: "" - misc: - useLoadTest: false - resources: {} diff --git a/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt index 7dbe60ba0..b8efad3d8 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt +++ b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt @@ -4,16 +4,16 @@ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-graceperiod.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-backgroundtasks.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "ordering-graceperiod.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-graceperiod.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + You can watch the status of by running 'kubectl get svc -w {{ template "ordering-backgroundtasks.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-backgroundtasks.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-graceperiod.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-backgroundtasks.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:80 {{- end }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index 56d0cac88..bbf3888d5 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -14,15 +14,19 @@ {{- end -}} {{- end -}} -{{- define "url-identity" -}} -{{- if .Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}} +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.app.ingress.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{- else -}} -{{- printf "%s/identity-api" .Values.inf.k8s.dns -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{- end -}} {{- end -}} + + {{ define "pathBase" -}} {{- if .Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" . -}} diff --git a/k8s/helm/ordering-backgroundtasks/values.yaml b/k8s/helm/ordering-backgroundtasks/values.yaml index fdb297940..e1b97daf9 100644 --- a/k8s/helm/ordering-backgroundtasks/values.yaml +++ b/k8s/helm/ordering-backgroundtasks/values.yaml @@ -22,22 +22,6 @@ cfg: checkUpdateTime: "15000" gracePeriodTime: "1" -inf: - sql: - ordering: - user: sa - pwd: Pass@word - db: CatalogDb - eventbus: - constr: rabbitmq - useAzure: false - appinsights: - key: "" - k8s: - dns: "" - misc: - useLoadTest: false - resources: {} From 84761fd7af28a00514cb5604e540e1349402f528 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Fri, 15 Jun 2018 15:27:58 +0200 Subject: [PATCH 08/29] remove non used chart --- k8s/helm/eshoponcontainers/.helmignore | 21 ---- k8s/helm/eshoponcontainers/Chart.yaml | 5 - .../eshoponcontainers/templates/NOTES.txt | 19 ---- .../eshoponcontainers/templates/_helpers.tpl | 32 ------ .../eshoponcontainers/templates/_names.tpl | 37 ------- k8s/helm/eshoponcontainers/values.yaml | 98 ------------------- 6 files changed, 212 deletions(-) delete mode 100644 k8s/helm/eshoponcontainers/.helmignore delete mode 100644 k8s/helm/eshoponcontainers/Chart.yaml delete mode 100644 k8s/helm/eshoponcontainers/templates/NOTES.txt delete mode 100644 k8s/helm/eshoponcontainers/templates/_helpers.tpl delete mode 100644 k8s/helm/eshoponcontainers/templates/_names.tpl delete mode 100644 k8s/helm/eshoponcontainers/values.yaml diff --git a/k8s/helm/eshoponcontainers/.helmignore b/k8s/helm/eshoponcontainers/.helmignore deleted file mode 100644 index f0c131944..000000000 --- a/k8s/helm/eshoponcontainers/.helmignore +++ /dev/null @@ -1,21 +0,0 @@ -# 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/eshoponcontainers/Chart.yaml b/k8s/helm/eshoponcontainers/Chart.yaml deleted file mode 100644 index 50190946e..000000000 --- a/k8s/helm/eshoponcontainers/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: Umbrella Chart for eShopOnContainers -name: eshoponcontainers -version: 0.1.0 diff --git a/k8s/helm/eshoponcontainers/templates/NOTES.txt b/k8s/helm/eshoponcontainers/templates/NOTES.txt deleted file mode 100644 index 80822d767..000000000 --- a/k8s/helm/eshoponcontainers/templates/NOTES.txt +++ /dev/null @@ -1,19 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "eshoponcontainers.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "eshoponcontainers.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "eshoponcontainers.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "eshoponcontainers.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/k8s/helm/eshoponcontainers/templates/_helpers.tpl b/k8s/helm/eshoponcontainers/templates/_helpers.tpl deleted file mode 100644 index e3175d5c1..000000000 --- a/k8s/helm/eshoponcontainers/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "eshoponcontainers.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 "eshoponcontainers.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 "eshoponcontainers.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/k8s/helm/eshoponcontainers/templates/_names.tpl b/k8s/helm/eshoponcontainers/templates/_names.tpl deleted file mode 100644 index bbf3888d5..000000000 --- a/k8s/helm/eshoponcontainers/templates/_names.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{{- 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 "url-of" -}} -{{- $name := first .}} -{{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} -{{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} -{{- end -}} -{{- end -}} - - - -{{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} -{{- else -}} -{{- .Values.pathBase -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/k8s/helm/eshoponcontainers/values.yaml b/k8s/helm/eshoponcontainers/values.yaml deleted file mode 100644 index e931cf463..000000000 --- a/k8s/helm/eshoponcontainers/values.yaml +++ /dev/null @@ -1,98 +0,0 @@ -# Default values for eshoponcontainers. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - path: / - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -global: - app: # app global settings - name: "my-eshop" # Override for custom app name - ingress: # ingress related settings - suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) - 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: webspa # 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 - 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 - catalog: # inf.sql.catalog: settings for the catalog-api sql (user, pwd, db) - user: sa # Catalog API SQL user - pwd: Pass@word # Catalog API SQL pwd - db: CatalogDb # Catalog API SQL db name - ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db) - user: sa # Ordering API SQL user - pwd: Pass@word # Ordering API SQL pwd - db: OrderingDb # Ordering API SQL db name - identity: - user: sa # Ordering API SQL user - pwd: Pass@word # Ordering API SQL pwd - db: IdentityDb # Ordering API SQL db name - redis: # inf.redis defines the redis' connection strings - basket: - constr: basket-data # Connection string to Redis used by Basket API - keystore: - constr: keystore-data # Connection string to Redis used as a Keystore (by Identity API) - eventbus: - constr: rabbitmq # Event bus connection strin g - 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 IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) - 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 From 519ecc5897af6bfad08eb27bb32f07c929d28ee5 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 10:47:39 +0200 Subject: [PATCH 09/29] Updating ingress templates to use .values.inf.k8s.dns value instead of values.ingress.hosts Updating names template to allow generation of external url values using dns prefix --- k8s/helm/app.yaml | 1 - k8s/helm/basket-api/templates/_names.tpl | 12 ++++++++---- k8s/helm/basket-api/templates/ingress.yaml | 8 ++------ k8s/helm/catalog-api/templates/_names.tpl | 12 ++++++++---- k8s/helm/catalog-api/templates/ingress.yaml | 8 ++------ k8s/helm/identity-api/templates/_names.tpl | 12 ++++++++---- k8s/helm/identity-api/templates/ingress.yaml | 8 ++------ k8s/helm/inf.yaml | 2 ++ k8s/helm/ordering-api/templates/_names.tpl | 12 ++++++++---- k8s/helm/ordering-api/templates/ingress.yaml | 8 ++------ .../ordering-backgroundtasks/templates/_names.tpl | 12 ++++++++---- .../ordering-backgroundtasks/templates/ingress.yaml | 8 ++------ 12 files changed, 52 insertions(+), 51 deletions(-) diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index 946a6f594..f0a7edeb2 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -5,7 +5,6 @@ app: # app global settings name: "my-eshop" # Override for custom app name ingress: # ingress related settings - suffix: false # if true ingress endpoints are suffixed with .Values.appName value (or .Release.Name if the 1st do not exist) entries: basket: basket-api # ingress entry for basket api catalog: catalog-api # ingress entry for catalog api diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/basket-api/templates/ingress.yaml b/k8s/helm/basket-api/templates/ingress.yaml index 9a47bb33f..f34e71680 100644 --- a/k8s/helm/basket-api/templates/ingress.yaml +++ b/k8s/helm/basket-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/catalog-api/templates/ingress.yaml b/k8s/helm/catalog-api/templates/ingress.yaml index 0833fb717..3efabacac 100644 --- a/k8s/helm/catalog-api/templates/ingress.yaml +++ b/k8s/helm/catalog-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/identity-api/templates/_names.tpl +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/identity-api/templates/ingress.yaml b/k8s/helm/identity-api/templates/ingress.yaml index 40822737c..ff26c67b7 100644 --- a/k8s/helm/identity-api/templates/ingress.yaml +++ b/k8s/helm/identity-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index 04814a97b..e112fa766 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -28,6 +28,8 @@ inf: key: "" # App insights to use k8s: # inf.k8s defines Kubernetes cluster global config dns: "" # k8s external IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) + dnsprefix: true # If 'true' DNS values in ingress are prefixed using values.app.name. Note that this requires "externalDNS" to be running in k8s cluster. If true "inf.k8s.suffix" is ignored. + suffix: false # If 'true' URL values in ingress are suffixed using values.app.name. That do not require anything special in cluster and still allows many apps using same ingress controller. Ignored if inf.k8s.dnsprefix is true 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 diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/ordering-api/templates/ingress.yaml b/k8s/helm/ordering-api/templates/ingress.yaml index 3bb61dbc7..ac390c7f8 100644 --- a/k8s/helm/ordering-api/templates/ingress.yaml +++ b/k8s/helm/ordering-api/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index bbf3888d5..0611ab704 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -17,18 +17,22 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- if $ctx.Values.app.ingress.suffix -}} {{- $suffix := include "suffix-name" $ctx -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} {{- end -}} {{- end -}} {{ define "pathBase" -}} -{{- if .Values.app.ingress.suffix -}} +{{- if .Values.inf.k8s.suffix -}} {{- $suffix := include "suffix-name" . -}} {{- printf "%s-%s" .Values.pathBase $suffix -}} {{- else -}} diff --git a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml index 1b2e5f66e..40a545cab 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml @@ -19,20 +19,16 @@ spec: tls: {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} - - {{ . }} - {{- end }} + - {{ .Values.inf.k8s.dns }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . }} + - host: {{ .Values.inf.k8s.dns }} http: paths: - path: {{ $ingressPath }} backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} {{- end }} From 49f1ca18d51cf42cde24697d011f766dd64b269b Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 11:34:34 +0200 Subject: [PATCH 10/29] ordering signalrhub chart --- k8s/helm/ordering-signalrhub/.helmignore | 21 ++++++ k8s/helm/ordering-signalrhub/Chart.yaml | 5 ++ .../ordering-signalrhub/templates/NOTES.txt | 19 +++++ .../templates/_helpers.tpl | 32 ++++++++ .../ordering-signalrhub/templates/_names.tpl | 41 +++++++++++ .../templates/configmap.yaml | 18 +++++ .../templates/deployment.yaml | 73 +++++++++++++++++++ .../templates/ingress.yaml | 34 +++++++++ .../templates/service.yaml | 19 +++++ k8s/helm/ordering-signalrhub/values.yaml | 57 +++++++++++++++ 10 files changed, 319 insertions(+) create mode 100644 k8s/helm/ordering-signalrhub/.helmignore create mode 100644 k8s/helm/ordering-signalrhub/Chart.yaml create mode 100644 k8s/helm/ordering-signalrhub/templates/NOTES.txt create mode 100644 k8s/helm/ordering-signalrhub/templates/_helpers.tpl create mode 100644 k8s/helm/ordering-signalrhub/templates/_names.tpl create mode 100644 k8s/helm/ordering-signalrhub/templates/configmap.yaml create mode 100644 k8s/helm/ordering-signalrhub/templates/deployment.yaml create mode 100644 k8s/helm/ordering-signalrhub/templates/ingress.yaml create mode 100644 k8s/helm/ordering-signalrhub/templates/service.yaml create mode 100644 k8s/helm/ordering-signalrhub/values.yaml 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..aed454cbe --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-signalrhub.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "ordering-signalrhub.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-signalrhub.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..0611ab704 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/_names.tpl @@ -0,0 +1,41 @@ +{{- 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 "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..91d2f80ae --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $name := include "ordering-signalrhub.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "ordering-signalrhub.fullname" . }} + labels: + ufo: {{ $cfgname}} + 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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/ordering-signalrhub/templates/ingress.yaml new file mode 100644 index 000000000..30bc51070 --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "ordering-signalrhub.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "ordering-signalrhub.name" . }} + chart: {{ template "ordering-signalrhub.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + - {{ .Values.inf.k8s.dns }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + - host: {{ .Values.inf.k8s.dns }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http +{{- end }} diff --git a/k8s/helm/ordering-signalrhub/templates/service.yaml b/k8s/helm/ordering-signalrhub/templates/service.yaml new file mode 100644 index 000000000..b76486d8f --- /dev/null +++ b/k8s/helm/ordering-signalrhub/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ordering-signalrhub.fullname" . }} + 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..13c3906e9 --- /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' + From 9c95402f9407360e8426e6325ef6587a9957292b Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 12:39:20 +0200 Subject: [PATCH 11/29] Locations api updates on service names generation --- k8s/helm/app.yaml | 17 +++++ k8s/helm/identity-api/templates/service.yaml | 2 +- k8s/helm/inf.yaml | 6 ++ k8s/helm/locations-api/.helmignore | 21 ++++++ k8s/helm/locations-api/Chart.yaml | 5 ++ k8s/helm/locations-api/templates/NOTES.txt | 19 +++++ k8s/helm/locations-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/locations-api/templates/_names.tpl | 49 +++++++++++++ .../locations-api/templates/configmap.yaml | 22 ++++++ .../locations-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/locations-api/templates/ingress.yaml | 34 +++++++++ k8s/helm/locations-api/templates/service.yaml | 19 +++++ k8s/helm/locations-api/values.yaml | 55 ++++++++++++++ 13 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 k8s/helm/locations-api/.helmignore create mode 100644 k8s/helm/locations-api/Chart.yaml create mode 100644 k8s/helm/locations-api/templates/NOTES.txt create mode 100644 k8s/helm/locations-api/templates/_helpers.tpl create mode 100644 k8s/helm/locations-api/templates/_names.tpl create mode 100644 k8s/helm/locations-api/templates/configmap.yaml create mode 100644 k8s/helm/locations-api/templates/deployment.yaml create mode 100644 k8s/helm/locations-api/templates/ingress.yaml create mode 100644 k8s/helm/locations-api/templates/service.yaml create mode 100644 k8s/helm/locations-api/values.yaml diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index f0a7edeb2..0cc140b0d 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -22,3 +22,20 @@ app: # app global settings 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 + 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 api diff --git a/k8s/helm/identity-api/templates/service.yaml b/k8s/helm/identity-api/templates/service.yaml index 406bb3544..bca200389 100644 --- a/k8s/helm/identity-api/templates/service.yaml +++ b/k8s/helm/identity-api/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "identity-api.fullname" . }} + name: {{ .Values.app.svc.identity }} labels: app: {{ template "identity-api.name" . }} chart: {{ template "identity-api.chart" . }} diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index e112fa766..de2ca3058 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -16,6 +16,12 @@ inf: user: sa # Ordering API SQL user pwd: Pass@word # Ordering API SQL pwd 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: constr: basket-data # Connection string to Redis used by Basket API 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..51aea5725 --- /dev/null +++ b/k8s/helm/locations-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "locations-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "locations-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "locations-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..0f42702d4 --- /dev/null +++ b/k8s/helm/locations-api/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..826dd80a1 --- /dev/null +++ b/k8s/helm/locations-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/locations-api/templates/ingress.yaml new file mode 100644 index 000000000..fa6c5b815 --- /dev/null +++ b/k8s/helm/locations-api/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "locations-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "locations-api.name" . }} + chart: {{ template "locations-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: {{ $fullName }} + servicePort: http +{{- 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' + From 68d753d0f087ed0318c33dc2030cc2b9bd368d69 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 12:45:07 +0200 Subject: [PATCH 12/29] Updated service names generation --- k8s/helm/app.yaml | 34 ++++++++++--------- k8s/helm/basket-api/templates/_names.tpl | 8 +++++ k8s/helm/basket-api/templates/service.yaml | 2 +- k8s/helm/catalog-api/templates/_names.tpl | 8 +++++ k8s/helm/catalog-api/templates/service.yaml | 2 +- k8s/helm/identity-api/templates/_names.tpl | 8 +++++ k8s/helm/ordering-api/templates/_names.tpl | 8 +++++ k8s/helm/ordering-api/templates/service.yaml | 2 +- .../templates/_names.tpl | 8 +++++ .../templates/service.yaml | 2 +- .../ordering-signalrhub/templates/_names.tpl | 8 +++++ .../templates/service.yaml | 2 +- 12 files changed, 71 insertions(+), 21 deletions(-) diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index 0cc140b0d..b92f73ac8 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -23,19 +23,21 @@ app: # app global settings 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 - 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 api + 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 api diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/basket-api/templates/service.yaml b/k8s/helm/basket-api/templates/service.yaml index c3b4be3e3..20224c3b5 100644 --- a/k8s/helm/basket-api/templates/service.yaml +++ b/k8s/helm/basket-api/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "basket-api.fullname" . }} + name: {{ .Values.app.svc.basket }} labels: app: {{ template "basket-api.name" . }} chart: {{ template "basket-api.chart" . }} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/catalog-api/templates/service.yaml b/k8s/helm/catalog-api/templates/service.yaml index 0291e6fac..e63d4a4fc 100644 --- a/k8s/helm/catalog-api/templates/service.yaml +++ b/k8s/helm/catalog-api/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "catalog-api.fullname" . }} + name: {{ .Values.app.svc.catalog }} labels: app: {{ template "catalog-api.name" . }} chart: {{ template "catalog-api.chart" . }} diff --git a/k8s/helm/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/identity-api/templates/_names.tpl +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/ordering-api/templates/service.yaml b/k8s/helm/ordering-api/templates/service.yaml index 83545e5f8..bedfd6f01 100644 --- a/k8s/helm/ordering-api/templates/service.yaml +++ b/k8s/helm/ordering-api/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "ordering-api.fullname" . }} + name: {{ .Values.app.svc.ordering }} labels: app: {{ template "ordering-api.name" . }} chart: {{ template "ordering-api.chart" . }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/ordering-backgroundtasks/templates/service.yaml b/k8s/helm/ordering-backgroundtasks/templates/service.yaml index c1738bd51..d8fcba036 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/service.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "ordering-backgroundtasks.fullname" . }} + name: {{ .Values.app.svc.orderingbackgroundtasks }} labels: app: {{ template "ordering-backgroundtasks.name" . }} chart: {{ template "ordering-backgroundtasks.chart" . }} diff --git a/k8s/helm/ordering-signalrhub/templates/_names.tpl b/k8s/helm/ordering-signalrhub/templates/_names.tpl index 0611ab704..0f42702d4 100644 --- a/k8s/helm/ordering-signalrhub/templates/_names.tpl +++ b/k8s/helm/ordering-signalrhub/templates/_names.tpl @@ -14,6 +14,14 @@ {{- 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 .}} diff --git a/k8s/helm/ordering-signalrhub/templates/service.yaml b/k8s/helm/ordering-signalrhub/templates/service.yaml index b76486d8f..501539923 100644 --- a/k8s/helm/ordering-signalrhub/templates/service.yaml +++ b/k8s/helm/ordering-signalrhub/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "ordering-signalrhub.fullname" . }} + name: {{ .Values.app.svc.orderingsignalrhub }} labels: app: {{ template "ordering-signalrhub.name" . }} chart: {{ template "ordering-signalrhub.chart" . }} From e6628f1a44507891d478d6969ace2b116a3e58b5 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 13:03:18 +0200 Subject: [PATCH 13/29] marketing api chart helm --- k8s/helm/marketing-api/.helmignore | 21 ++++++ k8s/helm/marketing-api/Chart.yaml | 5 ++ k8s/helm/marketing-api/templates/NOTES.txt | 19 +++++ k8s/helm/marketing-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/marketing-api/templates/_names.tpl | 49 +++++++++++++ .../marketing-api/templates/configmap.yaml | 22 ++++++ .../marketing-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/marketing-api/templates/ingress.yaml | 34 +++++++++ k8s/helm/marketing-api/templates/service.yaml | 19 +++++ k8s/helm/marketing-api/values.yaml | 55 ++++++++++++++ 10 files changed, 329 insertions(+) create mode 100644 k8s/helm/marketing-api/.helmignore create mode 100644 k8s/helm/marketing-api/Chart.yaml create mode 100644 k8s/helm/marketing-api/templates/NOTES.txt create mode 100644 k8s/helm/marketing-api/templates/_helpers.tpl create mode 100644 k8s/helm/marketing-api/templates/_names.tpl create mode 100644 k8s/helm/marketing-api/templates/configmap.yaml create mode 100644 k8s/helm/marketing-api/templates/deployment.yaml create mode 100644 k8s/helm/marketing-api/templates/ingress.yaml create mode 100644 k8s/helm/marketing-api/templates/service.yaml create mode 100644 k8s/helm/marketing-api/values.yaml 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..99f820091 --- /dev/null +++ b/k8s/helm/marketing-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "marketing-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "marketing-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "marketing-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..0f42702d4 --- /dev/null +++ b/k8s/helm/marketing-api/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..89cbfeb51 --- /dev/null +++ b/k8s/helm/marketing-api/templates/configmap.yaml @@ -0,0 +1,22 @@ +{{- $name := include "marketing-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 "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 }} \ 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..3aa1927e9 --- /dev/null +++ b/k8s/helm/marketing-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/marketing-api/templates/ingress.yaml new file mode 100644 index 000000000..5b4aa12ee --- /dev/null +++ b/k8s/helm/marketing-api/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "marketing-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "marketing-api.name" . }} + chart: {{ template "marketing-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: {{ $fullName }} + servicePort: http +{{- 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..0258eed8d --- /dev/null +++ b/k8s/helm/marketing-api/values.yaml @@ -0,0 +1,55 @@ +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 + # 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' + From cbe1a9f1051b19809bc5cc7aa152edb99ffd3c4e Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 13:11:54 +0200 Subject: [PATCH 14/29] some corrections on how some external urls are calculated --- k8s/helm/basket-api/templates/_names.tpl | 6 +++--- k8s/helm/catalog-api/templates/_names.tpl | 6 +++--- k8s/helm/catalog-api/templates/configmap.yaml | 3 ++- k8s/helm/identity-api/templates/_names.tpl | 6 +++--- k8s/helm/locations-api/templates/_names.tpl | 6 +++--- k8s/helm/marketing-api/templates/_names.tpl | 6 +++--- k8s/helm/marketing-api/templates/configmap.yaml | 4 +++- k8s/helm/marketing-api/values.yaml | 2 ++ k8s/helm/ordering-api/templates/_names.tpl | 6 +++--- k8s/helm/ordering-backgroundtasks/templates/_names.tpl | 6 +++--- k8s/helm/ordering-signalrhub/templates/_names.tpl | 6 +++--- 11 files changed, 31 insertions(+), 26 deletions(-) diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/catalog-api/templates/configmap.yaml b/k8s/helm/catalog-api/templates/configmap.yaml index 75cf686f9..4e67abf8f 100644 --- a/k8s/helm/catalog-api/templates/configmap.yaml +++ b/k8s/helm/catalog-api/templates/configmap.yaml @@ -1,5 +1,6 @@ {{- $name := include "catalog-api.fullname" . -}} {{- $sqlsrv := include "sql-name" . -}} +{{- $webshoppingapigw := include "url-of" (list .Values.app.ingress.entries.webshoppingapigw .) -}} apiVersion: v1 kind: ConfigMap @@ -12,7 +13,7 @@ metadata: heritage: {{ .Release.Service }} data: catalog__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.catalog.db }};User Id={{ .Values.inf.sql.catalog.user }};Password={{ .Values.inf.sql.catalog.pwd }}; - catalog__PicBaseUrl: http://{{ .Values.inf.k8s.dns }}/webshoppingapigw/api/v1/c/catalog/items/[0]/pic/ + 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 }} diff --git a/k8s/helm/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/identity-api/templates/_names.tpl +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/locations-api/templates/_names.tpl b/k8s/helm/locations-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/locations-api/templates/_names.tpl +++ b/k8s/helm/locations-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/marketing-api/templates/_names.tpl b/k8s/helm/marketing-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/marketing-api/templates/_names.tpl +++ b/k8s/helm/marketing-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/marketing-api/templates/configmap.yaml b/k8s/helm/marketing-api/templates/configmap.yaml index 89cbfeb51..ea99a1b5a 100644 --- a/k8s/helm/marketing-api/templates/configmap.yaml +++ b/k8s/helm/marketing-api/templates/configmap.yaml @@ -1,5 +1,6 @@ {{- $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 @@ -19,4 +20,5 @@ data: internalurls__IdentityUrl: http://{{ .Values.app.svc.identity }} urls__IdentityUrl: {{ $identity }} marketing__ConnectionString: mongodb://{{ $mongo }} - marketing__Database: {{ .Values.inf.mongo.marketing.database }} \ No newline at end of file + 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/values.yaml b/k8s/helm/marketing-api/values.yaml index 0258eed8d..8779685d6 100644 --- a/k8s/helm/marketing-api/values.yaml +++ b/k8s/helm/marketing-api/values.yaml @@ -46,6 +46,8 @@ env: 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 diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} diff --git a/k8s/helm/ordering-signalrhub/templates/_names.tpl b/k8s/helm/ordering-signalrhub/templates/_names.tpl index 0f42702d4..7e817f9b7 100644 --- a/k8s/helm/ordering-signalrhub/templates/_names.tpl +++ b/k8s/helm/ordering-signalrhub/templates/_names.tpl @@ -27,12 +27,12 @@ {{- $ctx := last .}} {{- $suffix := include "suffix-name" $ctx -}} {{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} # Value is ./ +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} {{- else -}} {{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} # Value is /- +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} {{- else -}} -{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} # Value is just / +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} {{- end -}} From 69955da33e8b484722d86c097a4b70e16c85e0f6 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 13:18:55 +0200 Subject: [PATCH 15/29] Payment api chart --- k8s/helm/payment-api/.helmignore | 21 ++++++ k8s/helm/payment-api/Chart.yaml | 5 ++ k8s/helm/payment-api/templates/NOTES.txt | 19 +++++ k8s/helm/payment-api/templates/_helpers.tpl | 32 ++++++++ k8s/helm/payment-api/templates/_names.tpl | 49 +++++++++++++ k8s/helm/payment-api/templates/configmap.yaml | 15 ++++ .../payment-api/templates/deployment.yaml | 73 +++++++++++++++++++ k8s/helm/payment-api/templates/ingress.yaml | 34 +++++++++ k8s/helm/payment-api/templates/service.yaml | 19 +++++ k8s/helm/payment-api/values.yaml | 45 ++++++++++++ 10 files changed, 312 insertions(+) create mode 100644 k8s/helm/payment-api/.helmignore create mode 100644 k8s/helm/payment-api/Chart.yaml create mode 100644 k8s/helm/payment-api/templates/NOTES.txt create mode 100644 k8s/helm/payment-api/templates/_helpers.tpl create mode 100644 k8s/helm/payment-api/templates/_names.tpl create mode 100644 k8s/helm/payment-api/templates/configmap.yaml create mode 100644 k8s/helm/payment-api/templates/deployment.yaml create mode 100644 k8s/helm/payment-api/templates/ingress.yaml create mode 100644 k8s/helm/payment-api/templates/service.yaml create mode 100644 k8s/helm/payment-api/values.yaml 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..0642d8004 --- /dev/null +++ b/k8s/helm/payment-api/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "payment-api.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "payment-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "payment-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/payment-api/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..8863535ba --- /dev/null +++ b/k8s/helm/payment-api/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/payment-api/templates/ingress.yaml new file mode 100644 index 000000000..e18ce4084 --- /dev/null +++ b/k8s/helm/payment-api/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "payment-api.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "payment-api.name" . }} + chart: {{ template "payment-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: {{ $fullName }} + servicePort: http +{{- 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..738bffa90 --- /dev/null +++ b/k8s/helm/payment-api/values.yaml @@ -0,0 +1,45 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /payment-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 + # 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' + From 887db619c2c570d2c1911c998af4fda412495561 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 14:11:48 +0200 Subject: [PATCH 16/29] webmvc chart --- k8s/helm/webmvc/.helmignore | 21 +++++++ k8s/helm/webmvc/Chart.yaml | 5 ++ k8s/helm/webmvc/templates/NOTES.txt | 19 ++++++ k8s/helm/webmvc/templates/_helpers.tpl | 32 ++++++++++ k8s/helm/webmvc/templates/_names.tpl | 49 +++++++++++++++ k8s/helm/webmvc/templates/configmap.yaml | 32 ++++++++++ k8s/helm/webmvc/templates/deployment.yaml | 73 +++++++++++++++++++++++ k8s/helm/webmvc/templates/ingress.yaml | 34 +++++++++++ k8s/helm/webmvc/templates/service.yaml | 19 ++++++ k8s/helm/webmvc/values.yaml | 71 ++++++++++++++++++++++ 10 files changed, 355 insertions(+) create mode 100644 k8s/helm/webmvc/.helmignore create mode 100644 k8s/helm/webmvc/Chart.yaml create mode 100644 k8s/helm/webmvc/templates/NOTES.txt create mode 100644 k8s/helm/webmvc/templates/_helpers.tpl create mode 100644 k8s/helm/webmvc/templates/_names.tpl create mode 100644 k8s/helm/webmvc/templates/configmap.yaml create mode 100644 k8s/helm/webmvc/templates/deployment.yaml create mode 100644 k8s/helm/webmvc/templates/ingress.yaml create mode 100644 k8s/helm/webmvc/templates/service.yaml create mode 100644 k8s/helm/webmvc/values.yaml 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..049af195c --- /dev/null +++ b/k8s/helm/webmvc/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webmvc.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "webmvc.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webmvc.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webmvc.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/webmvc/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..03db384b8 --- /dev/null +++ b/k8s/helm/webmvc/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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..313f4ccf8 --- /dev/null +++ b/k8s/helm/webmvc/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "webmvc.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: {{ $fullName }} + 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..2a6086996 --- /dev/null +++ b/k8s/helm/webmvc/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.webvmc }} + 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..3ec89304d --- /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: 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: 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' + From b6ba4a4d849f4c3508c7328ac962d9110c6527e6 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 15:17:33 +0200 Subject: [PATCH 17/29] webstatus chart --- k8s/helm/webstatus/.helmignore | 21 ++++++ k8s/helm/webstatus/Chart.yaml | 5 ++ k8s/helm/webstatus/templates/NOTES.txt | 19 +++++ k8s/helm/webstatus/templates/_helpers.tpl | 32 +++++++++ k8s/helm/webstatus/templates/_names.tpl | 49 +++++++++++++ k8s/helm/webstatus/templates/configmap.yaml | 36 ++++++++++ k8s/helm/webstatus/templates/deployment.yaml | 73 ++++++++++++++++++++ k8s/helm/webstatus/templates/ingress.yaml | 34 +++++++++ k8s/helm/webstatus/templates/service.yaml | 19 +++++ k8s/helm/webstatus/values.yaml | 62 +++++++++++++++++ 10 files changed, 350 insertions(+) create mode 100644 k8s/helm/webstatus/.helmignore create mode 100644 k8s/helm/webstatus/Chart.yaml create mode 100644 k8s/helm/webstatus/templates/NOTES.txt create mode 100644 k8s/helm/webstatus/templates/_helpers.tpl create mode 100644 k8s/helm/webstatus/templates/_names.tpl create mode 100644 k8s/helm/webstatus/templates/configmap.yaml create mode 100644 k8s/helm/webstatus/templates/deployment.yaml create mode 100644 k8s/helm/webstatus/templates/ingress.yaml create mode 100644 k8s/helm/webstatus/templates/service.yaml create mode 100644 k8s/helm/webstatus/values.yaml 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..243d0726f --- /dev/null +++ b/k8s/helm/webstatus/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webstatus.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "webstatus.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webstatus.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webstatus.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/webstatus/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..19eed779b --- /dev/null +++ b/k8s/helm/webstatus/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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..48b38c3dd --- /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: {{ $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: {{ $fullName }} + 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..872b1fc27 --- /dev/null +++ b/k8s/helm/webstatus/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.webvmc }} + 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..28c15b22d --- /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: 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: BasketUrl + key: internalurls__basket__hc + - name: CatalogUrl + key: internalurls__catalog__hc + - name: IdentityUrl + key: internalurls__IdentityUrl + - 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' From dd425e75c57d7acea7c9104a52a2f01b31dd0047 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 15:56:55 +0200 Subject: [PATCH 18/29] webspa chart --- k8s/helm/webspa/.helmignore | 21 +++++++ k8s/helm/webspa/Chart.yaml | 5 ++ k8s/helm/webspa/templates/NOTES.txt | 19 ++++++ k8s/helm/webspa/templates/_helpers.tpl | 32 ++++++++++ k8s/helm/webspa/templates/_names.tpl | 49 +++++++++++++++ k8s/helm/webspa/templates/configmap.yaml | 32 ++++++++++ k8s/helm/webspa/templates/deployment.yaml | 73 +++++++++++++++++++++++ k8s/helm/webspa/templates/ingress.yaml | 34 +++++++++++ k8s/helm/webspa/templates/service.yaml | 19 ++++++ k8s/helm/webspa/values.yaml | 71 ++++++++++++++++++++++ 10 files changed, 355 insertions(+) create mode 100644 k8s/helm/webspa/.helmignore create mode 100644 k8s/helm/webspa/Chart.yaml create mode 100644 k8s/helm/webspa/templates/NOTES.txt create mode 100644 k8s/helm/webspa/templates/_helpers.tpl create mode 100644 k8s/helm/webspa/templates/_names.tpl create mode 100644 k8s/helm/webspa/templates/configmap.yaml create mode 100644 k8s/helm/webspa/templates/deployment.yaml create mode 100644 k8s/helm/webspa/templates/ingress.yaml create mode 100644 k8s/helm/webspa/templates/service.yaml create mode 100644 k8s/helm/webspa/values.yaml 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..1bd7fdbc3 --- /dev/null +++ b/k8s/helm/webspa/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webspa.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "webspa.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webspa.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webspa.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/webspa/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..9b3b88962 --- /dev/null +++ b/k8s/helm/webspa/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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..3a578e79c --- /dev/null +++ b/k8s/helm/webspa/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "webspa.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: {{ $fullName }} + 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..6ef53d347 --- /dev/null +++ b/k8s/helm/webspa/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.webvmc }} + 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..6ca548102 --- /dev/null +++ b/k8s/helm/webspa/values.yaml @@ -0,0 +1,71 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /webspa + +image: + repository: eshop/webspa + 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: 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' + From e016ebcff5ba49d253f1cd66ce8f0966da51df83 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 16:14:43 +0200 Subject: [PATCH 19/29] web shopping aggregator and some fixes --- k8s/helm/webmvc/templates/service.yaml | 2 +- k8s/helm/webshoppingagg/.helmignore | 21 ++++++ k8s/helm/webshoppingagg/Chart.yaml | 5 ++ k8s/helm/webshoppingagg/templates/NOTES.txt | 19 +++++ .../webshoppingagg/templates/_helpers.tpl | 32 ++++++++ k8s/helm/webshoppingagg/templates/_names.tpl | 49 +++++++++++++ .../webshoppingagg/templates/configmap.yaml | 19 +++++ .../webshoppingagg/templates/deployment.yaml | 73 +++++++++++++++++++ .../webshoppingagg/templates/ingress.yaml | 34 +++++++++ .../webshoppingagg/templates/service.yaml | 19 +++++ k8s/helm/webshoppingagg/values.yaml | 53 ++++++++++++++ k8s/helm/webspa/templates/service.yaml | 2 +- k8s/helm/webstatus/templates/service.yaml | 2 +- 13 files changed, 327 insertions(+), 3 deletions(-) create mode 100644 k8s/helm/webshoppingagg/.helmignore create mode 100644 k8s/helm/webshoppingagg/Chart.yaml create mode 100644 k8s/helm/webshoppingagg/templates/NOTES.txt create mode 100644 k8s/helm/webshoppingagg/templates/_helpers.tpl create mode 100644 k8s/helm/webshoppingagg/templates/_names.tpl create mode 100644 k8s/helm/webshoppingagg/templates/configmap.yaml create mode 100644 k8s/helm/webshoppingagg/templates/deployment.yaml create mode 100644 k8s/helm/webshoppingagg/templates/ingress.yaml create mode 100644 k8s/helm/webshoppingagg/templates/service.yaml create mode 100644 k8s/helm/webshoppingagg/values.yaml diff --git a/k8s/helm/webmvc/templates/service.yaml b/k8s/helm/webmvc/templates/service.yaml index 2a6086996..74d87673f 100644 --- a/k8s/helm/webmvc/templates/service.yaml +++ b/k8s/helm/webmvc/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Values.app.svc.webvmc }} + name: {{ .Values.app.svc.mvc }} labels: app: {{ template "webmvc.name" . }} chart: {{ template "webmvc.chart" . }} 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..24c110fec --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webshoppingagg.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "webshoppingagg.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webshoppingagg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..a0f97df5d --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/webshoppingagg/templates/ingress.yaml new file mode 100644 index 000000000..058f24730 --- /dev/null +++ b/k8s/helm/webshoppingagg/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "webshoppingagg.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "webshoppingagg.name" . }} + chart: {{ template "webshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + - {{ .Values.inf.k8s.dns }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + - host: {{ .Values.inf.k8s.dns }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http +{{- end }} 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/templates/service.yaml b/k8s/helm/webspa/templates/service.yaml index 6ef53d347..2eab5d02e 100644 --- a/k8s/helm/webspa/templates/service.yaml +++ b/k8s/helm/webspa/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Values.app.svc.webvmc }} + name: {{ .Values.app.svc.spa }} labels: app: {{ template "webspa.name" . }} chart: {{ template "webspa.chart" . }} diff --git a/k8s/helm/webstatus/templates/service.yaml b/k8s/helm/webstatus/templates/service.yaml index 872b1fc27..37fff50c6 100644 --- a/k8s/helm/webstatus/templates/service.yaml +++ b/k8s/helm/webstatus/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Values.app.svc.webvmc }} + name: {{ .Values.app.svc.status }} labels: app: {{ template "webstatus.name" . }} chart: {{ template "webstatus.chart" . }} From 97f142f01c701d5deb09334c52c7fe64c2f36388 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 16:31:09 +0200 Subject: [PATCH 20/29] Mobile shopping aggregator --- k8s/helm/mobileshoppingagg/.helmignore | 21 ++++++ k8s/helm/mobileshoppingagg/Chart.yaml | 5 ++ .../mobileshoppingagg/templates/NOTES.txt | 19 +++++ .../mobileshoppingagg/templates/_helpers.tpl | 32 ++++++++ .../mobileshoppingagg/templates/_names.tpl | 49 +++++++++++++ .../templates/configmap.yaml | 19 +++++ .../templates/deployment.yaml | 73 +++++++++++++++++++ .../mobileshoppingagg/templates/ingress.yaml | 34 +++++++++ .../mobileshoppingagg/templates/service.yaml | 19 +++++ k8s/helm/mobileshoppingagg/values.yaml | 53 ++++++++++++++ 10 files changed, 324 insertions(+) create mode 100644 k8s/helm/mobileshoppingagg/.helmignore create mode 100644 k8s/helm/mobileshoppingagg/Chart.yaml create mode 100644 k8s/helm/mobileshoppingagg/templates/NOTES.txt create mode 100644 k8s/helm/mobileshoppingagg/templates/_helpers.tpl create mode 100644 k8s/helm/mobileshoppingagg/templates/_names.tpl create mode 100644 k8s/helm/mobileshoppingagg/templates/configmap.yaml create mode 100644 k8s/helm/mobileshoppingagg/templates/deployment.yaml create mode 100644 k8s/helm/mobileshoppingagg/templates/ingress.yaml create mode 100644 k8s/helm/mobileshoppingagg/templates/service.yaml create mode 100644 k8s/helm/mobileshoppingagg/values.yaml 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..db6051447 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "mobileshoppingagg.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "mobileshoppingagg.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mobileshoppingagg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..6317c99e3 --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/deployment.yaml @@ -0,0 +1,73 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .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/ingress.yaml b/k8s/helm/mobileshoppingagg/templates/ingress.yaml new file mode 100644 index 000000000..c116272cd --- /dev/null +++ b/k8s/helm/mobileshoppingagg/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "mobileshoppingagg.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "mobileshoppingagg.name" . }} + chart: {{ template "mobileshoppingagg.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + - {{ .Values.inf.k8s.dns }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + - host: {{ .Values.inf.k8s.dns }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http +{{- end }} 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' + From fce8326dffacef4e1ebe2adb886c0828d67ee080 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 17:10:23 +0200 Subject: [PATCH 21/29] apigwmm chart --- k8s/helm/apigwmm/.helmignore | 21 +++++ k8s/helm/apigwmm/Chart.yaml | 5 ++ .../configuration-mobile-marketing.json | 34 ++++++++ k8s/helm/apigwmm/templates/NOTES.txt | 19 +++++ k8s/helm/apigwmm/templates/_helpers.tpl | 32 +++++++ k8s/helm/apigwmm/templates/_names.tpl | 49 +++++++++++ k8s/helm/apigwmm/templates/configmap.yaml | 14 ++++ k8s/helm/apigwmm/templates/deployment.yaml | 84 +++++++++++++++++++ k8s/helm/apigwmm/templates/ingress.yaml | 34 ++++++++ k8s/helm/apigwmm/templates/ocelot-cm.yaml | 15 ++++ k8s/helm/apigwmm/templates/service.yaml | 19 +++++ k8s/helm/apigwmm/values.yaml | 39 +++++++++ 12 files changed, 365 insertions(+) create mode 100644 k8s/helm/apigwmm/.helmignore create mode 100644 k8s/helm/apigwmm/Chart.yaml create mode 100644 k8s/helm/apigwmm/configuration-mobile-marketing.json create mode 100644 k8s/helm/apigwmm/templates/NOTES.txt create mode 100644 k8s/helm/apigwmm/templates/_helpers.tpl create mode 100644 k8s/helm/apigwmm/templates/_names.tpl create mode 100644 k8s/helm/apigwmm/templates/configmap.yaml create mode 100644 k8s/helm/apigwmm/templates/deployment.yaml create mode 100644 k8s/helm/apigwmm/templates/ingress.yaml create mode 100644 k8s/helm/apigwmm/templates/ocelot-cm.yaml create mode 100644 k8s/helm/apigwmm/templates/service.yaml create mode 100644 k8s/helm/apigwmm/values.yaml 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..7bdf1a6a5 --- /dev/null +++ b/k8s/helm/apigwmm/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwmm.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "apigwmm.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwmm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwmm.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/apigwmm/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..1a239a2b8 --- /dev/null +++ b/k8s/helm/apigwmm/templates/deployment.yaml @@ -0,0 +1,84 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: mm + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" . }} + - name: k8sname + value: {{ .Values.clusterName }} + {{- if .Values.env.values -}} + {{- range .Values.env.values }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end -}} + {{- end -}} + {{- if .Values.env.configmap -}} + {{- range .Values.env.configmap }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ $cfgname }} + key: {{ .key }} + {{- end -}} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + diff --git a/k8s/helm/apigwmm/templates/ingress.yaml b/k8s/helm/apigwmm/templates/ingress.yaml new file mode 100644 index 000000000..ae42e6747 --- /dev/null +++ b/k8s/helm/apigwmm/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "apigwmm.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: {{ $fullName }} + 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..fc908494f --- /dev/null +++ b/k8s/helm/apigwmm/templates/ocelot-cm.yaml @@ -0,0 +1,15 @@ +{{- $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: + mm: |- + {{ (.Files.Glob "configuration-mobile-marketing.json").AsConfig }} + diff --git a/k8s/helm/apigwmm/templates/service.yaml b/k8s/helm/apigwmm/templates/service.yaml new file mode 100644 index 000000000..43c02ebdb --- /dev/null +++ b/k8s/helm/apigwmm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.apigwmm }} + 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..7782a32e2 --- /dev/null +++ b/k8s/helm/apigwmm/values.yaml @@ -0,0 +1,39 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /apigwmm + +image: + repository: eshop/ocelotapigw + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + tls: [] + +resources: {} + + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# env defines the environment variables that will be declared in the pod +env: + urls: + # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). + configmap: + - name: urls__identity + key: internalurls__identity + # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) + values: + - name: ASPNETCORE_ENVIRONMENT + value: Development + From 7be2b53ff7ab8327ad139d00de070f2c15c538d7 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 17:38:29 +0200 Subject: [PATCH 22/29] Mobile Shopping apigw --- k8s/helm/apigwmm/templates/service.yaml | 2 +- k8s/helm/apigwms/.helmignore | 21 +++ k8s/helm/apigwms/Chart.yaml | 5 + .../configuration-mobile-shopping.json | 142 ++++++++++++++++++ k8s/helm/apigwms/templates/NOTES.txt | 19 +++ k8s/helm/apigwms/templates/_helpers.tpl | 32 ++++ k8s/helm/apigwms/templates/_names.tpl | 49 ++++++ k8s/helm/apigwms/templates/configmap.yaml | 14 ++ k8s/helm/apigwms/templates/deployment.yaml | 84 +++++++++++ k8s/helm/apigwms/templates/ingress.yaml | 34 +++++ k8s/helm/apigwms/templates/ocelot-cm.yaml | 15 ++ k8s/helm/apigwms/templates/service.yaml | 19 +++ k8s/helm/apigwms/values.yaml | 39 +++++ 13 files changed, 474 insertions(+), 1 deletion(-) create mode 100644 k8s/helm/apigwms/.helmignore create mode 100644 k8s/helm/apigwms/Chart.yaml create mode 100644 k8s/helm/apigwms/configuration-mobile-shopping.json create mode 100644 k8s/helm/apigwms/templates/NOTES.txt create mode 100644 k8s/helm/apigwms/templates/_helpers.tpl create mode 100644 k8s/helm/apigwms/templates/_names.tpl create mode 100644 k8s/helm/apigwms/templates/configmap.yaml create mode 100644 k8s/helm/apigwms/templates/deployment.yaml create mode 100644 k8s/helm/apigwms/templates/ingress.yaml create mode 100644 k8s/helm/apigwms/templates/ocelot-cm.yaml create mode 100644 k8s/helm/apigwms/templates/service.yaml create mode 100644 k8s/helm/apigwms/values.yaml diff --git a/k8s/helm/apigwmm/templates/service.yaml b/k8s/helm/apigwmm/templates/service.yaml index 43c02ebdb..dac59b23a 100644 --- a/k8s/helm/apigwmm/templates/service.yaml +++ b/k8s/helm/apigwmm/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Values.app.svc.apigwmm }} + name: {{ .Values.app.svc.mobilemarketingapigw }} labels: app: {{ template "apigwmm.name" . }} chart: {{ template "apigwmm.chart" . }} 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..55efc73f4 --- /dev/null +++ b/k8s/helm/apigwms/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwms.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "apigwms.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwms.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwms.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/apigwms/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..e4e23ed48 --- /dev/null +++ b/k8s/helm/apigwms/templates/deployment.yaml @@ -0,0 +1,84 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: ms + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" . }} + - name: k8sname + value: {{ .Values.clusterName }} + {{- if .Values.env.values -}} + {{- range .Values.env.values }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end -}} + {{- end -}} + {{- if .Values.env.configmap -}} + {{- range .Values.env.configmap }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ $cfgname }} + key: {{ .key }} + {{- end -}} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + diff --git a/k8s/helm/apigwms/templates/ingress.yaml b/k8s/helm/apigwms/templates/ingress.yaml new file mode 100644 index 000000000..42cc79816 --- /dev/null +++ b/k8s/helm/apigwms/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "apigwms.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: {{ $fullName }} + 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..9860b90e1 --- /dev/null +++ b/k8s/helm/apigwms/templates/ocelot-cm.yaml @@ -0,0 +1,15 @@ +{{- $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: + ms: |- + {{ (.Files.Glob "configuration-mobile-shopping.json").AsConfig }} + 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..7846a3b91 --- /dev/null +++ b/k8s/helm/apigwms/values.yaml @@ -0,0 +1,39 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /apigwms + +image: + repository: eshop/ocelotapigw + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + tls: [] + +resources: {} + + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# env defines the environment variables that will be declared in the pod +env: + urls: + # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). + configmap: + - name: urls__identity + key: internalurls__identity + # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) + values: + - name: ASPNETCORE_ENVIRONMENT + value: Development + From 92585089ba627fcb0901a8d05de4132a6284f034 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 17:53:22 +0200 Subject: [PATCH 23/29] Web marketing apigw --- k8s/helm/apigwmm/values.yaml | 2 +- k8s/helm/apigwms/values.yaml | 2 +- k8s/helm/apigwwm/.helmignore | 21 +++++ k8s/helm/apigwwm/Chart.yaml | 5 ++ .../apigwwm/configuration-web-marketing.json | 34 ++++++++ k8s/helm/apigwwm/templates/NOTES.txt | 19 +++++ k8s/helm/apigwwm/templates/_helpers.tpl | 32 +++++++ k8s/helm/apigwwm/templates/_names.tpl | 49 +++++++++++ k8s/helm/apigwwm/templates/configmap.yaml | 14 ++++ k8s/helm/apigwwm/templates/deployment.yaml | 84 +++++++++++++++++++ k8s/helm/apigwwm/templates/ingress.yaml | 34 ++++++++ k8s/helm/apigwwm/templates/ocelot-cm.yaml | 15 ++++ k8s/helm/apigwwm/templates/service.yaml | 19 +++++ k8s/helm/apigwwm/values.yaml | 39 +++++++++ 14 files changed, 367 insertions(+), 2 deletions(-) create mode 100644 k8s/helm/apigwwm/.helmignore create mode 100644 k8s/helm/apigwwm/Chart.yaml create mode 100644 k8s/helm/apigwwm/configuration-web-marketing.json create mode 100644 k8s/helm/apigwwm/templates/NOTES.txt create mode 100644 k8s/helm/apigwwm/templates/_helpers.tpl create mode 100644 k8s/helm/apigwwm/templates/_names.tpl create mode 100644 k8s/helm/apigwwm/templates/configmap.yaml create mode 100644 k8s/helm/apigwwm/templates/deployment.yaml create mode 100644 k8s/helm/apigwwm/templates/ingress.yaml create mode 100644 k8s/helm/apigwwm/templates/ocelot-cm.yaml create mode 100644 k8s/helm/apigwwm/templates/service.yaml create mode 100644 k8s/helm/apigwwm/values.yaml diff --git a/k8s/helm/apigwmm/values.yaml b/k8s/helm/apigwmm/values.yaml index 7782a32e2..4a82d6aac 100644 --- a/k8s/helm/apigwmm/values.yaml +++ b/k8s/helm/apigwmm/values.yaml @@ -1,6 +1,6 @@ replicaCount: 1 clusterName: eshop-aks -pathBase: /apigwmm +pathBase: /mobilemarketingapigw image: repository: eshop/ocelotapigw diff --git a/k8s/helm/apigwms/values.yaml b/k8s/helm/apigwms/values.yaml index 7846a3b91..9f9b1d9ba 100644 --- a/k8s/helm/apigwms/values.yaml +++ b/k8s/helm/apigwms/values.yaml @@ -1,6 +1,6 @@ replicaCount: 1 clusterName: eshop-aks -pathBase: /apigwms +pathBase: /mobileshoppingapigw image: repository: eshop/ocelotapigw 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..a5bda5189 --- /dev/null +++ b/k8s/helm/apigwwm/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwwm.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "apigwwm.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwwm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwwm.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/apigwwm/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..32ff86bb7 --- /dev/null +++ b/k8s/helm/apigwwm/templates/deployment.yaml @@ -0,0 +1,84 @@ +{{- $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.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: wm + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" . }} + - name: k8sname + value: {{ .Values.clusterName }} + {{- if .Values.env.values -}} + {{- range .Values.env.values }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end -}} + {{- end -}} + {{- if .Values.env.configmap -}} + {{- range .Values.env.configmap }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ $cfgname }} + key: {{ .key }} + {{- end -}} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + diff --git a/k8s/helm/apigwwm/templates/ingress.yaml b/k8s/helm/apigwwm/templates/ingress.yaml new file mode 100644 index 000000000..50ed779df --- /dev/null +++ b/k8s/helm/apigwwm/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "apigwwm.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $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: {{ $fullName }} + 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..f11ea0d2e --- /dev/null +++ b/k8s/helm/apigwwm/templates/ocelot-cm.yaml @@ -0,0 +1,15 @@ +{{- $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: + wm: |- + {{ (.Files.Glob "configuration-web-marketing.json").AsConfig }} + 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..1d431ed09 --- /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: false + annotations: {} + tls: [] + +resources: {} + + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# env defines the environment variables that will be declared in the pod +env: + urls: + # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). + configmap: + - name: urls__identity + key: internalurls__identity + # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) + values: + - name: ASPNETCORE_ENVIRONMENT + value: Development + From 59729c74ea8aa6a2d8832218ca85c51629926bd0 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 17:56:01 +0200 Subject: [PATCH 24/29] web shopping apigw --- k8s/helm/apigwws/.helmignore | 21 +++ k8s/helm/apigwws/Chart.yaml | 5 + .../apigwws/configuration-web-shopping.json | 154 ++++++++++++++++++ k8s/helm/apigwws/templates/NOTES.txt | 19 +++ k8s/helm/apigwws/templates/_helpers.tpl | 32 ++++ k8s/helm/apigwws/templates/_names.tpl | 49 ++++++ k8s/helm/apigwws/templates/configmap.yaml | 14 ++ k8s/helm/apigwws/templates/deployment.yaml | 84 ++++++++++ k8s/helm/apigwws/templates/ingress.yaml | 34 ++++ k8s/helm/apigwws/templates/ocelot-cm.yaml | 15 ++ k8s/helm/apigwws/templates/service.yaml | 19 +++ k8s/helm/apigwws/values.yaml | 39 +++++ 12 files changed, 485 insertions(+) create mode 100644 k8s/helm/apigwws/.helmignore create mode 100644 k8s/helm/apigwws/Chart.yaml create mode 100644 k8s/helm/apigwws/configuration-web-shopping.json create mode 100644 k8s/helm/apigwws/templates/NOTES.txt create mode 100644 k8s/helm/apigwws/templates/_helpers.tpl create mode 100644 k8s/helm/apigwws/templates/_names.tpl create mode 100644 k8s/helm/apigwws/templates/configmap.yaml create mode 100644 k8s/helm/apigwws/templates/deployment.yaml create mode 100644 k8s/helm/apigwws/templates/ingress.yaml create mode 100644 k8s/helm/apigwws/templates/ocelot-cm.yaml create mode 100644 k8s/helm/apigwws/templates/service.yaml create mode 100644 k8s/helm/apigwws/values.yaml 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..6f6248f57 --- /dev/null +++ b/k8s/helm/apigwws/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwws.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "apigwws.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwws.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwws.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} 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..7e817f9b7 --- /dev/null +++ b/k8s/helm/apigwws/templates/_names.tpl @@ -0,0 +1,49 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- if $ctx.Values.inf.k8s.dnsprefix -}} +{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} +{{- else -}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} +{{- end -}} + + + +{{ define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} \ 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..b3a5f1e92 --- /dev/null +++ b/k8s/helm/apigwws/templates/deployment.yaml @@ -0,0 +1,84 @@ +{{- $name := include "apigwws.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +{{- $ocelotcfgname := printf "%s-%s" "ocelot" $name -}} +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "apigwws.fullname" . }} + labels: + ufo: {{ $cfgname}} + app: {{ template "apigwws.name" . }} + chart: {{ template "apigwws.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "apigwws.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "apigwws.name" . }} + release: {{ .Release.Name }} + spec: + {{ if .Values.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + volumes: + - name: config + configMap: + name: {{ $ocelotcfgname }} + items: + - key: ws + path: configuration.json + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: /app/configuration + env: + - name: PATH_BASE + value: {{ include "pathBase" . }} + - name: k8sname + value: {{ .Values.clusterName }} + {{- if .Values.env.values -}} + {{- range .Values.env.values }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end -}} + {{- end -}} + {{- if .Values.env.configmap -}} + {{- range .Values.env.configmap }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ $cfgname }} + key: {{ .key }} + {{- end -}} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + diff --git a/k8s/helm/apigwws/templates/ingress.yaml b/k8s/helm/apigwws/templates/ingress.yaml new file mode 100644 index 000000000..b8956ce77 --- /dev/null +++ b/k8s/helm/apigwws/templates/ingress.yaml @@ -0,0 +1,34 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "apigwws.fullname" . -}} +{{- $ingressPath := include "pathBase" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "apigwws.name" . }} + chart: {{ template "apigwws.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + - {{ .Values.inf.k8s.dns }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + - host: {{ .Values.inf.k8s.dns }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http +{{- end }} diff --git a/k8s/helm/apigwws/templates/ocelot-cm.yaml b/k8s/helm/apigwws/templates/ocelot-cm.yaml new file mode 100644 index 000000000..59c6e3e67 --- /dev/null +++ b/k8s/helm/apigwws/templates/ocelot-cm.yaml @@ -0,0 +1,15 @@ +{{- $name := include "apigwws.fullname" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "ocelot-{{ $name }}" + labels: + app: {{ template "apigwws.name" . }} + chart: {{ template "apigwws.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + ws: |- + {{ (.Files.Glob "configuration-web-shopping.json").AsConfig }} + 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..128e263de --- /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: false + annotations: {} + tls: [] + +resources: {} + + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# env defines the environment variables that will be declared in the pod +env: + urls: + # configmap declares variables which value is taken from the config map defined in template configmap.yaml (name is name of var and key the key in configmap). + configmap: + - name: urls__identity + key: internalurls__identity + # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) + values: + - name: ASPNETCORE_ENVIRONMENT + value: Development + From e3807fa2a5ac136142fe39d7863473b8957eb69b Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Jun 2018 18:06:12 +0200 Subject: [PATCH 25/29] Fixed pathBase generation for apigwws Need to apply this change on the others --- k8s/helm/apigwws/templates/_names.tpl | 10 ++++++---- k8s/helm/apigwws/templates/deployment.yaml | 2 +- k8s/helm/apigwws/templates/ingress.yaml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/k8s/helm/apigwws/templates/_names.tpl b/k8s/helm/apigwws/templates/_names.tpl index 7e817f9b7..c1111b058 100644 --- a/k8s/helm/apigwws/templates/_names.tpl +++ b/k8s/helm/apigwws/templates/_names.tpl @@ -40,10 +40,12 @@ {{ define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} {{- else -}} -{{- .Values.pathBase -}} +{{- printf "/%s" $name -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwws/templates/deployment.yaml b/k8s/helm/apigwws/templates/deployment.yaml index b3a5f1e92..8fad50098 100644 --- a/k8s/helm/apigwws/templates/deployment.yaml +++ b/k8s/helm/apigwws/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: mountPath: /app/configuration env: - name: PATH_BASE - value: {{ include "pathBase" . }} + value: {{ include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) }} - name: k8sname value: {{ .Values.clusterName }} {{- if .Values.env.values -}} diff --git a/k8s/helm/apigwws/templates/ingress.yaml b/k8s/helm/apigwws/templates/ingress.yaml index b8956ce77..bb19d2b19 100644 --- a/k8s/helm/apigwws/templates/ingress.yaml +++ b/k8s/helm/apigwws/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "apigwws.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: From c29aa65607fb75388f25712e541774adc376ed31 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 3 Jul 2018 09:28:54 +0200 Subject: [PATCH 26/29] fixed ingressPath for other apigws --- k8s/helm/apigwmm/templates/_names.tpl | 10 ++++++---- k8s/helm/apigwmm/templates/deployment.yaml | 2 +- k8s/helm/apigwmm/templates/ingress.yaml | 2 +- k8s/helm/apigwms/templates/_names.tpl | 10 ++++++---- k8s/helm/apigwms/templates/deployment.yaml | 2 +- k8s/helm/apigwms/templates/ingress.yaml | 2 +- k8s/helm/apigwwm/templates/_names.tpl | 10 ++++++---- k8s/helm/apigwwm/templates/deployment.yaml | 2 +- k8s/helm/apigwwm/templates/ingress.yaml | 2 +- 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/k8s/helm/apigwmm/templates/_names.tpl b/k8s/helm/apigwmm/templates/_names.tpl index 7e817f9b7..c1111b058 100644 --- a/k8s/helm/apigwmm/templates/_names.tpl +++ b/k8s/helm/apigwmm/templates/_names.tpl @@ -40,10 +40,12 @@ {{ define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} {{- else -}} -{{- .Values.pathBase -}} +{{- printf "/%s" $name -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwmm/templates/deployment.yaml b/k8s/helm/apigwmm/templates/deployment.yaml index 1a239a2b8..7c2c05329 100644 --- a/k8s/helm/apigwmm/templates/deployment.yaml +++ b/k8s/helm/apigwmm/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: mountPath: /app/configuration env: - name: PATH_BASE - value: {{ include "pathBase" . }} + value: {{ include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) }} - name: k8sname value: {{ .Values.clusterName }} {{- if .Values.env.values -}} diff --git a/k8s/helm/apigwmm/templates/ingress.yaml b/k8s/helm/apigwmm/templates/ingress.yaml index ae42e6747..f7b47d602 100644 --- a/k8s/helm/apigwmm/templates/ingress.yaml +++ b/k8s/helm/apigwmm/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "apigwmm.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: diff --git a/k8s/helm/apigwms/templates/_names.tpl b/k8s/helm/apigwms/templates/_names.tpl index 7e817f9b7..c1111b058 100644 --- a/k8s/helm/apigwms/templates/_names.tpl +++ b/k8s/helm/apigwms/templates/_names.tpl @@ -40,10 +40,12 @@ {{ define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} {{- else -}} -{{- .Values.pathBase -}} +{{- printf "/%s" $name -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwms/templates/deployment.yaml b/k8s/helm/apigwms/templates/deployment.yaml index e4e23ed48..3cb4b5638 100644 --- a/k8s/helm/apigwms/templates/deployment.yaml +++ b/k8s/helm/apigwms/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: mountPath: /app/configuration env: - name: PATH_BASE - value: {{ include "pathBase" . }} + value: {{ include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) }} - name: k8sname value: {{ .Values.clusterName }} {{- if .Values.env.values -}} diff --git a/k8s/helm/apigwms/templates/ingress.yaml b/k8s/helm/apigwms/templates/ingress.yaml index 42cc79816..b234b81eb 100644 --- a/k8s/helm/apigwms/templates/ingress.yaml +++ b/k8s/helm/apigwms/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "apigwms.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: diff --git a/k8s/helm/apigwwm/templates/_names.tpl b/k8s/helm/apigwwm/templates/_names.tpl index 7e817f9b7..c1111b058 100644 --- a/k8s/helm/apigwwm/templates/_names.tpl +++ b/k8s/helm/apigwwm/templates/_names.tpl @@ -40,10 +40,12 @@ {{ define "pathBase" -}} -{{- if .Values.inf.k8s.suffix -}} -{{- $suffix := include "suffix-name" . -}} -{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if $ctx.Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" $ctx -}} +{{- printf "/%s-%s" $name $suffix -}} {{- else -}} -{{- .Values.pathBase -}} +{{- printf "/%s" $name -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/k8s/helm/apigwwm/templates/deployment.yaml b/k8s/helm/apigwwm/templates/deployment.yaml index 32ff86bb7..e5c16a0e7 100644 --- a/k8s/helm/apigwwm/templates/deployment.yaml +++ b/k8s/helm/apigwwm/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: mountPath: /app/configuration env: - name: PATH_BASE - value: {{ include "pathBase" . }} + value: {{ include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) }} - name: k8sname value: {{ .Values.clusterName }} {{- if .Values.env.values -}} diff --git a/k8s/helm/apigwwm/templates/ingress.yaml b/k8s/helm/apigwwm/templates/ingress.yaml index 50ed779df..eafc21719 100644 --- a/k8s/helm/apigwwm/templates/ingress.yaml +++ b/k8s/helm/apigwwm/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "apigwwm.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} +{{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: From 91fdc3bd8a37ba6ddd3fec65c1456d7fc79b1888 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 3 Jul 2018 19:07:37 +0200 Subject: [PATCH 27/29] helm charts mostly finished --- k8s/helm/apigwmm/templates/NOTES.txt | 21 +----- k8s/helm/apigwmm/templates/deployment.yaml | 8 +-- k8s/helm/apigwmm/templates/ingress.yaml | 5 +- k8s/helm/apigwmm/templates/ocelot-cm.yaml | 3 +- k8s/helm/apigwmm/values.yaml | 2 +- k8s/helm/apigwms/templates/NOTES.txt | 21 +----- k8s/helm/apigwms/templates/deployment.yaml | 8 +-- k8s/helm/apigwms/templates/ingress.yaml | 5 +- k8s/helm/apigwms/templates/ocelot-cm.yaml | 3 +- k8s/helm/apigwms/values.yaml | 2 +- k8s/helm/apigwwm/templates/NOTES.txt | 21 +----- k8s/helm/apigwwm/templates/deployment.yaml | 8 +-- k8s/helm/apigwwm/templates/ingress.yaml | 5 +- k8s/helm/apigwwm/templates/ocelot-cm.yaml | 3 +- k8s/helm/apigwwm/values.yaml | 2 +- k8s/helm/apigwws/templates/NOTES.txt | 21 +----- k8s/helm/apigwws/templates/deployment.yaml | 8 +-- k8s/helm/apigwws/templates/ingress.yaml | 5 +- k8s/helm/apigwws/templates/ocelot-cm.yaml | 3 +- k8s/helm/apigwws/values.yaml | 2 +- k8s/helm/app.yaml | 2 +- k8s/helm/basket-api/templates/NOTES.txt | 27 +++----- k8s/helm/basket-api/templates/ingress.yaml | 34 ---------- k8s/helm/basket-api/values.yaml | 7 -- k8s/helm/basket-data/.helmignore | 21 ++++++ k8s/helm/basket-data/Chart.yaml | 5 ++ k8s/helm/basket-data/templates/NOTES.txt | 8 +++ k8s/helm/basket-data/templates/_helpers.tpl | 32 +++++++++ .../basket-data/templates/deployment.yaml | 43 ++++++++++++ k8s/helm/basket-data/templates/service.yaml | 19 ++++++ k8s/helm/basket-data/values.yaml | 19 ++++++ k8s/helm/catalog-api/templates/NOTES.txt | 28 +++----- k8s/helm/catalog-api/templates/configmap.yaml | 2 +- k8s/helm/catalog-api/templates/ingress.yaml | 34 ---------- k8s/helm/catalog-api/values.yaml | 6 -- k8s/helm/deploy-all.ps1 | 66 +++++++++++++++++++ k8s/helm/eshop-common/.helmignore | 21 ++++++ k8s/helm/eshop-common/Chart.yaml | 5 ++ k8s/helm/eshop-common/templates/NOTES.txt | 7 ++ k8s/helm/eshop-common/templates/_helpers.tpl | 32 +++++++++ k8s/helm/eshop-common/templates/_names.tpl | 3 + k8s/helm/eshop-common/templates/secret.yaml | 9 +++ k8s/helm/eshop-common/values.yaml | 0 k8s/helm/identity-api/templates/NOTES.txt | 23 ++----- .../identity-api/templates/configmap.yaml | 2 +- k8s/helm/identity-api/templates/ingress.yaml | 5 +- k8s/helm/identity-api/values.yaml | 4 +- k8s/helm/inf.yaml | 25 ++++--- k8s/helm/ingress_values.yaml | 5 ++ k8s/helm/keystore-data/.helmignore | 21 ++++++ k8s/helm/keystore-data/Chart.yaml | 5 ++ k8s/helm/keystore-data/templates/NOTES.txt | 8 +++ k8s/helm/keystore-data/templates/_helpers.tpl | 32 +++++++++ .../keystore-data/templates/deployment.yaml | 43 ++++++++++++ k8s/helm/keystore-data/templates/service.yaml | 19 ++++++ k8s/helm/keystore-data/values.yaml | 19 ++++++ k8s/helm/locations-api/templates/NOTES.txt | 28 +++----- k8s/helm/locations-api/templates/ingress.yaml | 34 ---------- k8s/helm/marketing-api/templates/NOTES.txt | 28 +++----- k8s/helm/marketing-api/templates/ingress.yaml | 34 ---------- .../mobileshoppingagg/templates/NOTES.txt | 27 +++----- .../mobileshoppingagg/templates/ingress.yaml | 34 ---------- k8s/helm/nosql-data/.helmignore | 21 ++++++ k8s/helm/nosql-data/Chart.yaml | 5 ++ k8s/helm/nosql-data/templates/NOTES.txt | 8 +++ k8s/helm/nosql-data/templates/_helpers.tpl | 32 +++++++++ k8s/helm/nosql-data/templates/_names.tpl | 8 +++ k8s/helm/nosql-data/templates/deployment.yaml | 43 ++++++++++++ k8s/helm/nosql-data/templates/service.yaml | 19 ++++++ k8s/helm/nosql-data/values.yaml | 19 ++++++ k8s/helm/ordering-api/templates/NOTES.txt | 27 +++----- .../ordering-api/templates/configmap.yaml | 2 +- k8s/helm/ordering-api/templates/ingress.yaml | 34 ---------- .../templates/NOTES.txt | 22 +------ .../templates/configmap.yaml | 2 +- .../templates/ingress.yaml | 34 ---------- k8s/helm/ordering-backgroundtasks/values.yaml | 2 - .../ordering-signalrhub/templates/NOTES.txt | 27 +++----- .../templates/ingress.yaml | 34 ---------- k8s/helm/ordering-signalrhub/values.yaml | 2 +- k8s/helm/payment-api/templates/NOTES.txt | 28 +++----- k8s/helm/payment-api/templates/ingress.yaml | 34 ---------- k8s/helm/payment-api/values.yaml | 2 +- k8s/helm/rabbitmq/.helmignore | 21 ++++++ k8s/helm/rabbitmq/Chart.yaml | 5 ++ k8s/helm/rabbitmq/templates/NOTES.txt | 8 +++ k8s/helm/rabbitmq/templates/_helpers.tpl | 32 +++++++++ k8s/helm/rabbitmq/templates/_names.tpl | 8 +++ k8s/helm/rabbitmq/templates/deployment.yaml | 43 ++++++++++++ k8s/helm/rabbitmq/templates/service.yaml | 19 ++++++ k8s/helm/rabbitmq/values.yaml | 19 ++++++ k8s/helm/sql-data/.helmignore | 21 ++++++ k8s/helm/sql-data/Chart.yaml | 5 ++ k8s/helm/sql-data/templates/NOTES.txt | 8 +++ k8s/helm/sql-data/templates/_helpers.tpl | 32 +++++++++ k8s/helm/sql-data/templates/_names.tpl | 8 +++ k8s/helm/sql-data/templates/deployment.yaml | 50 ++++++++++++++ k8s/helm/sql-data/templates/service.yaml | 19 ++++++ k8s/helm/sql-data/values.yaml | 19 ++++++ k8s/helm/webmvc/templates/NOTES.txt | 21 +----- k8s/helm/webmvc/templates/ingress.yaml | 5 +- k8s/helm/webmvc/values.yaml | 2 +- k8s/helm/webshoppingagg/templates/NOTES.txt | 27 +++----- .../webshoppingagg/templates/ingress.yaml | 34 ---------- k8s/helm/webspa/templates/NOTES.txt | 21 +----- k8s/helm/webspa/templates/ingress.yaml | 5 +- k8s/helm/webspa/values.yaml | 2 +- k8s/helm/webstatus/templates/NOTES.txt | 21 +----- k8s/helm/webstatus/templates/ingress.yaml | 4 +- k8s/helm/webstatus/values.yaml | 4 +- 110 files changed, 1080 insertions(+), 770 deletions(-) delete mode 100644 k8s/helm/basket-api/templates/ingress.yaml create mode 100644 k8s/helm/basket-data/.helmignore create mode 100644 k8s/helm/basket-data/Chart.yaml create mode 100644 k8s/helm/basket-data/templates/NOTES.txt create mode 100644 k8s/helm/basket-data/templates/_helpers.tpl create mode 100644 k8s/helm/basket-data/templates/deployment.yaml create mode 100644 k8s/helm/basket-data/templates/service.yaml create mode 100644 k8s/helm/basket-data/values.yaml delete mode 100644 k8s/helm/catalog-api/templates/ingress.yaml create mode 100644 k8s/helm/deploy-all.ps1 create mode 100644 k8s/helm/eshop-common/.helmignore create mode 100644 k8s/helm/eshop-common/Chart.yaml create mode 100644 k8s/helm/eshop-common/templates/NOTES.txt create mode 100644 k8s/helm/eshop-common/templates/_helpers.tpl create mode 100644 k8s/helm/eshop-common/templates/_names.tpl create mode 100644 k8s/helm/eshop-common/templates/secret.yaml create mode 100644 k8s/helm/eshop-common/values.yaml create mode 100644 k8s/helm/ingress_values.yaml create mode 100644 k8s/helm/keystore-data/.helmignore create mode 100644 k8s/helm/keystore-data/Chart.yaml create mode 100644 k8s/helm/keystore-data/templates/NOTES.txt create mode 100644 k8s/helm/keystore-data/templates/_helpers.tpl create mode 100644 k8s/helm/keystore-data/templates/deployment.yaml create mode 100644 k8s/helm/keystore-data/templates/service.yaml create mode 100644 k8s/helm/keystore-data/values.yaml delete mode 100644 k8s/helm/locations-api/templates/ingress.yaml delete mode 100644 k8s/helm/marketing-api/templates/ingress.yaml delete mode 100644 k8s/helm/mobileshoppingagg/templates/ingress.yaml create mode 100644 k8s/helm/nosql-data/.helmignore create mode 100644 k8s/helm/nosql-data/Chart.yaml create mode 100644 k8s/helm/nosql-data/templates/NOTES.txt create mode 100644 k8s/helm/nosql-data/templates/_helpers.tpl create mode 100644 k8s/helm/nosql-data/templates/_names.tpl create mode 100644 k8s/helm/nosql-data/templates/deployment.yaml create mode 100644 k8s/helm/nosql-data/templates/service.yaml create mode 100644 k8s/helm/nosql-data/values.yaml delete mode 100644 k8s/helm/ordering-api/templates/ingress.yaml delete mode 100644 k8s/helm/ordering-backgroundtasks/templates/ingress.yaml delete mode 100644 k8s/helm/ordering-signalrhub/templates/ingress.yaml delete mode 100644 k8s/helm/payment-api/templates/ingress.yaml create mode 100644 k8s/helm/rabbitmq/.helmignore create mode 100644 k8s/helm/rabbitmq/Chart.yaml create mode 100644 k8s/helm/rabbitmq/templates/NOTES.txt create mode 100644 k8s/helm/rabbitmq/templates/_helpers.tpl create mode 100644 k8s/helm/rabbitmq/templates/_names.tpl create mode 100644 k8s/helm/rabbitmq/templates/deployment.yaml create mode 100644 k8s/helm/rabbitmq/templates/service.yaml create mode 100644 k8s/helm/rabbitmq/values.yaml create mode 100644 k8s/helm/sql-data/.helmignore create mode 100644 k8s/helm/sql-data/Chart.yaml create mode 100644 k8s/helm/sql-data/templates/NOTES.txt create mode 100644 k8s/helm/sql-data/templates/_helpers.tpl create mode 100644 k8s/helm/sql-data/templates/_names.tpl create mode 100644 k8s/helm/sql-data/templates/deployment.yaml create mode 100644 k8s/helm/sql-data/templates/service.yaml create mode 100644 k8s/helm/sql-data/values.yaml delete mode 100644 k8s/helm/webshoppingagg/templates/ingress.yaml diff --git a/k8s/helm/apigwmm/templates/NOTES.txt b/k8s/helm/apigwmm/templates/NOTES.txt index 7bdf1a6a5..30ef33447 100644 --- a/k8s/helm/apigwmm/templates/NOTES.txt +++ b/k8s/helm/apigwmm/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwmm.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "apigwmm.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwmm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwmm.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop API Gateway for Mobile Marketing services installed +---------------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwmm/templates/deployment.yaml b/k8s/helm/apigwmm/templates/deployment.yaml index 7c2c05329..120cb5889 100644 --- a/k8s/helm/apigwmm/templates/deployment.yaml +++ b/k8s/helm/apigwmm/templates/deployment.yaml @@ -34,15 +34,15 @@ spec: configMap: name: {{ $ocelotcfgname }} items: - - key: mm + - key: configuration-mobile-marketing.json path: configuration.json containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - volumeMounts: - - name: config - mountPath: /app/configuration + volumeMounts: + - name: config + mountPath: /app/configuration env: - name: PATH_BASE value: {{ include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) }} diff --git a/k8s/helm/apigwmm/templates/ingress.yaml b/k8s/helm/apigwmm/templates/ingress.yaml index f7b47d602..28e2aa84d 100644 --- a/k8s/helm/apigwmm/templates/ingress.yaml +++ b/k8s/helm/apigwmm/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "apigwmm.fullname" . -}} {{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobilemarketingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "apigwmm.fullname" . }} labels: app: {{ template "apigwmm.name" . }} chart: {{ template "apigwmm.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + 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 index fc908494f..c7c20ce06 100644 --- a/k8s/helm/apigwmm/templates/ocelot-cm.yaml +++ b/k8s/helm/apigwmm/templates/ocelot-cm.yaml @@ -10,6 +10,5 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - mm: |- - {{ (.Files.Glob "configuration-mobile-marketing.json").AsConfig }} + {{ (.Files.Glob "configuration-mobile-marketing.json").AsConfig | indent 2 }} diff --git a/k8s/helm/apigwmm/values.yaml b/k8s/helm/apigwmm/values.yaml index 4a82d6aac..eeb379c38 100644 --- a/k8s/helm/apigwmm/values.yaml +++ b/k8s/helm/apigwmm/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/apigwms/templates/NOTES.txt b/k8s/helm/apigwms/templates/NOTES.txt index 55efc73f4..74b3eedda 100644 --- a/k8s/helm/apigwms/templates/NOTES.txt +++ b/k8s/helm/apigwms/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwms.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "apigwms.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwms.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwms.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop API Gateway for Mobile Shopping services installed +-------------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwms/templates/deployment.yaml b/k8s/helm/apigwms/templates/deployment.yaml index 3cb4b5638..24519d777 100644 --- a/k8s/helm/apigwms/templates/deployment.yaml +++ b/k8s/helm/apigwms/templates/deployment.yaml @@ -34,15 +34,15 @@ spec: configMap: name: {{ $ocelotcfgname }} items: - - key: ms + - key: configuration-mobile-shopping.json path: configuration.json containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - volumeMounts: - - name: config - mountPath: /app/configuration + volumeMounts: + - name: config + mountPath: /app/configuration env: - name: PATH_BASE value: {{ include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) }} diff --git a/k8s/helm/apigwms/templates/ingress.yaml b/k8s/helm/apigwms/templates/ingress.yaml index b234b81eb..7dd50d8dd 100644 --- a/k8s/helm/apigwms/templates/ingress.yaml +++ b/k8s/helm/apigwms/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "apigwms.fullname" . -}} {{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.mobileshoppingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "apigwms.fullname" . }} labels: app: {{ template "apigwms.name" . }} chart: {{ template "apigwms.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + 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 index 9860b90e1..5f92ca409 100644 --- a/k8s/helm/apigwms/templates/ocelot-cm.yaml +++ b/k8s/helm/apigwms/templates/ocelot-cm.yaml @@ -10,6 +10,5 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - ms: |- - {{ (.Files.Glob "configuration-mobile-shopping.json").AsConfig }} + {{ (.Files.Glob "configuration-mobile-shopping.json").AsConfig | indent 2 }} diff --git a/k8s/helm/apigwms/values.yaml b/k8s/helm/apigwms/values.yaml index 9f9b1d9ba..2659cb8cb 100644 --- a/k8s/helm/apigwms/values.yaml +++ b/k8s/helm/apigwms/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/apigwwm/templates/NOTES.txt b/k8s/helm/apigwwm/templates/NOTES.txt index a5bda5189..3420c97c8 100644 --- a/k8s/helm/apigwwm/templates/NOTES.txt +++ b/k8s/helm/apigwwm/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwwm.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "apigwwm.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwwm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwwm.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop API Gateway for Web Marketing services installed +------------------------------------------------------ \ No newline at end of file diff --git a/k8s/helm/apigwwm/templates/deployment.yaml b/k8s/helm/apigwwm/templates/deployment.yaml index e5c16a0e7..ed28de243 100644 --- a/k8s/helm/apigwwm/templates/deployment.yaml +++ b/k8s/helm/apigwwm/templates/deployment.yaml @@ -34,15 +34,15 @@ spec: configMap: name: {{ $ocelotcfgname }} items: - - key: wm + - key: configuration-web-marketing.json path: configuration.json containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - volumeMounts: - - name: config - mountPath: /app/configuration + volumeMounts: + - name: config + mountPath: /app/configuration env: - name: PATH_BASE value: {{ include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) }} diff --git a/k8s/helm/apigwwm/templates/ingress.yaml b/k8s/helm/apigwwm/templates/ingress.yaml index eafc21719..0a79c4660 100644 --- a/k8s/helm/apigwwm/templates/ingress.yaml +++ b/k8s/helm/apigwwm/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "apigwwm.fullname" . -}} {{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webmarketingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "apigwwm.fullname" . }} labels: app: {{ template "apigwwm.name" . }} chart: {{ template "apigwwm.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + 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 index f11ea0d2e..3de28b1a1 100644 --- a/k8s/helm/apigwwm/templates/ocelot-cm.yaml +++ b/k8s/helm/apigwwm/templates/ocelot-cm.yaml @@ -10,6 +10,5 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - wm: |- - {{ (.Files.Glob "configuration-web-marketing.json").AsConfig }} + {{ (.Files.Glob "configuration-web-marketing.json").AsConfig | indent 2 -}} diff --git a/k8s/helm/apigwwm/values.yaml b/k8s/helm/apigwwm/values.yaml index 1d431ed09..989a5c8c6 100644 --- a/k8s/helm/apigwwm/values.yaml +++ b/k8s/helm/apigwwm/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/apigwws/templates/NOTES.txt b/k8s/helm/apigwws/templates/NOTES.txt index 6f6248f57..8214afb1e 100644 --- a/k8s/helm/apigwws/templates/NOTES.txt +++ b/k8s/helm/apigwws/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "apigwws.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "apigwws.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "apigwws.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "apigwws.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop API Gateway for Web Shopping services installed +----------------------------------------------------- \ No newline at end of file diff --git a/k8s/helm/apigwws/templates/deployment.yaml b/k8s/helm/apigwws/templates/deployment.yaml index 8fad50098..da7b69a5b 100644 --- a/k8s/helm/apigwws/templates/deployment.yaml +++ b/k8s/helm/apigwws/templates/deployment.yaml @@ -34,15 +34,15 @@ spec: configMap: name: {{ $ocelotcfgname }} items: - - key: ws + - key: configuration-web-shopping.json path: configuration.json containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - volumeMounts: - - name: config - mountPath: /app/configuration + volumeMounts: + - name: config + mountPath: /app/configuration env: - name: PATH_BASE value: {{ include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) }} diff --git a/k8s/helm/apigwws/templates/ingress.yaml b/k8s/helm/apigwws/templates/ingress.yaml index bb19d2b19..ee1f681ad 100644 --- a/k8s/helm/apigwws/templates/ingress.yaml +++ b/k8s/helm/apigwws/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "apigwws.fullname" . -}} {{- $ingressPath := include "pathBase" (list .Values.app.ingress.entries.webshoppingapigw .) -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "apigwws.fullname" . }} labels: app: {{ template "apigwws.name" . }} chart: {{ template "apigwws.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + 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 index 59c6e3e67..39b27f29a 100644 --- a/k8s/helm/apigwws/templates/ocelot-cm.yaml +++ b/k8s/helm/apigwws/templates/ocelot-cm.yaml @@ -10,6 +10,5 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - ws: |- - {{ (.Files.Glob "configuration-web-shopping.json").AsConfig }} + {{ (.Files.Glob "configuration-web-shopping.json").AsConfig | indent 2 }} diff --git a/k8s/helm/apigwws/values.yaml b/k8s/helm/apigwws/values.yaml index 128e263de..f2f839a05 100644 --- a/k8s/helm/apigwws/values.yaml +++ b/k8s/helm/apigwws/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index b92f73ac8..826c41632 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -40,4 +40,4 @@ app: # app global settings 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 api + marketing: marketing # service name for marketing ap diff --git a/k8s/helm/basket-api/templates/NOTES.txt b/k8s/helm/basket-api/templates/NOTES.txt index ea08df066..8ba2c89ee 100644 --- a/k8s/helm/basket-api/templates/NOTES.txt +++ b/k8s/helm/basket-api/templates/NOTES.txt @@ -1,19 +1,8 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "basket-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "basket-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "basket-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/basket-api/templates/ingress.yaml deleted file mode 100644 index f34e71680..000000000 --- a/k8s/helm/basket-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "basket-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "basket-api.name" . }} - chart: {{ template "basket-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/basket-api/values.yaml b/k8s/helm/basket-api/values.yaml index 95ba3a9d9..892fdf584 100644 --- a/k8s/helm/basket-api/values.yaml +++ b/k8s/helm/basket-api/values.yaml @@ -11,13 +11,6 @@ service: type: ClusterIP port: 80 -ingress: - enabled: false - annotations: {} - hosts: - - chart-example.local - tls: [] - resources: {} 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/templates/NOTES.txt b/k8s/helm/catalog-api/templates/NOTES.txt index a44a24644..1f01a2b92 100644 --- a/k8s/helm/catalog-api/templates/NOTES.txt +++ b/k8s/helm/catalog-api/templates/NOTES.txt @@ -1,19 +1,9 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "catalog-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "catalog-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "catalog-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/configmap.yaml b/k8s/helm/catalog-api/templates/configmap.yaml index 4e67abf8f..95d8f2f9b 100644 --- a/k8s/helm/catalog-api/templates/configmap.yaml +++ b/k8s/helm/catalog-api/templates/configmap.yaml @@ -12,7 +12,7 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - catalog__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.catalog.db }};User Id={{ .Values.inf.sql.catalog.user }};Password={{ .Values.inf.sql.catalog.pwd }}; + 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 }} diff --git a/k8s/helm/catalog-api/templates/ingress.yaml b/k8s/helm/catalog-api/templates/ingress.yaml deleted file mode 100644 index 3efabacac..000000000 --- a/k8s/helm/catalog-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "catalog-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "catalog-api.name" . }} - chart: {{ template "catalog-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/catalog-api/values.yaml b/k8s/helm/catalog-api/values.yaml index 28d5c6521..e0306a824 100644 --- a/k8s/helm/catalog-api/values.yaml +++ b/k8s/helm/catalog-api/values.yaml @@ -11,12 +11,6 @@ service: type: ClusterIP port: 80 -ingress: - enabled: false - annotations: {} - hosts: - - chart-example.local - tls: [] resources: {} diff --git a/k8s/helm/deploy-all.ps1 b/k8s/helm/deploy-all.ps1 new file mode 100644 index 000000000..a77d5d030 --- /dev/null +++ b/k8s/helm/deploy-all.ps1 @@ -0,0 +1,66 @@ +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 +} + +$useDockerHub = [string]::IsNullOrEmpty($registry) + +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", "-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 appName=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra + } +} + +foreach ($chart in $charts) { + Write-Host "Installing: $chart" -ForegroundColor Green + helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set appName=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --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/templates/NOTES.txt b/k8s/helm/identity-api/templates/NOTES.txt index a232b3af6..48fbbe9b4 100644 --- a/k8s/helm/identity-api/templates/NOTES.txt +++ b/k8s/helm/identity-api/templates/NOTES.txt @@ -1,19 +1,4 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "identity-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "identity-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "identity-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "identity-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 -{{- end }} +eShop Identity API installed. +----------------------------- + +Access this API through ingress. \ No newline at end of file diff --git a/k8s/helm/identity-api/templates/configmap.yaml b/k8s/helm/identity-api/templates/configmap.yaml index f0ad8de3f..bb22d27f8 100644 --- a/k8s/helm/identity-api/templates/configmap.yaml +++ b/k8s/helm/identity-api/templates/configmap.yaml @@ -20,7 +20,7 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - identity__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.identity.db }};User Id={{ .Values.inf.sql.identity.user }};Password={{ .Values.inf.sql.identity.pwd }}; + 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: http://{{ .Values.inf.redis.keystore.constr }} all__InstrumentationKey: http://{{ .Values.inf.appinsights.key }} mvc_e: http://{{ $mvc_url }} diff --git a/k8s/helm/identity-api/templates/ingress.yaml b/k8s/helm/identity-api/templates/ingress.yaml index ff26c67b7..5824f91e2 100644 --- a/k8s/helm/identity-api/templates/ingress.yaml +++ b/k8s/helm/identity-api/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "identity-api.fullname" . -}} {{- $ingressPath := include "pathBase" . -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "identity-api.fullname" . }} labels: app: {{ template "identity-api.name" . }} chart: {{ template "identity-api.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + serviceName: {{ .Values.app.svc.identity }} servicePort: http {{- end }} diff --git a/k8s/helm/identity-api/values.yaml b/k8s/helm/identity-api/values.yaml index 77609b12b..9777db355 100644 --- a/k8s/helm/identity-api/values.yaml +++ b/k8s/helm/identity-api/values.yaml @@ -3,7 +3,7 @@ clusterName: eshop-aks pathBase: /identity image: - repository: eshop/ordering.backgroundtasks + repository: eshop/identity.api tag: latest pullPolicy: IfNotPresent @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} hosts: - chart-example.local diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index de2ca3058..e0e0dc562 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -3,18 +3,16 @@ 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 +# 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) - user: sa # Catalog API SQL user - pwd: Pass@word # Catalog API SQL pwd db: CatalogDb # Catalog API SQL db name ordering: # inf.sql.ordering: settings for the ordering-api sql (user, pwd, db) - user: sa # Ordering API SQL user - pwd: Pass@word # Ordering API SQL pwd db: OrderingDb # Ordering API SQL db name identity: - user: sa # Ordering API SQL user - pwd: Pass@word # Ordering API SQL pwd 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 @@ -23,12 +21,15 @@ inf: marketing: database: MarketingDb redis: # inf.redis defines the redis' connection strings - basket: + 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: - constr: rabbitmq # Event bus connection strin g + 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 @@ -39,3 +40,9 @@ inf: 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/templates/NOTES.txt b/k8s/helm/locations-api/templates/NOTES.txt index 51aea5725..3b48889bf 100644 --- a/k8s/helm/locations-api/templates/NOTES.txt +++ b/k8s/helm/locations-api/templates/NOTES.txt @@ -1,19 +1,9 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "locations-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "locations-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "locations-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/locations-api/templates/ingress.yaml deleted file mode 100644 index fa6c5b815..000000000 --- a/k8s/helm/locations-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "locations-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "locations-api.name" . }} - chart: {{ template "locations-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/marketing-api/templates/NOTES.txt b/k8s/helm/marketing-api/templates/NOTES.txt index 99f820091..7fa66ed47 100644 --- a/k8s/helm/marketing-api/templates/NOTES.txt +++ b/k8s/helm/marketing-api/templates/NOTES.txt @@ -1,19 +1,9 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "marketing-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "marketing-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "marketing-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/marketing-api/templates/ingress.yaml deleted file mode 100644 index 5b4aa12ee..000000000 --- a/k8s/helm/marketing-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "marketing-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "marketing-api.name" . }} - chart: {{ template "marketing-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/mobileshoppingagg/templates/NOTES.txt b/k8s/helm/mobileshoppingagg/templates/NOTES.txt index db6051447..61971f717 100644 --- a/k8s/helm/mobileshoppingagg/templates/NOTES.txt +++ b/k8s/helm/mobileshoppingagg/templates/NOTES.txt @@ -1,19 +1,8 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "mobileshoppingagg.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "mobileshoppingagg.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mobileshoppingagg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/mobileshoppingagg/templates/ingress.yaml deleted file mode 100644 index c116272cd..000000000 --- a/k8s/helm/mobileshoppingagg/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "mobileshoppingagg.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "mobileshoppingagg.name" . }} - chart: {{ template "mobileshoppingagg.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - - {{ .Values.inf.k8s.dns }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - - host: {{ .Values.inf.k8s.dns }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http -{{- end }} 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/templates/NOTES.txt b/k8s/helm/ordering-api/templates/NOTES.txt index b44f4af4e..43bfd2fdf 100644 --- a/k8s/helm/ordering-api/templates/NOTES.txt +++ b/k8s/helm/ordering-api/templates/NOTES.txt @@ -1,19 +1,8 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "ordering-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/configmap.yaml b/k8s/helm/ordering-api/templates/configmap.yaml index a43663308..de4cb2d7a 100644 --- a/k8s/helm/ordering-api/templates/configmap.yaml +++ b/k8s/helm/ordering-api/templates/configmap.yaml @@ -12,7 +12,7 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.ordering.user }};Password={{ .Values.inf.sql.ordering.pwd }}; + 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 }} diff --git a/k8s/helm/ordering-api/templates/ingress.yaml b/k8s/helm/ordering-api/templates/ingress.yaml deleted file mode 100644 index ac390c7f8..000000000 --- a/k8s/helm/ordering-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "ordering-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "ordering-api.name" . }} - chart: {{ template "ordering-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt index b8efad3d8..54e1b49ea 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt +++ b/k8s/helm/ordering-backgroundtasks/templates/NOTES.txt @@ -1,19 +1,3 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-backgroundtasks.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "ordering-backgroundtasks.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-backgroundtasks.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "ordering-backgroundtasks.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop Ordering Background Tasks installed. +------------------------------------------ + diff --git a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml index ceaa7ea89..54fec785b 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/configmap.yaml @@ -11,7 +11,7 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: - ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.ordering.user }};Password={{ .Values.inf.sql.ordering.pwd }}; + 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 }} diff --git a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml b/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml deleted file mode 100644 index 40a545cab..000000000 --- a/k8s/helm/ordering-backgroundtasks/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "ordering-backgroundtasks.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "ordering-backgroundtasks.name" . }} - chart: {{ template "ordering-backgroundtasks.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - - {{ .Values.inf.k8s.dns }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - - host: {{ .Values.inf.k8s.dns }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/ordering-backgroundtasks/values.yaml b/k8s/helm/ordering-backgroundtasks/values.yaml index e1b97daf9..adfa20c03 100644 --- a/k8s/helm/ordering-backgroundtasks/values.yaml +++ b/k8s/helm/ordering-backgroundtasks/values.yaml @@ -44,8 +44,6 @@ env: key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: IdentityUrl - key: urls__IdentityUrl - name: UseLoadTest key: ordering__EnableLoadTest - name: CheckUpdateTime diff --git a/k8s/helm/ordering-signalrhub/templates/NOTES.txt b/k8s/helm/ordering-signalrhub/templates/NOTES.txt index aed454cbe..fc55c9dfa 100644 --- a/k8s/helm/ordering-signalrhub/templates/NOTES.txt +++ b/k8s/helm/ordering-signalrhub/templates/NOTES.txt @@ -1,19 +1,8 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "ordering-signalrhub.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "ordering-signalrhub.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ordering-signalrhub.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/ordering-signalrhub/templates/ingress.yaml deleted file mode 100644 index 30bc51070..000000000 --- a/k8s/helm/ordering-signalrhub/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "ordering-signalrhub.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "ordering-signalrhub.name" . }} - chart: {{ template "ordering-signalrhub.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - - {{ .Values.inf.k8s.dns }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - - host: {{ .Values.inf.k8s.dns }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/ordering-signalrhub/values.yaml b/k8s/helm/ordering-signalrhub/values.yaml index 13c3906e9..19099b147 100644 --- a/k8s/helm/ordering-signalrhub/values.yaml +++ b/k8s/helm/ordering-signalrhub/values.yaml @@ -3,7 +3,7 @@ clusterName: eshop-aks pathBase: /ordering-signalrhub image: - repository: eshop/ordering-signalrhub + repository: eshop/ordering.signalrhub tag: latest pullPolicy: IfNotPresent diff --git a/k8s/helm/payment-api/templates/NOTES.txt b/k8s/helm/payment-api/templates/NOTES.txt index 0642d8004..6d178f344 100644 --- a/k8s/helm/payment-api/templates/NOTES.txt +++ b/k8s/helm/payment-api/templates/NOTES.txt @@ -1,19 +1,9 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "payment-api.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "payment-api.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "payment-api.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/payment-api/templates/ingress.yaml deleted file mode 100644 index e18ce4084..000000000 --- a/k8s/helm/payment-api/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "payment-api.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "payment-api.name" . }} - chart: {{ template "payment-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: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/payment-api/values.yaml b/k8s/helm/payment-api/values.yaml index 738bffa90..0ee6dd4d9 100644 --- a/k8s/helm/payment-api/values.yaml +++ b/k8s/helm/payment-api/values.yaml @@ -3,7 +3,7 @@ clusterName: eshop-aks pathBase: /payment-api image: - repository: eshop/locations.api + repository: eshop/payment.api tag: latest pullPolicy: IfNotPresent 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/templates/NOTES.txt b/k8s/helm/webmvc/templates/NOTES.txt index 049af195c..06e02a45d 100644 --- a/k8s/helm/webmvc/templates/NOTES.txt +++ b/k8s/helm/webmvc/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webmvc.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "webmvc.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webmvc.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webmvc.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop WebMVC installed. +----------------------- diff --git a/k8s/helm/webmvc/templates/ingress.yaml b/k8s/helm/webmvc/templates/ingress.yaml index 313f4ccf8..abfb62b2f 100644 --- a/k8s/helm/webmvc/templates/ingress.yaml +++ b/k8s/helm/webmvc/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "webmvc.fullname" . -}} {{- $ingressPath := include "pathBase" . -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "webmvc.fullname" . }} labels: app: {{ template "webmvc.name" . }} chart: {{ template "webmvc.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + serviceName: {{ .Values.app.svc.mvc }} servicePort: http {{- end }} diff --git a/k8s/helm/webmvc/values.yaml b/k8s/helm/webmvc/values.yaml index 3ec89304d..f37dc104e 100644 --- a/k8s/helm/webmvc/values.yaml +++ b/k8s/helm/webmvc/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/webshoppingagg/templates/NOTES.txt b/k8s/helm/webshoppingagg/templates/NOTES.txt index 24c110fec..f55946f36 100644 --- a/k8s/helm/webshoppingagg/templates/NOTES.txt +++ b/k8s/helm/webshoppingagg/templates/NOTES.txt @@ -1,19 +1,8 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webshoppingagg.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "webshoppingagg.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webshoppingagg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "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 -{{- end }} +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/ingress.yaml b/k8s/helm/webshoppingagg/templates/ingress.yaml deleted file mode 100644 index 058f24730..000000000 --- a/k8s/helm/webshoppingagg/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "webshoppingagg.fullname" . -}} -{{- $ingressPath := include "pathBase" . -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app: {{ template "webshoppingagg.name" . }} - chart: {{ template "webshoppingagg.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - - {{ .Values.inf.k8s.dns }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - - host: {{ .Values.inf.k8s.dns }} - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http -{{- end }} diff --git a/k8s/helm/webspa/templates/NOTES.txt b/k8s/helm/webspa/templates/NOTES.txt index 1bd7fdbc3..c8e1622db 100644 --- a/k8s/helm/webspa/templates/NOTES.txt +++ b/k8s/helm/webspa/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webspa.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "webspa.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webspa.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webspa.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop WebSPA installed +---------------------- \ No newline at end of file diff --git a/k8s/helm/webspa/templates/ingress.yaml b/k8s/helm/webspa/templates/ingress.yaml index 3a578e79c..85419f8e7 100644 --- a/k8s/helm/webspa/templates/ingress.yaml +++ b/k8s/helm/webspa/templates/ingress.yaml @@ -1,10 +1,9 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "webspa.fullname" . -}} {{- $ingressPath := include "pathBase" . -}} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "webspa.fullname" . }} labels: app: {{ template "webspa.name" . }} chart: {{ template "webspa.chart" . }} @@ -29,6 +28,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + serviceName: {{ .Values.app.svc.spa }} servicePort: http {{- end }} diff --git a/k8s/helm/webspa/values.yaml b/k8s/helm/webspa/values.yaml index 6ca548102..49821f276 100644 --- a/k8s/helm/webspa/values.yaml +++ b/k8s/helm/webspa/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] diff --git a/k8s/helm/webstatus/templates/NOTES.txt b/k8s/helm/webstatus/templates/NOTES.txt index 243d0726f..5d9d4570d 100644 --- a/k8s/helm/webstatus/templates/NOTES.txt +++ b/k8s/helm/webstatus/templates/NOTES.txt @@ -1,19 +1,2 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "webstatus.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get svc -w {{ template "webstatus.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "webstatus.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "webstatus.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} +eShop WebStatus installed. +-------------------------- \ No newline at end of file diff --git a/k8s/helm/webstatus/templates/ingress.yaml b/k8s/helm/webstatus/templates/ingress.yaml index 48b38c3dd..1ab4e5e22 100644 --- a/k8s/helm/webstatus/templates/ingress.yaml +++ b/k8s/helm/webstatus/templates/ingress.yaml @@ -4,7 +4,7 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ $fullName }} + name: {{ template "webstatus.fullname" . }} labels: app: {{ template "webstatus.name" . }} chart: {{ template "webstatus.chart" . }} @@ -29,6 +29,6 @@ spec: paths: - path: {{ $ingressPath }} backend: - serviceName: {{ $fullName }} + serviceName: {{ .Values.app.svc.status }} servicePort: http {{- end }} diff --git a/k8s/helm/webstatus/values.yaml b/k8s/helm/webstatus/values.yaml index 28c15b22d..8e5912fda 100644 --- a/k8s/helm/webstatus/values.yaml +++ b/k8s/helm/webstatus/values.yaml @@ -12,7 +12,7 @@ service: port: 80 ingress: - enabled: false + enabled: true annotations: {} tls: [] @@ -37,7 +37,7 @@ env: - name: CatalogUrl key: internalurls__catalog__hc - name: IdentityUrl - key: internalurls__IdentityUrl + key: internalurls__identity__hc - name: OrderingUrl key: internalurls__ordering__hc - name: OrderingBackgroundTasksUrl From 8ca63522c31ecf6f9c4e148c15f64cb92f0bf0e4 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Tue, 3 Jul 2018 20:05:58 +0200 Subject: [PATCH 28/29] minor fixes --- k8s/helm/app.yaml | 2 +- k8s/helm/deploy-all.ps1 | 6 +++--- k8s/helm/identity-api/templates/configmap.yaml | 4 ++-- k8s/helm/inf.yaml | 2 +- k8s/helm/webspa/values.yaml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/k8s/helm/app.yaml b/k8s/helm/app.yaml index 826c41632..6ca5d9d31 100644 --- a/k8s/helm/app.yaml +++ b/k8s/helm/app.yaml @@ -11,7 +11,7 @@ app: # app global settings ordering: ordering-api # ingress entry for ordering api identity: identity # ingress entry for identity api mvc: webmvc # ingress entry for web mvc - spa: webspa # ingress entry for web spa + 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 diff --git a/k8s/helm/deploy-all.ps1 b/k8s/helm/deploy-all.ps1 index a77d5d030..4a90387cd 100644 --- a/k8s/helm/deploy-all.ps1 +++ b/k8s/helm/deploy-all.ps1 @@ -45,18 +45,18 @@ $useDockerHub = [string]::IsNullOrEmpty($registry) 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", "-api", "locations-api", "marketing-api", "mobileshoppingagg","ordering-api","ordering-backgroundtasks","ordering-signalrhub", "payment-api", "webmvc", "webshoppingagg", "webspa", "webstatus") +$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 appName=$appName --set inf.k8s.dns=$dns --name="$appName-$infra" $infra + 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 - helm install --values app.yaml --values inf.yaml --values ingress_values.yaml --set appName=$appName --set inf.k8s.dns=$dns --set image.tag=$imageTag --name="$appName-$chart" $chart + 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 --name="$appName-$chart" $chart } Write-Host "helm charts installed." -ForegroundColor Green diff --git a/k8s/helm/identity-api/templates/configmap.yaml b/k8s/helm/identity-api/templates/configmap.yaml index bb22d27f8..3a71f1a81 100644 --- a/k8s/helm/identity-api/templates/configmap.yaml +++ b/k8s/helm/identity-api/templates/configmap.yaml @@ -21,8 +21,8 @@ metadata: 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: http://{{ .Values.inf.redis.keystore.constr }} - all__InstrumentationKey: http://{{ .Values.inf.appinsights.key }} + 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 }} diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index e0e0dc562..073e53dd4 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -35,7 +35,7 @@ inf: key: "" # App insights to use k8s: # inf.k8s defines Kubernetes cluster global config dns: "" # k8s external IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) - dnsprefix: true # If 'true' DNS values in ingress are prefixed using values.app.name. Note that this requires "externalDNS" to be running in k8s cluster. If true "inf.k8s.suffix" is ignored. + dnsprefix: false # If 'true' DNS values in ingress are prefixed using values.app.name. Note that this requires "externalDNS" to be running in k8s cluster. If true "inf.k8s.suffix" is ignored. suffix: false # If 'true' URL values in ingress are suffixed using values.app.name. That do not require anything special in cluster and still allows many apps using same ingress controller. Ignored if inf.k8s.dnsprefix is true misc: # inf.misc contains miscellaneous configuration related to infrastructure useLoadTest: false # If running under loading test or not diff --git a/k8s/helm/webspa/values.yaml b/k8s/helm/webspa/values.yaml index 49821f276..e07909f6e 100644 --- a/k8s/helm/webspa/values.yaml +++ b/k8s/helm/webspa/values.yaml @@ -1,6 +1,6 @@ replicaCount: 1 clusterName: eshop-aks -pathBase: /webspa +pathBase: / image: repository: eshop/webspa From 9351fb31eb1ecad77500fa60410c12c76d983d75 Mon Sep 17 00:00:00 2001 From: eiximenis Date: Mon, 9 Jul 2018 14:20:27 +0200 Subject: [PATCH 29/29] final updates to helm scripts --- k8s/helm/aks-httpaddon-cfg.yaml | 12 +++++++++++ k8s/helm/apigwmm/templates/_names.tpl | 20 ++++++++++--------- k8s/helm/apigwmm/templates/deployment.yaml | 8 +++----- k8s/helm/apigwms/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/apigwms/templates/deployment.yaml | 8 +++----- k8s/helm/apigwwm/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/apigwwm/templates/deployment.yaml | 8 +++----- k8s/helm/apigwws/templates/_names.tpl | 20 ++++++++++--------- k8s/helm/apigwws/templates/deployment.yaml | 8 +++----- k8s/helm/basket-api/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/basket-api/templates/deployment.yaml | 8 +++----- k8s/helm/catalog-api/templates/_names.tpl | 19 ++++++++++-------- .../catalog-api/templates/deployment.yaml | 8 +++----- k8s/helm/deploy-all.ps1 | 19 ++++++++++++++++-- k8s/helm/identity-api/templates/_names.tpl | 20 ++++++++++--------- .../identity-api/templates/deployment.yaml | 8 +++----- k8s/helm/inf.yaml | 4 +--- k8s/helm/locations-api/templates/_names.tpl | 19 ++++++++++-------- .../locations-api/templates/deployment.yaml | 8 +++----- k8s/helm/marketing-api/templates/_names.tpl | 19 ++++++++++-------- .../marketing-api/templates/deployment.yaml | 8 +++----- .../mobileshoppingagg/templates/_names.tpl | 19 ++++++++++-------- .../templates/deployment.yaml | 8 +++----- k8s/helm/ordering-api/templates/_names.tpl | 20 ++++++++++--------- .../ordering-api/templates/deployment.yaml | 8 +++----- .../templates/_names.tpl | 20 ++++++++++--------- .../templates/deployment.yaml | 8 +++----- .../ordering-signalrhub/templates/_names.tpl | 20 ++++++++++--------- .../templates/deployment.yaml | 9 +++------ k8s/helm/payment-api/templates/_names.tpl | 20 ++++++++++--------- .../payment-api/templates/deployment.yaml | 8 +++----- k8s/helm/webmvc/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/webmvc/templates/deployment.yaml | 8 +++----- k8s/helm/webshoppingagg/templates/_names.tpl | 19 ++++++++++-------- .../webshoppingagg/templates/deployment.yaml | 8 +++----- k8s/helm/webspa/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/webspa/templates/deployment.yaml | 8 +++----- k8s/helm/webstatus/templates/_names.tpl | 19 ++++++++++-------- k8s/helm/webstatus/templates/deployment.yaml | 8 +++----- src/Services/Identity/Identity.API/Startup.cs | 1 + 40 files changed, 283 insertions(+), 247 deletions(-) create mode 100644 k8s/helm/aks-httpaddon-cfg.yaml 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/templates/_names.tpl b/k8s/helm/apigwmm/templates/_names.tpl index c1111b058..a6eeb9965 100644 --- a/k8s/helm/apigwmm/templates/_names.tpl +++ b/k8s/helm/apigwmm/templates/_names.tpl @@ -25,21 +25,15 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- define "pathBase" -}} {{- $name := first .}} {{- $ctx := last .}} {{- if $ctx.Values.inf.k8s.suffix -}} @@ -48,4 +42,12 @@ {{- 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/deployment.yaml b/k8s/helm/apigwmm/templates/deployment.yaml index 120cb5889..2e30c78e7 100644 --- a/k8s/helm/apigwmm/templates/deployment.yaml +++ b/k8s/helm/apigwmm/templates/deployment.yaml @@ -23,11 +23,9 @@ spec: app: {{ template "apigwmm.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} volumes: - name: config @@ -38,7 +36,7 @@ spec: path: configuration.json containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: - name: config diff --git a/k8s/helm/apigwms/templates/_names.tpl b/k8s/helm/apigwms/templates/_names.tpl index c1111b058..1e840c56c 100644 --- a/k8s/helm/apigwms/templates/_names.tpl +++ b/k8s/helm/apigwms/templates/_names.tpl @@ -25,21 +25,16 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- define "pathBase" -}} {{- $name := first .}} {{- $ctx := last .}} {{- if $ctx.Values.inf.k8s.suffix -}} @@ -48,4 +43,12 @@ {{- 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/deployment.yaml b/k8s/helm/apigwms/templates/deployment.yaml index 24519d777..2c8a43050 100644 --- a/k8s/helm/apigwms/templates/deployment.yaml +++ b/k8s/helm/apigwms/templates/deployment.yaml @@ -23,11 +23,9 @@ spec: app: {{ template "apigwms.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} volumes: - name: config @@ -38,7 +36,7 @@ spec: path: configuration.json containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: - name: config diff --git a/k8s/helm/apigwwm/templates/_names.tpl b/k8s/helm/apigwwm/templates/_names.tpl index c1111b058..1e840c56c 100644 --- a/k8s/helm/apigwwm/templates/_names.tpl +++ b/k8s/helm/apigwwm/templates/_names.tpl @@ -25,21 +25,16 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- define "pathBase" -}} {{- $name := first .}} {{- $ctx := last .}} {{- if $ctx.Values.inf.k8s.suffix -}} @@ -48,4 +43,12 @@ {{- 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/deployment.yaml b/k8s/helm/apigwwm/templates/deployment.yaml index ed28de243..1e0e58888 100644 --- a/k8s/helm/apigwwm/templates/deployment.yaml +++ b/k8s/helm/apigwwm/templates/deployment.yaml @@ -23,11 +23,9 @@ spec: app: {{ template "apigwwm.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} volumes: - name: config @@ -38,7 +36,7 @@ spec: path: configuration.json containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: - name: config diff --git a/k8s/helm/apigwws/templates/_names.tpl b/k8s/helm/apigwws/templates/_names.tpl index c1111b058..a6eeb9965 100644 --- a/k8s/helm/apigwws/templates/_names.tpl +++ b/k8s/helm/apigwws/templates/_names.tpl @@ -25,21 +25,15 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- define "pathBase" -}} {{- $name := first .}} {{- $ctx := last .}} {{- if $ctx.Values.inf.k8s.suffix -}} @@ -48,4 +42,12 @@ {{- 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/deployment.yaml b/k8s/helm/apigwws/templates/deployment.yaml index da7b69a5b..b52e77042 100644 --- a/k8s/helm/apigwws/templates/deployment.yaml +++ b/k8s/helm/apigwws/templates/deployment.yaml @@ -23,11 +23,9 @@ spec: app: {{ template "apigwws.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} volumes: - name: config @@ -38,7 +36,7 @@ spec: path: configuration.json containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: - name: config diff --git a/k8s/helm/basket-api/templates/_names.tpl b/k8s/helm/basket-api/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/basket-api/templates/_names.tpl +++ b/k8s/helm/basket-api/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/basket-api/templates/deployment.yaml index 911818231..ee283122c 100644 --- a/k8s/helm/basket-api/templates/deployment.yaml +++ b/k8s/helm/basket-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "basket-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/catalog-api/templates/_names.tpl b/k8s/helm/catalog-api/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/catalog-api/templates/_names.tpl +++ b/k8s/helm/catalog-api/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/catalog-api/templates/deployment.yaml index d508cd3ae..99e270af9 100644 --- a/k8s/helm/catalog-api/templates/deployment.yaml +++ b/k8s/helm/catalog-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "catalog-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/deploy-all.ps1 b/k8s/helm/deploy-all.ps1 index 4a90387cd..1239cc7af 100644 --- a/k8s/helm/deploy-all.ps1 +++ b/k8s/helm/deploy-all.ps1 @@ -40,7 +40,15 @@ if ($clean) { Write-Host "Previous releases deleted" -ForegroundColor Green } -$useDockerHub = [string]::IsNullOrEmpty($registry) +$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 @@ -56,7 +64,14 @@ if ($deployInfrastructure) { foreach ($chart in $charts) { Write-Host "Installing: $chart" -ForegroundColor Green - 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 --name="$appName-$chart" $chart + 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/identity-api/templates/_names.tpl b/k8s/helm/identity-api/templates/_names.tpl index 7e817f9b7..39ee485ef 100644 --- a/k8s/helm/identity-api/templates/_names.tpl +++ b/k8s/helm/identity-api/templates/_names.tpl @@ -25,25 +25,27 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/identity-api/templates/deployment.yaml index 6cd425afd..753725a9f 100644 --- a/k8s/helm/identity-api/templates/deployment.yaml +++ b/k8s/helm/identity-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "identity-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/inf.yaml b/k8s/helm/inf.yaml index 073e53dd4..4c0180f45 100644 --- a/k8s/helm/inf.yaml +++ b/k8s/helm/inf.yaml @@ -34,9 +34,7 @@ inf: appinsights: key: "" # App insights to use k8s: # inf.k8s defines Kubernetes cluster global config - dns: "" # k8s external IP or DNS. Value MUST BE PROVIDED using --set (--set inf.k8s.dns=my-cluster-dns) - dnsprefix: false # If 'true' DNS values in ingress are prefixed using values.app.name. Note that this requires "externalDNS" to be running in k8s cluster. If true "inf.k8s.suffix" is ignored. - suffix: false # If 'true' URL values in ingress are suffixed using values.app.name. That do not require anything special in cluster and still allows many apps using same ingress controller. Ignored if inf.k8s.dnsprefix is true + 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 diff --git a/k8s/helm/locations-api/templates/_names.tpl b/k8s/helm/locations-api/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/locations-api/templates/_names.tpl +++ b/k8s/helm/locations-api/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/locations-api/templates/deployment.yaml index 826dd80a1..c8f3f00cd 100644 --- a/k8s/helm/locations-api/templates/deployment.yaml +++ b/k8s/helm/locations-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "locations-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/marketing-api/templates/_names.tpl b/k8s/helm/marketing-api/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/marketing-api/templates/_names.tpl +++ b/k8s/helm/marketing-api/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/marketing-api/templates/deployment.yaml index 3aa1927e9..e0cbeb3ce 100644 --- a/k8s/helm/marketing-api/templates/deployment.yaml +++ b/k8s/helm/marketing-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "marketing-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/mobileshoppingagg/templates/_names.tpl b/k8s/helm/mobileshoppingagg/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/mobileshoppingagg/templates/_names.tpl +++ b/k8s/helm/mobileshoppingagg/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/mobileshoppingagg/templates/deployment.yaml index 6317c99e3..5e81da7bf 100644 --- a/k8s/helm/mobileshoppingagg/templates/deployment.yaml +++ b/k8s/helm/mobileshoppingagg/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "mobileshoppingagg.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/ordering-api/templates/_names.tpl b/k8s/helm/ordering-api/templates/_names.tpl index 7e817f9b7..39ee485ef 100644 --- a/k8s/helm/ordering-api/templates/_names.tpl +++ b/k8s/helm/ordering-api/templates/_names.tpl @@ -25,25 +25,27 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/ordering-api/templates/deployment.yaml index 54ab5a6ed..19845c251 100644 --- a/k8s/helm/ordering-api/templates/deployment.yaml +++ b/k8s/helm/ordering-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "ordering-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl index 7e817f9b7..39ee485ef 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/_names.tpl +++ b/k8s/helm/ordering-backgroundtasks/templates/_names.tpl @@ -25,25 +25,27 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml index 16dc73400..cb57ca18d 100644 --- a/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml +++ b/k8s/helm/ordering-backgroundtasks/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "ordering-backgroundtasks.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/ordering-signalrhub/templates/_names.tpl b/k8s/helm/ordering-signalrhub/templates/_names.tpl index 7e817f9b7..39ee485ef 100644 --- a/k8s/helm/ordering-signalrhub/templates/_names.tpl +++ b/k8s/helm/ordering-signalrhub/templates/_names.tpl @@ -25,25 +25,27 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/ordering-signalrhub/templates/deployment.yaml index 91d2f80ae..af3867ea5 100644 --- a/k8s/helm/ordering-signalrhub/templates/deployment.yaml +++ b/k8s/helm/ordering-signalrhub/templates/deployment.yaml @@ -5,7 +5,6 @@ kind: Deployment metadata: name: {{ template "ordering-signalrhub.fullname" . }} labels: - ufo: {{ $cfgname}} app: {{ template "ordering-signalrhub.name" . }} chart: {{ template "ordering-signalrhub.chart" . }} release: {{ .Release.Name }} @@ -22,15 +21,13 @@ spec: app: {{ template "ordering-signalrhub.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/payment-api/templates/_names.tpl b/k8s/helm/payment-api/templates/_names.tpl index 7e817f9b7..39ee485ef 100644 --- a/k8s/helm/payment-api/templates/_names.tpl +++ b/k8s/helm/payment-api/templates/_names.tpl @@ -25,25 +25,27 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} - -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/payment-api/templates/deployment.yaml index 8863535ba..8b414145f 100644 --- a/k8s/helm/payment-api/templates/deployment.yaml +++ b/k8s/helm/payment-api/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "payment-api.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/webmvc/templates/_names.tpl b/k8s/helm/webmvc/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/webmvc/templates/_names.tpl +++ b/k8s/helm/webmvc/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/webmvc/templates/deployment.yaml index 03db384b8..d972db448 100644 --- a/k8s/helm/webmvc/templates/deployment.yaml +++ b/k8s/helm/webmvc/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "webmvc.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/webshoppingagg/templates/_names.tpl b/k8s/helm/webshoppingagg/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/webshoppingagg/templates/_names.tpl +++ b/k8s/helm/webshoppingagg/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/webshoppingagg/templates/deployment.yaml index a0f97df5d..9d557b0e0 100644 --- a/k8s/helm/webshoppingagg/templates/deployment.yaml +++ b/k8s/helm/webshoppingagg/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "webshoppingagg.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/webspa/templates/_names.tpl b/k8s/helm/webspa/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/webspa/templates/_names.tpl +++ b/k8s/helm/webspa/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/webspa/templates/deployment.yaml index 9b3b88962..62af2d8b1 100644 --- a/k8s/helm/webspa/templates/deployment.yaml +++ b/k8s/helm/webspa/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "webspa.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE diff --git a/k8s/helm/webstatus/templates/_names.tpl b/k8s/helm/webstatus/templates/_names.tpl index 7e817f9b7..d44859fea 100644 --- a/k8s/helm/webstatus/templates/_names.tpl +++ b/k8s/helm/webstatus/templates/_names.tpl @@ -25,25 +25,28 @@ {{- define "url-of" -}} {{- $name := first .}} {{- $ctx := last .}} -{{- $suffix := include "suffix-name" $ctx -}} -{{- if $ctx.Values.inf.k8s.dnsprefix -}} -{{- printf "%s.%s/%s" $suffix $ctx.Values.inf.k8s.dns $name -}} {{/* Value is ./ */}} -{{- else -}} -{{- if $ctx.Values.inf.k8s.suffix -}} -{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}} {{/*Value is /- */}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} {{- else -}} {{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} {{- end -}} {{- end -}} -{{- end -}} -{{ define "pathBase" -}} +{{- 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/deployment.yaml b/k8s/helm/webstatus/templates/deployment.yaml index 19eed779b..6f96f81fb 100644 --- a/k8s/helm/webstatus/templates/deployment.yaml +++ b/k8s/helm/webstatus/templates/deployment.yaml @@ -22,15 +22,13 @@ spec: app: {{ template "webstatus.name" . }} release: {{ .Release.Name }} spec: - {{ if .Values.imagePullSecrets -}} + {{ if .Values.inf.registry -}} imagePullSecrets: - {{ range .Values.imagePullSecrets -}} - - name: {{ .name }} - {{- end -}} + - name: {{ .Values.inf.registry.secretName }} {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: "{{ template "fqdn-image" . }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: PATH_BASE 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();