Skip to content

Commit

Permalink
Merge pull request #158 from openinfradev/add-tomcat-chart
Browse files Browse the repository at this point in the history
add bitnami tomcat chart for appserving service
  • Loading branch information
robertchoi80 authored Dec 12, 2022
2 parents ef1b665 + 3df88e6 commit eb021db
Show file tree
Hide file tree
Showing 22 changed files with 2,016 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tomcat/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions tomcat/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.2.1
digest: sha256:6c67cfa9945bf608209d4e2ca8f17079fca4770907c7902d984187ab5b21811e
generated: "2022-11-25T14:11:32.087181112Z"
29 changes: 29 additions & 0 deletions tomcat/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
annotations:
category: ApplicationServer
apiVersion: v2
appVersion: 10.1.4
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 2.x.x
description: Apache Tomcat is an open-source web server designed to host and run Java-based web applications. It is a lightweight server with a good performance for applications running in production environments.
engine: gotpl
home: https://github.com/bitnami/charts/tree/main/bitnami/tomcat
icon: https://bitnami.com/assets/stacks/tomcat/img/tomcat-stack-220x234.png
keywords:
- tomcat
- java
- http
- web
- application server
- jsp
maintainers:
- name: Bitnami
url: https://github.com/bitnami/charts
name: tomcat
sources:
- https://github.com/bitnami/containers/tree/main/bitnami/tomcat
- http://tomcat.apache.org
version: 10.5.6
405 changes: 405 additions & 0 deletions tomcat/README.md

Large diffs are not rendered by default.

Binary file added tomcat/charts/common-2.2.1.tgz
Binary file not shown.
50 changes: 50 additions & 0 deletions tomcat/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}

** Please be patient while the chart is being deployed **

{{- if .Values.ingress.enabled }}

1. Get the Tomcat URL and associate its hostname to your cluster external IP:

export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
echo "Tomcat URL: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }}"
echo "$CLUSTER_IP {{ .Values.ingress.hostname }}" | sudo tee -a /etc/hosts

{{- else }}

1. Get the Tomcat URL by running:

{{- if contains "NodePort" .Values.service.type }}

export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo "Tomcat URL: http://$NODE_IP:$NODE_PORT"
echo "Tomcat Management URL: http://$NODE_IP:$NODE_PORT/manager"

{{- else if contains "LoadBalancer" .Values.service.type }}

NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "common.names.fullname" . }}'

export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
{{- $port:=.Values.service.ports.http | toString }}
echo "Tomcat URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.ports.http }}{{ end }}/"
echo "Tomcat Management URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.ports.http }}{{ end }}/manager"

{{- else if contains "ClusterIP" .Values.service.type }}

kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "common.names.fullname" . }} 8080:{{ .Values.service.ports.http }} &
echo "Tomcat URL: http://127.0.0.1:8080/"
echo "Tomcat Management URL: http://127.0.0.1:8080/manager"

{{- end }}
{{- end }}

2. Login with the following credentials

echo Username: {{ .Values.tomcatUsername }}
echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "common.names.fullname" . }} -o jsonpath="{.data.tomcat-password}" | base64 -d)

{{- include "tomcat.checkRollingTags" . }}
113 changes: 113 additions & 0 deletions tomcat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return the proper Tomcat image name
*/}}
{{- define "tomcat.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the Tomcat ports map
*/}}
{{- define "tomcat.ports" -}}
- port: {{ .Values.containerPorts.http }}
protocol: TCP
{{- range .Values.containerExtraPorts }}
- port: {{ include "common.tplvalues.render" (dict "value" .containerPort "context" $) }}
protocol: TCP
{{- end }}
{{- 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 "tomcat.fullname" -}}
{{- include "common.names.fullname" . -}}
{{- end -}}

{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
{{- define "tomcat.volumePermissions.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "tomcat.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image .Values.metrics.jmx.image) "global" .Values.global) -}}
{{- end -}}

{{/*
Check if there are rolling tags in the images
*/}}
{{- define "tomcat.checkRollingTags" -}}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
{{- define "tomcat.pvc" -}}
{{- coalesce .Values.persistence.existingClaim (include "common.names.fullname" .) -}}
{{- end -}}

{{/*
Return the proper CATALINA_OPTS value
*/}}
{{- define "tomcat.catalinaOpts" -}}
{{- if .Values.metrics.jmx.enabled -}}
{{- default "" (cat .Values.catalinaOpts .Values.metrics.jmx.catalinaOpts) | trim -}}
{{- else -}}
{{- default "" .Values.catalinaOpts | trim -}}
{{- end -}}
{{- end -}}

{{/*
Return the proper JMX exporter image name
*/}}
{{- define "tomcat.metrics.jmx.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.metrics.jmx.image "global" .Values.global) -}}
{{- end -}}

{{/*
Return the tomcat jmx configuration configmap
*/}}
{{- define "tomcat.metrics.jmx.configmapName" -}}
{{- if .Values.metrics.jmx.existingConfigmap -}}
{{- printf "%s" (tpl .Values.metrics.jmx.existingConfigmap $) -}}
{{- else -}}
{{- printf "%s-jmx-configuration" (include "tomcat.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "tomcat.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "tomcat.validateValues.jmxConfig" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}

{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}

{{/*
Check if jmx metrics is enabled, then either metrics.jmx.config or metrics.jmx.existingConfigmap must be set.
*/}}
{{- define "tomcat.validateValues.jmxConfig" -}}
{{- if and .Values.metrics.jmx.enabled (not .Values.metrics.jmx.config) (not .Values.metrics.jmx.existingConfigmap) -}}
tomcat: metrics.jmx.enabled
In order to enable JMX metrics, you also need to provide
the prometheus/jmx_exporter configuration or
provide an existing ConfigMap.
{{- end -}}
{{- end -}}
Loading

0 comments on commit eb021db

Please sign in to comment.