Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to use libchart approach to avoid code duplication #124

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
path = kiali-operator
url = https://github.com/evry-ace/helm-kiali-operator.git
[submodule "istio-bookinfo"]
path = istio-bookinfo
url = https://github.com/evry-ace/helm-istio-bookinfo.git
path = istio-bookinfo
url = https://github.com/evry-ace/helm-istio-bookinfo.git
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 "libchart.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.

7 changes: 3 additions & 4 deletions dotnet/templates/alert-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "dotnet.name" . }}
namespace: {{ .Release.Namespace }}
name: {{ template "libchart.name" . }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
{{- include "libchart.labels" . | nindent 4 }}
alertmanager: {{ .Values.alertManager | default "default" }}
spec:
groups:
{{ toYaml .Values.alertRules | indent 4 }}
{{ toYaml .Values.alertRules | nindent 4 }}
{{- end }}
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 }}
7 changes: 3 additions & 4 deletions dotnet/templates/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ metadata:
{{- if .Values.istio.gatewayName }}
name: {{ .Values.istio.gatewayName }}
{{- else }}
name: {{ template "dotnet.name" . }}-gateway
name: {{ template "libchart.name" . }}-gateway
{{- end }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "dotnet.metaLabels" . | nindent 4 }}
{{- include "libchart.labels" . | nindent 4 }}
spec:
selector:
istio: {{ .Values.istio.ingressGateway | default "ingressgateway" }} # use Istio default gateway implementation
Expand Down Expand Up @@ -41,7 +40,7 @@ spec:
{{- if .Values.istio.ingress.tls.secretName }}
credentialName: "{{ .Values.istio.ingress.tls.secretName }}"
{{- else }}
credentialName: "{{ template "dotnet.name" . }}"
credentialName: "{{ template "libchart.name" . }}"
{{- end }}
{{- end }}

Expand Down
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 }}
8 changes: 3 additions & 5 deletions dotnet/templates/istio-egress-serviceentry-http.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{- $name := include "dotnet.name" . }}
{{- $labels := include "dotnet.metaLabels" . }}
{{- $namespace := .Release.Namespace}}
{{- $name := include "libchart.name" . }}
{{- $labels := include "libchart.labels" . }}

{{- if .Values.egress }}
{{ range $entry := .Values.egress.http }}
Expand All @@ -9,7 +8,6 @@ apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: "{{ $name }}-{{ $entry.name }}-http"
namespace: {{ $namespace }}
labels:
{{- toYaml $labels | nindent 4 }}
spec:
Expand All @@ -26,4 +24,4 @@ spec:
location: MESH_EXTERNAL
{{- end }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 3 additions & 5 deletions dotnet/templates/istio-egress-serviceentry-https.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{- $name := include "dotnet.name" . }}
{{- $labels := include "dotnet.metaLabels" . }}
{{- $namespace := .Release.Namespace}}
{{- $name := include "libchart.name" . }}
{{- $labels := include "libchart.labels" . }}

{{- if .Values.egress }}
{{ range $entry := .Values.egress.https }}
Expand All @@ -9,7 +8,6 @@ apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: "{{ $name }}-{{ $entry.name }}-https"
namespace: {{ $namespace }}
labels:
{{- toYaml $labels | nindent 4 }}
spec:
Expand All @@ -26,4 +24,4 @@ spec:
location: MESH_EXTERNAL
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading