diff --git a/stable/tomcat/Chart.yaml b/stable/tomcat/Chart.yaml new file mode 100644 index 0000000000..0db89f0cf7 --- /dev/null +++ b/stable/tomcat/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +name: tomcat +description: Deploy a basic tomcat application server with sidecar as web archive container +icon: http://tomcat.apache.org/res/images/tomcat.png +version: 0.1.0 +appVersion: 7.0 +home: https://github.com/yahavb +maintainers: + - name: yahavb + email: ybiran@ananware.systems diff --git a/stable/tomcat/README.md b/stable/tomcat/README.md new file mode 100644 index 0000000000..99b8b8ec41 --- /dev/null +++ b/stable/tomcat/README.md @@ -0,0 +1,86 @@ +# Tomcat + +[Tomcat](http://tomcat.apache.org) is is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. + +## Introduction + +This chart creates a [tomcat application server](http://tomcat.apache.org) Deployment, plus http Services for the server. +The chart offers an optimization for application updates running in a servlet container-type engines like tomcat and [Jboss](http://jbossas.jboss.org). The chart uses the WAR, EAR, and other deployable components outside of the Servlet engine as sidecar container so application upgrades requires the sidecar container image only to be updated and not the Servlet engine as if both would run at the same image. + + +## Prerequisites + +- Kubernetes 1.8+ + +## Provider-specific Prerequisites + + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/tomcat +``` + +This command deploys a tomcat dedicated server with sane defaults. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the tomcat chart and their default values. + +Parameter | Description | Default +------------------------------- | ------------------------------------- | ---------------------------------------------------------- +`image.webarchive.repository` | Sidecar image source repository name | `ananwaresystems/webarchive` +`image.webarchive.tag` | `webarchive` release tag. | `1.0` +`image.tomcat.repository` | Tomact image source repository name | `tomcat` +`image.tomcat.tag` | `tomcat` release tag. | `7.0` +`image.pullPolicy` | Image pull policy | `IfNotPresent` +`deploy.directory` | Webarchive deployment directory | `/usr/local/tomcat/webapps` +`service.name` | Tomcat service name | `http` +`service.externalPort` | Kubernetes service port | `80` +`service.internalPort` | Tomcat front port | `8080` +`service.type` | Kubernetes service type | `LoadBalancer` +`resources` | CPU/Memory resource requests/limits | `{}` +`nodeSelector` | Node affinity | `{}` +`tolerations` | Node tolerations | `{}` + +Refer to [values.yaml](values.yaml) for the full run-down on defaults. These are a mixture of Kubernetes and tomcat-related directives that map to environment variables. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set Values.someval=My Server,ImageTag=1.0 \ + stable/tomcat +``` + +The above command deploys Tomcat dedicated with a server name of `My Server` and docker-tomcat image version `1.0`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/stable +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."* + +## Credits + +[Java Web Application with Tomcat and Sidecar Container](https://github.com/kubernetes/examples/tree/master/staging/javaweb-tomcat-sidecar) diff --git a/stable/tomcat/templates/NOTES.txt b/stable/tomcat/templates/NOTES.txt new file mode 100644 index 0000000000..c863f8b713 --- /dev/null +++ b/stable/tomcat/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + 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 "tomcat.fullname" . }}) + 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 "tomcat.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "tomcat.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') + 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 "tomcat.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 }} diff --git a/stable/tomcat/templates/_helpers.tpl b/stable/tomcat/templates/_helpers.tpl new file mode 100644 index 0000000000..affca097da --- /dev/null +++ b/stable/tomcat/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "tomcat.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- 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" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "tomcat.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/tomcat/templates/appsrv-svc.yaml b/stable/tomcat/templates/appsrv-svc.yaml new file mode 100644 index 0000000000..b6fa0b9b5d --- /dev/null +++ b/stable/tomcat/templates/appsrv-svc.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "tomcat.fullname" . }} + labels: + app: {{ template "tomcat.name" . }} + chart: {{ template "tomcat.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "tomcat.name" . }} + release: {{ .Release.Name }} diff --git a/stable/tomcat/templates/appsrv.yaml b/stable/tomcat/templates/appsrv.yaml new file mode 100644 index 0000000000..af53a05de5 --- /dev/null +++ b/stable/tomcat/templates/appsrv.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "tomcat.fullname" . }} + labels: + app: {{ template "tomcat.name" . }} + chart: {{ template "tomcat.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "tomcat.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "tomcat.name" . }} + release: {{ .Release.Name }} + spec: + volumes: + - name: app-volume + emptyDir: {} + containers: + - name: war + image: {{ .Values.image.webarchive.repository }}:{{ .Values.image.webarchive.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: app-volume + mountPath: /app + - name: {{ .Chart.Name }} + image: {{ .Values.image.tomcat.repository }}:{{ .Values.image.tomcat.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: app-volume + mountPath: {{ .Values.deploy.directory }} + ports: + - containerPort: {{ .Values.service.internalPort }} + hostPort: 8009 + livenessProbe: + exec: + command: + - cat + - /usr/local/tomcat/webapps/sample/index.html + initialDelaySeconds: 15 + periodSeconds: 20 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} diff --git a/stable/tomcat/values.yaml b/stable/tomcat/values.yaml new file mode 100644 index 0000000000..53a6a837dd --- /dev/null +++ b/stable/tomcat/values.yaml @@ -0,0 +1,49 @@ +# Default values for the chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 + +image: + webarchive: + repository: ananwaresystems/webarchive + tag: "1.0" + tomcat: + repository: tomcat + tag: "7.0" + pullPolicy: IfNotPresent + +deploy: + directory: /usr/local/tomcat/webapps + +service: + name: http + type: LoadBalancer + externalPort: 80 + internalPort: 8080 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} +# limits: +# cpu: 100m +# memory: 256Mi +# requests: +# cpu: 100m +# memory: 256Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}