Skip to content

Commit

Permalink
Update charts to lib approach and add func
Browse files Browse the repository at this point in the history
* Add ability to pass command + args
* Add hpa
  • Loading branch information
ekarlso committed Apr 5, 2021
1 parent a42b4d3 commit 9782bd6
Show file tree
Hide file tree
Showing 121 changed files with 1,480 additions and 2,019 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ repository/

data
temp
charts/
Chart.lock
9 changes: 6 additions & 3 deletions dotnet/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: v1
apiVersion: v2
description: .NET Core Helm Chart
name: dotnet
version: 8.1.0

version: 9.0.0
dependencies:
- name: libchart
version: 0.1.0
repository: file://../libchart
8 changes: 4 additions & 4 deletions dotnet/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
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 "dotnet.name" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "java.name" . }})
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 "dotnet.name" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "dotnet.name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
You can watch the status of by running 'kubectl get svc -w {{ template "libchart.name" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "libchart.name" . }} -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 "dotnet.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "libchart.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 }}
30 changes: 0 additions & 30 deletions dotnet/templates/_helpers.tpl

This file was deleted.

37 changes: 2 additions & 35 deletions dotnet/templates/cm-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
{{- $hosts := .Values.cert.hosts -}}

{{- if and .Values.istio.enabled (.Values.istio.ingress.enabled) }}
{{ $hosts = .Values.istio.ingress.hosts }}
{{- else if .Values.ingress.enabled }}
{{ $hosts = .Values.ingress.hosts }}
{{- if .Values.cert.enabled -}}
{{- include "libchart.cm-certificate.tpl" . }}
{{- end }}

{{- if and .Values.cert.enabled ($hosts) }}

apiVersion: {{ .Values.certmanagerApiVersion }}
kind: Certificate
metadata:
name: {{ template "dotnet.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
annotations:
{{ toYaml .Values.cert.annotations | indent 4 }}
spec:
{{- if .Values.cert.secretName }}
secretName: {{ .Values.cert.secretName }}
{{- else }}
secretName: {{ template "dotnet.name" . }}
{{- end }}
{{- if .Values.cert.duration }}
duration: {{ .Values.cert.duration }}
{{- end }}
renewBefore: {{ .Values.cert.renewBefore }}
commonName: {{ index $hosts 0 }}
dnsNames:
{{ $hosts | toYaml | indent 4 }}
issuerRef:
name: {{ .Values.cert.issuer | default "letsencrypt-prod" }}
kind: {{ .Values.cert.issuerKind | default "ClusterIssuer" }}
{{- end }}
132 changes: 2 additions & 130 deletions dotnet/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,131 +1,3 @@
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
apiVersion: apps/v1
{{ else }}
apiVersion: apps/v1beta1
{{ if eq .Values.deployKind "deployment" }}
{{- include "libchart.deployment.tpl" . -}}
{{- end }}
kind: Deployment
metadata:
name: {{ template "dotnet.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "dotnet.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "dotnet.metaLabels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | nindent 8 }}
{{- end -}}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range $pullSecret := .Values.image.pullSecrets }}
- name: {{ $pullSecret }}
{{- end }}
{{- end }}
securityContext:
{{ toYaml .Values.securityContext | indent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
{{- if or (.Values.volumeMounts) (.Values.csi) }}
volumeMounts:
{{- if .Values.volumeMounts }}
{{ toYaml .Values.volumeMounts | indent 12 }}
{{- end }}
{{- if .Values.csi }}
- name: {{ .Values.csi.name }}
mountPath: {{ .Values.csi.mountPath | quote }}
readOnly: true
{{- end }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.targetPort | default 8080 }}
protocol: TCP
{{ if .Values.extraPorts }}
{{ toYaml .Values.extraPorts | nindent 12 }}
{{- end }}
{{- if and (.Values.liveness) (.Values.liveness.enabled) }}
livenessProbe:
httpGet:
path: {{ .Values.liveness.path | default "/" }}
port: {{ .Values.liveness.port | default 8080 }}
initialDelaySeconds: {{ .Values.liveness.delay | default 15 }}
timeoutSeconds: {{ .Values.liveness.timeout | default 15 }}
periodSeconds: {{ .Values.liveness.periodSeconds | default 15 }}
{{- end }}
{{- if and (.Values.readiness) (.Values.readiness.enabled) }}
readinessProbe:
httpGet:
path: {{ .Values.readiness.path | default "/" }}
port: {{ .Values.readiness.port | default 8080 }}
initialDelaySeconds: {{ .Values.readiness.delay | default 15 }}
timeoutSeconds: {{ .Values.readiness.timeout | default 15 }}
periodSeconds: {{ .Values.readiness.periodSeconds | default 15 }}
{{- end }}
env:
- name: APP_ENV
value: {{ .Values.appEnv }}
{{- if .Values.secrets }}
{{ toYaml .Values.secrets | indent 10 }}
{{- end }}
{{- if .Values.environment }}
{{ toYaml .Values.environment | indent 10 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}

{{- if or .Values.affinity .Values.podAntiAffinity }}
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if eq .Values.podAntiAffinity "hard" }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "{{ .Values.podAntiAffinityTopologyKey }}"
labelSelector:
matchLabels:
{{- include "dotnet.selectorLabels" . | nindent 18 }}
{{- else if eq .Values.podAntiAffinity "soft" }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
topologyKey: "{{ .Values.podAntiAffinityTopologyKey }}"
labelSelector:
matchLabels:
{{- include "dotnet.selectorLabels" . | nindent 20 }}
{{- end }}
{{- end }}

{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if or (.Values.volumes) (.Values.csi) }}
volumes:
{{- if .Values.volumes }}
{{ toYaml .Values.volumes | indent 8 }}
{{- end }}
{{- if .Values.csi }}
- name: {{ .Values.csi.name }}
persistentVolumeClaim:
claimName: {{ .Values.csi.name }}
{{ end }}
{{ end }}
3 changes: 3 additions & 0 deletions dotnet/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.autoscaling.enabled }}
{{- include "libchart.hpa.tpl" . }}
{{- end }}
39 changes: 1 addition & 38 deletions dotnet/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
{{- if .Values.ingress.enabled -}}
{{- $name := include "dotnet.name" . -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
apiVersion: networking.k8s.io/v1beta1
{{ else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
{{- 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: {{ $name }}
servicePort: http
{{- end }}
{{- include "libchart.ingress.tpl" . -}}
{{- end }}
17 changes: 2 additions & 15 deletions dotnet/templates/pod-disruption-budget.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
{{- if .Values.podDisruptionBudget -}}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: {{ template "dotnet.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ template "dotnet.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Values.appVersion }}
{{ toYaml .Values.podDisruptionBudget | indent 2 }}
{{- end -}}
{{- include "libchart.pdb.tpl" . -}}
{{- end }}
33 changes: 2 additions & 31 deletions dotnet/templates/pv-secrets-store-csi-pv.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
{{- if .Values.csi -}}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.csi.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
spec:
capacity:
storage: {{ .Values.csi.storage | default "10Mi" | quote }}
accessModes:
- ReadOnlyMany
persistentVolumeReclaimPolicy: Retain
storageClassName: {{ .Values.csi.storageClassName | quote}}
csi:
driver: secrets-store.csi.k8s.com
readOnly: true
volumeHandle: kv
volumeAttributes:
providerName: {{ .Values.csi.providerName | quote}}
usePodIdentity: {{ .Values.csi.usePodIdentity | default "false" | quote }}
keyvaultName: {{ .Values.csi.keyvaultName | quote}}
objects: |
array:
{{ toYaml .Values.csi.array | indent 10 }}
resourceGroup: {{ .Values.csi.resourceGroup | quote}}
subscriptionId: {{ .Values.csi.subscriptionId | quote}}
tenantId: {{ .Values.csi.tenantId | quote}}
nodePublishSecretRef:
name: secrets-store-creds
{{- end -}}
{{- include "libchart.pv-secrets-store-csi-pv.tpl" . }}
{{- end -}}
18 changes: 2 additions & 16 deletions dotnet/templates/pv-secrets-store-csi-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
{{- if .Values.csi -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ .Values.csi.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
spec:
accessModes:
- ReadOnlyMany
resources:
requests:
storage: {{ .Values.csi.storage | default "10Mi" | quote }}
volumeName: {{ .Values.csi.name }}
storageClassName: {{ .Values.csi.storageClassName| quote}}
{{- end -}}
{{- include "libchart.pv-secrets-store-csi-pvc.tpl" . }}
{{- end -}}
1 change: 1 addition & 0 deletions dotnet/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "libchart.serviceAccount.tpl" . -}}
20 changes: 1 addition & 19 deletions dotnet/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "dotnet.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort | default "http" }}
protocol: TCP
name: {{ .Values.service.name | default "http" }}
{{ if .Values.service.extraPorts }}
{{ toYaml .Values.service.extraPorts | nindent 4 }}
{{- end }}
selector:
{{- include "dotnet.selectorLabels" . | nindent 4 }}
{{- include "libchart.service.tpl" . -}}
Loading

0 comments on commit 9782bd6

Please sign in to comment.