Skip to content

Commit cb60593

Browse files
committed
WIP on helm charts
1 parent c84ddb7 commit cb60593

18 files changed

Lines changed: 254 additions & 90 deletions

File tree

k8s/helm/basket-api/templates/_names.tpl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
{{- end -}}
1515
{{- end -}}
1616

17-
{{- define "url-identity" -}}
18-
{{- if .Values.app.ingress.suffix -}}
19-
{{- $suffix := include "suffix-name" . -}}
20-
{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}}
17+
{{- define "url-of" -}}
18+
{{- $name := first .}}
19+
{{- $ctx := last .}}
20+
{{- if $ctx.Values.app.ingress.suffix -}}
21+
{{- $suffix := include "suffix-name" $ctx -}}
22+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
2123
{{- else -}}
22-
{{- printf "%s/identity-api" .Values.inf.k8s.dns -}}
24+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
2325
{{- end -}}
2426
{{- end -}}
2527

28+
29+
2630
{{ define "pathBase" -}}
2731
{{- if .Values.app.ingress.suffix -}}
2832
{{- $suffix := include "suffix-name" . -}}

k8s/helm/basket-api/templates/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $name := include "basket-api.fullname" . -}}
2-
{{- $identity := include "url-identity" . -}}
2+
{{- $identity := include "url-of" (list .Values.app.ingress.entries.identity .) -}}
33

44
apiVersion: v1
55
kind: ConfigMap

k8s/helm/basket-api/values.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ ingress:
1818
- chart-example.local
1919
tls: []
2020

21-
inf: # inf - see comments in ../inf.yaml file for info
22-
redis:
23-
basket:
24-
constr: basket-data
25-
eventbus:
26-
constr: rabbitmq
27-
useAzure: false
28-
appinsights:
29-
key: ""
30-
k8s:
31-
dns: ""
32-
misc:
33-
useLoadTest: false
34-
3521
resources: {}
3622

3723

k8s/helm/catalog-api/templates/_names.tpl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
{{- end -}}
1515
{{- end -}}
1616

17-
{{- define "url-identity" -}}
18-
{{- if .Values.app.ingress.suffix -}}
19-
{{- $suffix := include "suffix-name" . -}}
20-
{{- printf "%s/identity-api-%s" .Values.inf.k8s.dns $suffix -}}
17+
{{- define "url-of" -}}
18+
{{- $name := first .}}
19+
{{- $ctx := last .}}
20+
{{- if $ctx.Values.app.ingress.suffix -}}
21+
{{- $suffix := include "suffix-name" $ctx -}}
22+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
2123
{{- else -}}
22-
{{- printf "%s/identity-api" .Values.inf.k8s.dns -}}
24+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
2325
{{- end -}}
2426
{{- end -}}
2527

28+
29+
2630
{{ define "pathBase" -}}
2731
{{- if .Values.app.ingress.suffix -}}
2832
{{- $suffix := include "suffix-name" . -}}

k8s/helm/catalog-api/values.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@ ingress:
1818
- chart-example.local
1919
tls: []
2020

21-
inf:
22-
sql:
23-
catalog:
24-
user: sa
25-
pwd: Pass@word
26-
db: CatalogDb
27-
eventbus:
28-
constr: rabbitmq
29-
useAzure: false
30-
appinsights:
31-
key: ""
32-
k8s:
33-
dns: ""
34-
misc:
35-
useAzureStorage: false
36-
37-
3821
resources: {}
3922

4023

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: Umbrella Chart for eShopOnContainers
4+
name: eshoponcontainers
5+
version: 0.1.0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range .Values.ingress.hosts }}
4+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
5+
{{- end }}
6+
{{- else if contains "NodePort" .Values.service.type }}
7+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "eshoponcontainers.fullname" . }})
8+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
9+
echo http://$NODE_IP:$NODE_PORT
10+
{{- else if contains "LoadBalancer" .Values.service.type }}
11+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
12+
You can watch the status of by running 'kubectl get svc -w {{ template "eshoponcontainers.fullname" . }}'
13+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "eshoponcontainers.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
14+
echo http://$SERVICE_IP:{{ .Values.service.port }}
15+
{{- else if contains "ClusterIP" .Values.service.type }}
16+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "eshoponcontainers.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
17+
echo "Visit http://127.0.0.1:8080 to use your application"
18+
kubectl port-forward $POD_NAME 8080:80
19+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "eshoponcontainers.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "eshoponcontainers.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "eshoponcontainers.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- define "suffix-name" -}}
2+
{{- if .Values.app.name -}}
3+
{{- .Values.app.name -}}
4+
{{- else -}}
5+
{{- .Release.Name -}}
6+
{{- end -}}
7+
{{- end -}}
8+
9+
{{- define "sql-name" -}}
10+
{{- if .Values.inf.sql.host -}}
11+
{{- .Values.inf.sql.host -}}
12+
{{- else -}}
13+
{{- printf "%s" "sql-data" -}}
14+
{{- end -}}
15+
{{- end -}}
16+
17+
{{- define "url-of" -}}
18+
{{- $name := first .}}
19+
{{- $ctx := last .}}
20+
{{- if $ctx.Values.app.ingress.suffix -}}
21+
{{- $suffix := include "suffix-name" $ctx -}}
22+
{{- printf "%s/%s-%s" $ctx.Values.inf.k8s.dns $name $suffix -}}
23+
{{- else -}}
24+
{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}}
25+
{{- end -}}
26+
{{- end -}}
27+
28+
29+
30+
{{ define "pathBase" -}}
31+
{{- if .Values.app.ingress.suffix -}}
32+
{{- $suffix := include "suffix-name" . -}}
33+
{{- printf "%s-%s" .Values.pathBase $suffix -}}
34+
{{- else -}}
35+
{{- .Values.pathBase -}}
36+
{{- end -}}
37+
{{- end -}}

0 commit comments

Comments
 (0)