diff --git a/deploy/k8s/helm/zipkin/.helmignore b/deploy/k8s/helm/zipkin/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/deploy/k8s/helm/zipkin/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deploy/k8s/helm/zipkin/Chart.yaml b/deploy/k8s/helm/zipkin/Chart.yaml new file mode 100644 index 000000000..c70c6c0dd --- /dev/null +++ b/deploy/k8s/helm/zipkin/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: zipkin +version: 0.1.0 diff --git a/deploy/k8s/helm/zipkin/templates/NOTES.txt b/deploy/k8s/helm/zipkin/templates/NOTES.txt new file mode 100644 index 000000000..d5491db5f --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/NOTES.txt @@ -0,0 +1,2 @@ +eShop trace tool Zipkin installed. +----------------------- diff --git a/deploy/k8s/helm/zipkin/templates/_helpers.tpl b/deploy/k8s/helm/zipkin/templates/_helpers.tpl new file mode 100644 index 000000000..4679c356b --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "zipkin.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 "zipkin.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 "zipkin.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} \ No newline at end of file diff --git a/deploy/k8s/helm/zipkin/templates/_names.tpl b/deploy/k8s/helm/zipkin/templates/_names.tpl new file mode 100644 index 000000000..605e92e7e --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/_names.tpl @@ -0,0 +1,60 @@ +{{- define "suffix-name" -}} +{{- if .Values.app.name -}} +{{- .Values.app.name -}} +{{- else -}} +{{- .Release.Name -}} +{{- end -}} +{{- end -}} + +{{- define "sql-name" -}} +{{- if .Values.inf.sql.host -}} +{{- .Values.inf.sql.host -}} +{{- else -}} +{{- printf "%s" "sql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "mongo-name" -}} +{{- if .Values.inf.mongo.host -}} +{{- .Values.inf.mongo.host -}} +{{- else -}} +{{- printf "%s" "nosql-data" -}} +{{- end -}} +{{- end -}} + +{{- define "url-of" -}} +{{- $name := first .}} +{{- $ctx := last .}} +{{- if eq $name "" -}} +{{- $ctx.Values.inf.k8s.dns -}} +{{- else -}} +{{- printf "%s/%s" $ctx.Values.inf.k8s.dns $name -}} {{/*Value is just / */}} +{{- end -}} +{{- end -}} + + + +{{- define "pathBase" -}} +{{- if .Values.inf.k8s.suffix -}} +{{- $suffix := include "suffix-name" . -}} +{{- printf "%s-%s" .Values.pathBase $suffix -}} +{{- else -}} +{{- .Values.pathBase -}} +{{- end -}} +{{- end -}} + +{{- define "fqdn-image" -}} +{{- if .Values.inf.registry -}} +{{- printf "%s/%s" .Values.inf.registry.server .Values.image.repository -}} +{{- else -}} +{{- .Values.image.repository -}} +{{- end -}} +{{- end -}} + +{{- define "protocol" -}} +{{- if .Values.inf.tls.enabled -}} +{{- printf "%s" "https" -}} +{{- else -}} +{{- printf "%s" "http" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/helm/zipkin/templates/deployment.yaml b/deploy/k8s/helm/zipkin/templates/deployment.yaml new file mode 100644 index 000000000..a7ab765d3 --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "zipkin.fullname" . }} + labels: + app: {{ template "zipkin.name" . }} + chart: {{ template "zipkin.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "zipkin.name" . }} + release: {{ .Release.Name }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app: {{ template "zipkin.name" . }} + release: {{ .Release.Name }} + {{ if .Values.inf.mesh.enabled -}} + annotations: + linkerd.io/inject: enabled + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9411 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deploy/k8s/helm/zipkin/templates/ingress-dockerk8s.yaml b/deploy/k8s/helm/zipkin/templates/ingress-dockerk8s.yaml new file mode 100644 index 000000000..ab22d82bf --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/ingress-dockerk8s.yaml @@ -0,0 +1,33 @@ +{{- if .Values.ingress.enabled -}} +{{- if .Values.inf.k8s.local -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := .Values.app.svc.zipkin }} +{{- $name := include "zipkin.fullname" . -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ $name }}-local + labels: + app: {{ template "zipkin.name" . }} + chart: {{ template "zipkin.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +{{- if .Values.inf.mesh.enabled }} +{{- with .Values.ingress.mesh.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} +{{- end }} +spec: + rules: + - http: + paths: + - backend: + serviceName: {{ $serviceName }} + servicePort: http + path: {{ $ingressPath }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/deploy/k8s/helm/zipkin/templates/ingress.yaml b/deploy/k8s/helm/zipkin/templates/ingress.yaml new file mode 100644 index 000000000..0235938f7 --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled -}} +{{- $ingressPath := include "pathBase" . -}} +{{- $serviceName := include "zipkin.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ template "zipkin.fullname" . }} + labels: + app: {{ template "zipkin.name" . }} + chart: {{ template "zipkin.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 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: {{ $.Values.app.svc.zipkin }} + servicePort: http + {{- end }} +{{- end }} diff --git a/deploy/k8s/helm/zipkin/templates/service.yaml b/deploy/k8s/helm/zipkin/templates/service.yaml new file mode 100644 index 000000000..a27e0c1e0 --- /dev/null +++ b/deploy/k8s/helm/zipkin/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.app.svc.zipkin }} + labels: + app: {{ template "zipkin.name" . }} + chart: {{ template "zipkin.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 "zipkin.name" . }} + release: {{ .Release.Name }} \ No newline at end of file diff --git a/deploy/k8s/helm/zipkin/values.yaml b/deploy/k8s/helm/zipkin/values.yaml new file mode 100644 index 000000000..cabc3b328 --- /dev/null +++ b/deploy/k8s/helm/zipkin/values.yaml @@ -0,0 +1,26 @@ +replicaCount: 1 +clusterName: eshop-aks +pathBase: /zipkin + +image: + repository: openzipkin/zipkin + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 9411 + + +ingress: + enabled: true + annotations: {} + tls: [] + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} \ No newline at end of file