Skip to content

Commit

Permalink
feat: web-app 3.2.x with super-features
Browse files Browse the repository at this point in the history
  • Loading branch information
abdennour committed May 30, 2024
1 parent 8ce39f1 commit 2fb2a9d
Show file tree
Hide file tree
Showing 33 changed files with 915 additions and 567 deletions.
3 changes: 3 additions & 0 deletions charts/web-app/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies: []
digest: sha256:643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726
generated: "2024-05-30T21:36:36.73281+03:00"
17 changes: 10 additions & 7 deletions charts/web-app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apiVersion: v2
name: webapp
name: web-app
description: |
A Helm chart to install any web application that requires
a single deployment(pod), with a single container.
This is a very generic helm chart that allows you deploy any Web Application
with couple of features like Observability (APM, PBD, ..etc) like persistence
It allow you also to switch between Pod controllers easilty: Deployment, Statefulset,...etc
icon: https://raw.githubusercontent.com/ElmCompany/helm-charts/master/assets/icons/generic-app.png
keywords:
- webapp
- web-app
- pod
- route
- web
Expand All @@ -15,7 +17,8 @@ keywords:
- openshift
- ocp3
- openshift3
- elm
- apm
- openshift4
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -29,12 +32,12 @@ 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.2.1
version: 3.2.15

# 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.
appVersion: latest
appVersion: 1.16.0
dependencies: []

sources:
Expand Down
8 changes: 4 additions & 4 deletions charts/web-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ If so, this chart should answer your needs.

# Values

Check default Values of this chart [here](https://github.com/ElmCompany/helm-charts/blob/master/charts/webapp/values.yaml)
Check default Values of this chart [here](https://github.com/ElmCompany/helm-charts/blob/master/charts/web-app/values.yaml))

# How to install the app

**Set Elm Repo**
```sh
helm repo add elm https://raw.githubusercontent.com/ElmCompany/helm-charts/gh-pages
helm repo update
-helm repo update
```

**Use it** `helm install elm/webapp`
Also this helm chart requires a Helm release name in this format:
`{project}-{app}-{environment}` where environment is "ci", "dev", "qa","staging" or "prod"

# Authors

Expand Down
32 changes: 6 additions & 26 deletions charts/web-app/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,24 @@
{{- end }}
1. Get the application URL by running these commands:
{{- if .Values.route.enabled }}
app is accessible at https://{{ include "webapp.host" . }}
app is accessible at https://{{ include "web-app.host" . }}
{{- end }}
{{- if contains "NodePort" .Values.service.type -}}
export NODE_PORT=$({{ $kubeclient }} get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "webapp.fullname" . }})
export NODE_PORT=$({{ $kubeclient }} get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "web-app.fullname" . }})
export NODE_IP=$({{ $kubeclient }} 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 '{{ $kubeclient }} get --namespace {{ .Release.Namespace }} svc -w {{ include "webapp.fullname" . }}'
export SERVICE_IP=$({{ $kubeclient }} get svc --namespace {{ .Release.Namespace }} {{ include "webapp.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running '{{ $kubeclient }} get --namespace {{ .Release.Namespace }} svc -w {{ include "web-app.fullname" . }}'
export SERVICE_IP=$({{ $kubeclient }} get svc --namespace {{ .Release.Namespace }} {{ include "web-app.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$({{ $kubeclient }} get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "webapp.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$({{ $kubeclient }} get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "web-app.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
{{ $kubeclient }} --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

{{- if .Values.envVarsSealed }}
You are providing values for "envVarsSealed":
Make sure that you encrypted it in the right way:
{{- if eq .Values.sealScope "cluster-wide" }}
echo -n YOUR_CLEAR_VALUE | \
kubeseal --cert https://seal.dev-apps.elm.sa/v1/cert.pem \
--raw --from-file=/dev/stdin \
--scope cluster-wide
{{- else if eq .Values.sealScope "namespace-wide" }}
echo -n YOUR_CLEAR_VALUE | \
kubeseal --cert https://seal.dev-apps.elm.sa/v1/cert.pem \
--raw --from-file=/dev/stdin \
--scope namespace-wide \
--namespace {{ .Release.Namespace }}
{{- else if eq .Values.sealScope "strict" }}
echo -n YOUR_CLEAR_VALUE | \
kubeseal --cert https://seal.dev-apps.elm.sa/v1/cert.pem \
--raw --from-file=/dev/stdin \
--scope namespace-wide \
--namespace {{ .Release.Namespace }} \
--name {{ include "webapp.fullname" . }}-env-vars-sealed
{{- end }}

Make sure that you encrypted it in the right way
{{- end }}
48 changes: 48 additions & 0 deletions charts/web-app/templates/_apm_pod_chunks.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- define "web-app.apmRuntimeDefined" }}
{{- if and .Values.apm.enabled (not (has .Values.apm.runtime .Values.apmProvider.supportedRuntimes)) }}
{{- fail (printf ".Values.apm.runtime must be set . Choose Value from the following: %s" (.Values.apmProvider.supportedRuntimes | join "|")) }}
{{- end }}
{{- end }}

{{- define "web-app.apmEnvFrom" -}}
- configMapRef:
name: apm-{{ include "web-app.fullname" . }}
- secretRef:
name: apm-{{ include "web-app.fullname" . }}
{{- end -}}

{{- define "web-app.apmInitContainers" -}}
- name: apm-init
image: {{printf "%s/cloudnative/sidecar-elastic-apm-agent:%s" .Values.image.registry .Values.apm.imageTag }}
command:
- sh
- -c
- >-
cp -r /agents/* /tmp/apm-agents/;
volumeMounts:
- name: apm-agents
# /elastic-apm-agent.jar
mountPath: /tmp/apm-agents
{{- end -}}

{{- define "web-app.apmVolumeMounts" -}}
- name: apm-agents
mountPath: "{{ include "web-app.apmAgentMountPath" . }}"
{{- end -}}

{{- define "web-app.apmVolumes" -}}
- name: apm-agents
emptyDir: {}
{{- end -}}

{{- define "web-app.apmAgentMountPath" }}
{{- printf "/tmp/apm-agents" }}
{{- end }}

{{- define "web-app.apmJavaOpts" }}
{{- if .Values.envVars.JAVA_OPTS }}
{{- printf "-javaagent:%s/elastic-apm-agent.jar %s" (include "web-app.apmAgentMountPath" . ) (.Values.envVars.JAVA_OPTS | trim) }}
{{- else }}
{{- printf "-javaagent:%s/elastic-apm-agent.jar" (include "web-app.apmAgentMountPath" . ) }}
{{- end }}
{{- end }}
Loading

0 comments on commit 2fb2a9d

Please sign in to comment.