Skip to content

Commit

Permalink
Merge branch 'main' into fix-helm-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
tripathishikha1 authored Jul 5, 2024
2 parents 412565e + 1a5113d commit 2da3fb1
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
1 change: 1 addition & 0 deletions charts/microservice/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v2
name: microservice
description: A Helm chart for Kubernetes
Expand Down
17 changes: 16 additions & 1 deletion charts/microservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,19 @@ The Helm chart is specifically for deploying a microservice with a Kubernetes se

```bash
helm install my-release microservice/
```
```

## TODO

- [ ] Application Health Probes
- [ ] Service
- [ ] Horizontal Pod Autoscaler
- [ ] ConfigMap
- [ ] RBAC
- [ ] Service Account
- [ ] Role Binding
- [ ] Role
- [ ] Rolling Deployment Manipulation
- [ ] Environment Parmaters
- [ ] Container Port Mapping
- [ ] Application Secrets
60 changes: 60 additions & 0 deletions charts/microservice/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Create a defautl fully qualified app name
It will use the release name to give the app name
*/}}

{{- define "app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 60 | 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.tempname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 60 | 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 }}

{{- define "app.fullname" -}}
{{- printf "%s-%s" ( include "app.tempname" . ) "app" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "app.labels" -}}
app: {{ include "app.tempname" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "app.selectorLabels" -}}
app: {{ include "app.tempname" . }}
{{- end }}%

{{/*
service name
*/}}
{{- define "app.servicename" -}}
{{- printf "%s-%s" ( include "app.tempname" . ) "svc" | trunc 63 | trimSuffix "-" }}
{{- end }}%

{{/*
configmap name
*/}}
{{- define "app.configmapname" -}}
{{- printf "%s-%s" ( include "app.tempname" . ) "cm" | trunc 63 | trimSuffix "-" }}
{{- end }}%
8 changes: 3 additions & 5 deletions charts/microservice/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "app.fullname" . }}-svc
name: {{ include "app.servicename" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
spec:
Expand All @@ -16,8 +17,5 @@ spec:
port: {{ .Values.servicePorts.https }}
targetPort: https
protocol: TCP
- name: custom-port
port: {{ .Values.servicePorts.custom }}
targetPort: custom-port
protocol: TCP
type: {{ .Values.service.type }}
selector:
{{- include "app.selectorLabels" . | nindent 4 }}

0 comments on commit 2da3fb1

Please sign in to comment.