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

Refactor/Use fullname for variable instead of ejbca-community-helm #13

Merged
merged 2 commits into from
May 15, 2024
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
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "1.0.3"
version: "1.0.4"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "8.0.0"
appVersion: "8.2.0.1"
26 changes: 13 additions & 13 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Define the EJBCA deployment parameters
*/}}
{{- define "ejbca-community-helm.ejbcaDeploymentParameters" -}}
{{- define "ejbca.ejbcaDeploymentParameters" -}}
{{- if .Values.ejbca.useEphemeralH2Database }}
- name: DATABASE_JDBC_URL
value: "jdbc:h2:mem:ejbcadb;DB_CLOSE_DELAY=-1"
Expand All @@ -23,7 +23,7 @@ Define the EJBCA deployment parameters
{{/*
Define port that EJBCA redirects for HTTPS
*/}}
{{- define "ejbca-community-helm.ejbcaHttpsPort" -}}
{{- define "ejbca.ejbcaHttpsPort" -}}
{{- if .Values.nginx.service.enabled }}
{{- .Values.nginx.service.httpsPort }}
{{- else if .Values.services.directHttp.enabled }}
Expand All @@ -36,7 +36,7 @@ Define port that EJBCA redirects for HTTPS
{{/*
Define port that EJBCA redirects for HTTP
*/}}
{{- define "ejbca-community-helm.ejbcaPubhttpPort" -}}
{{- define "ejbca.ejbcaPubhttpPort" -}}
{{- if .Values.nginx.service.enabled }}
{{- .Values.nginx.service.httpPort }}
{{- else if .Values.services.directHttp.enabled }}
Expand All @@ -49,7 +49,7 @@ Define port that EJBCA redirects for HTTP
{{/*
Expand the name of the chart.
*/}}
{{- define "ejbca-community-helm.name" -}}
{{- define "ejbca.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -58,7 +58,7 @@ 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 "ejbca-community-helm.fullname" -}}
{{- define "ejbca.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -74,16 +74,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ejbca-community-helm.chart" -}}
{{- define "ejbca.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ejbca-community-helm.labels" -}}
helm.sh/chart: {{ include "ejbca-community-helm.chart" . }}
{{ include "ejbca-community-helm.selectorLabels" . }}
{{- define "ejbca.labels" -}}
helm.sh/chart: {{ include "ejbca.chart" . }}
{{ include "ejbca.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -93,17 +93,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "ejbca-community-helm.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ejbca-community-helm.name" . }}
{{- define "ejbca.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ejbca.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ejbca-community-helm.serviceAccountName" -}}
{{- define "ejbca.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ejbca-community-helm.fullname" .) .Values.serviceAccount.name }}
{{- default (include "ejbca.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
26 changes: 13 additions & 13 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ejbca-community-helm.fullname" . }}
name: {{ include "ejbca.fullname" . }}
labels:
{{- include "ejbca-community-helm.labels" . | nindent 4 }}
{{- include "ejbca.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
# Adding for stateful set coming in a later PR
#{{- if eq .Values.services.proxyHttp.type "LoadBalancer" }}
#serviceName: {{ include "ejbca-community-helm.fullname" . }}
#serviceName: {{ include "ejbca.fullname" . }}
#{{- end }}
selector:
matchLabels:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 6 }}
{{- include "ejbca.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 8 }}
{{- include "ejbca.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ejbca-community-helm.serviceAccountName" . }}
serviceAccountName: {{ include "ejbca.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if or .Values.nginx.enabled .Values.ejbca.initContainers }}
initContainers:
{{- if .Values.nginx.enabled }}
- name: {{ .Chart.Name }}-init
- name: {{ template "ejbca.fullname" . }}-init
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env: {{- include "ejbca-community-helm.ejbcaDeploymentParameters" . | nindent 12 }}
env: {{- include "ejbca.ejbcaDeploymentParameters" . | nindent 12 }}
command:
- "/bin/sh"
- "-c"
Expand Down Expand Up @@ -70,7 +70,7 @@ spec:
{{- end }}
containers:
{{- if .Values.nginx.enabled }}
- name: {{ .Chart.Name }}-nginx
- name: {{ template "ejbca.fullname" . }}-nginx
image: nginx:alpine
ports:
- name: nginx-http
Expand All @@ -90,12 +90,12 @@ spec:
- name: nginx-cert
mountPath: /etc/nginx/ssl/
{{- end }}
- name: {{ .Chart.Name }}
- name: {{ template "ejbca.fullname" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env: {{- include "ejbca-community-helm.ejbcaDeploymentParameters" . | nindent 12 }}
env: {{- include "ejbca.ejbcaDeploymentParameters" . | nindent 12 }}
{{- if .Values.services.proxyAJP.enabled }}
- name: PROXY_AJP_BIND
value: {{ .Values.services.proxyAJP.bindIP }}
Expand All @@ -112,8 +112,8 @@ spec:
- "-c"
- |
{{- if not .Values.ejbca.importEjbcaConfFiles }}
sed -i s/https=443/https={{- include "ejbca-community-helm.ejbcaHttpsPort" . -}}/g /opt/primekey/ejbca/conf/web.properties
sed -i s/pubhttp=80/pubhttp={{- include "ejbca-community-helm.ejbcaPubhttpPort" . -}}/g /opt/primekey/ejbca/conf/web.properties
sed -i s/https=443/https={{- include "ejbca.ejbcaHttpsPort" . -}}/g /opt/primekey/ejbca/conf/web.properties
sed -i s/pubhttp=80/pubhttp={{- include "ejbca.ejbcaPubhttpPort" . -}}/g /opt/primekey/ejbca/conf/web.properties
{{- end }}
{{- if and (hasKey .Values.ejbca "superadminPasswordOverride") (eq .Values.ejbca.env.TLS_SETUP_ENABLED "true") }}
until [ -f /opt/keyfactor/appserver/standalone/deployments/ejbca.ear.deployed ]; do sleep 5; done
Expand Down
6 changes: 3 additions & 3 deletions templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "ejbca-community-helm.fullname" . }}
name: {{ include "ejbca.fullname" . }}
labels:
{{- include "ejbca-community-helm.labels" . | nindent 4 }}
{{- include "ejbca.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "ejbca-community-helm.fullname" . }}
name: {{ include "ejbca.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
4 changes: 2 additions & 2 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "ejbca-community-helm.fullname" . -}}
{{- $fullName := include "ejbca.fullname" . -}}
{{- $svcPort := .Values.services.directHttp.httpPort -}}
{{- if .Values.services.proxyAJP.enabled }}
{{- $svcPort = .Values.services.proxyAJP.port -}}
Expand All @@ -22,7 +22,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "ejbca-community-helm.labels" . | nindent 4 }}
{{- include "ejbca.labels" . | nindent 4 }}
annotations:
{{- if .Values.services.proxyAJP.enabled }}
nginx.ingress.kubernetes.io/backend-protocol: "AJP"
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ spec:
targetPort: nginx-https
protocol: TCP
selector:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 4 }}
{{- include "ejbca.selectorLabels" . | nindent 4 }}
{{- end }}
4 changes: 2 additions & 2 deletions templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ejbca-community-helm.serviceAccountName" . }}
name: {{ include "ejbca.serviceAccountName" . }}
labels:
{{- include "ejbca-community-helm.labels" . | nindent 4 }}
{{- include "ejbca.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
10 changes: 5 additions & 5 deletions templates/services.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "ejbca-community-helm.fullname" . }}
name: {{ include "ejbca.fullname" . }}
labels:
{{- include "ejbca-community-helm.labels" . | nindent 4 }}
{{- include "ejbca.labels" . | nindent 4 }}
{{- if .Values.services.directHttp.enabled }}
spec:
type: {{ .Values.services.directHttp.type }}
Expand All @@ -26,7 +26,7 @@ spec:
{{- toYaml .Values.services.sidecarPorts | nindent 4 }}
{{- end }}
selector:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 4 }}
{{- include "ejbca.selectorLabels" . | nindent 4 }}
{{- end }}
{{- if .Values.services.proxyAJP.enabled }}
spec:
Expand All @@ -40,7 +40,7 @@ spec:
protocol: TCP
name: ajp
selector:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 4 }}
{{- include "ejbca.selectorLabels" . | nindent 4 }}
{{- end }}
{{- if .Values.services.proxyHttp.enabled }}
spec:
Expand Down Expand Up @@ -72,5 +72,5 @@ spec:
protocol: TCP
name: proxy-https
selector:
{{- include "ejbca-community-helm.selectorLabels" . | nindent 4 }}
{{- include "ejbca.selectorLabels" . | nindent 4 }}
{{- end }}