Browse Source

Identity api

some refactor on common templates
pull/867/head
eiximenis 6 years ago
parent
commit
c84ddb7f40
12 changed files with 374 additions and 6 deletions
  1. +23
    -5
      k8s/helm/app.yaml
  2. +21
    -0
      k8s/helm/identity-api/.helmignore
  3. +5
    -0
      k8s/helm/identity-api/Chart.yaml
  4. +19
    -0
      k8s/helm/identity-api/templates/NOTES.txt
  5. +32
    -0
      k8s/helm/identity-api/templates/_helpers.tpl
  6. +37
    -0
      k8s/helm/identity-api/templates/_names.tpl
  7. +36
    -0
      k8s/helm/identity-api/templates/configmap.yaml
  8. +73
    -0
      k8s/helm/identity-api/templates/deployment.yaml
  9. +38
    -0
      k8s/helm/identity-api/templates/ingress.yaml
  10. +19
    -0
      k8s/helm/identity-api/templates/service.yaml
  11. +64
    -0
      k8s/helm/identity-api/values.yaml
  12. +7
    -1
      k8s/helm/inf.yaml

+ 23
- 5
k8s/helm/app.yaml View File

@ -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)
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

+ 21
- 0
k8s/helm/identity-api/.helmignore View File

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

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

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

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

@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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 }}

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

@ -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 -}}

+ 37
- 0
k8s/helm/identity-api/templates/_names.tpl View File

@ -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 -}}

+ 36
- 0
k8s/helm/identity-api/templates/configmap.yaml View File

@ -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 }}

+ 73
- 0
k8s/helm/identity-api/templates/deployment.yaml View File

@ -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 }}

+ 38
- 0
k8s/helm/identity-api/templates/ingress.yaml View File

@ -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 }}

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

@ -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 }}

+ 64
- 0
k8s/helm/identity-api/values.yaml View File

@ -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'

+ 7
- 1
k8s/helm/inf.yaml View File

@ -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


Loading…
Cancel
Save