Skip to content

Commit

Permalink
Update application-library (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Nemakov authored Nov 15, 2021
1 parent 87bb669 commit cbb89bc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/application-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: application-library
description: Library chart for general application templates
type: library
version: 0.2.1
version: 0.3.0
appVersion: "0.1.0"
4 changes: 2 additions & 2 deletions charts/application-library/example-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ type: application
version: 0.1.0
dependencies:
- name: application-library
version: "0.2.1"
repository: "https://helm.evilmartians.net"
version: "*.*.*"
repository: "file://../../application-library"
49 changes: 39 additions & 10 deletions charts/application-library/templates/_main.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
{{/* Expand the name of the application. */}}
{{- define "app.name" -}}
{{ .Chart.Name | replace "." "-" }}
{{- default .Chart.Name .Values.nameOverride | replace "." "-" | 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 "app.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 -}}

{{/* Expand the name of the chart. */}}
Expand Down Expand Up @@ -37,17 +53,24 @@
{{/* Template for spec selectors */}}
{{/* the `.currentType` stands for the type of current pod */}}
{{- define "app.templateSelector" -}}
app: {{ include "app.name" . }}
component: {{ .currentType }}
app.kubernetes.io/name: {{ template "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .currentType }}
app.kubernetes.io/component: {{ .currentType }}
{{- end }}
{{- end }}

{{/* Labels for metadata of deployments */}}
{{/* the `.currentType` stands for the type of current pod */}}
{{- define "app.templateLabels" -}}
app: {{ include "app.name" . }}
component: {{ .currentType }}
chart: {{ include "app.chart" . }}
revision: v{{ .Release.Revision }}
app.kubernetes.io/name: {{ template "app.name" . }}
helm.sh/chart: {{ template "app.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/revision: v{{ .Release.Revision }}
{{- if .currentType }}
app.kubernetes.io/component: {{ .currentType }}
{{- end }}
{{- end }}

{{/* Template metadata for deployments and services */}}
Expand Down Expand Up @@ -91,15 +114,21 @@ podAntiAffinity:
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
- key: app.kubernetes.io/name
operator: In
values:
- {{ include "app.name" . }}
- key: component
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
{{- if .currentType }}
- key: app.kubernetes.io/component
operator: In
values:
- {{ .currentType }}
topologyKey: "kubernetes.io/hostname"
{{ end }}
topologyKey: {{ .topologyKey | default "kubernetes.io/hostname" }}
{{- end }}

{{/* Template to generate payload for Slack notification */}}
Expand Down

0 comments on commit cbb89bc

Please sign in to comment.