From a4e01d5b034174d03418dc60b1333b334c45e8d7 Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Tue, 9 Oct 2018 15:12:58 -0400 Subject: [PATCH] Initial commit for Terracotta Server OSS helm chart (#8273) * Initial commit for Terracotta Server OSS helm chart Signed-off-by: Anthony Dahanne * Add new line character at end of file, to pass validation Signed-off-by: Anthony Dahanne * Better formatting, as suggested during PR review Signed-off-by: Anthony Dahanne * Add RBAC Signed-off-by: Anthony Dahanne --- stable/terracotta/.helmignore | 21 +++++ stable/terracotta/Chart.yaml | 17 ++++ stable/terracotta/OWNERS | 8 ++ stable/terracotta/README.md | 82 +++++++++++++++++++ stable/terracotta/templates/NOTES.txt | 13 +++ stable/terracotta/templates/_helpers.tpl | 43 ++++++++++ stable/terracotta/templates/config.yaml | 33 ++++++++ stable/terracotta/templates/role.yaml | 19 +++++ stable/terracotta/templates/rolebinding.yaml | 19 +++++ stable/terracotta/templates/service.yaml | 25 ++++++ .../terracotta/templates/serviceaccount.yaml | 11 +++ stable/terracotta/templates/statefulset.yaml | 57 +++++++++++++ stable/terracotta/values.yaml | 64 +++++++++++++++ 13 files changed, 412 insertions(+) create mode 100644 stable/terracotta/.helmignore create mode 100644 stable/terracotta/Chart.yaml create mode 100644 stable/terracotta/OWNERS create mode 100644 stable/terracotta/README.md create mode 100644 stable/terracotta/templates/NOTES.txt create mode 100644 stable/terracotta/templates/_helpers.tpl create mode 100644 stable/terracotta/templates/config.yaml create mode 100644 stable/terracotta/templates/role.yaml create mode 100644 stable/terracotta/templates/rolebinding.yaml create mode 100644 stable/terracotta/templates/service.yaml create mode 100644 stable/terracotta/templates/serviceaccount.yaml create mode 100644 stable/terracotta/templates/statefulset.yaml create mode 100644 stable/terracotta/values.yaml diff --git a/stable/terracotta/.helmignore b/stable/terracotta/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/terracotta/.helmignore @@ -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 diff --git a/stable/terracotta/Chart.yaml b/stable/terracotta/Chart.yaml new file mode 100644 index 0000000000..992ec8103e --- /dev/null +++ b/stable/terracotta/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +name: terracotta +version: 1.0.0 +appVersion: "5.5.1" +description: Terracotta Ehcache is an improved version of Java's de facto caching API, Ehcache. It has a powerful, streamlined, modernized caching API taking advantage of newer Java features as well as the capability to be used via the JSR-107 "JCache" API. +keywords: + - terracotta + - jcache + - in-memory + - caching +home: http://www.terracotta.org/ +icon: http://www.terracotta.org/wp-content/themes/terracotta/library/images/logo.png +sources: + - https://github.com/Terracotta-OSS +maintainers: + - name: anthonydahanne + email: anthonydahanne@softwareag.com diff --git a/stable/terracotta/OWNERS b/stable/terracotta/OWNERS new file mode 100644 index 0000000000..34e87d9a94 --- /dev/null +++ b/stable/terracotta/OWNERS @@ -0,0 +1,8 @@ +approvers: +- anthonydahanne +- henri-tremblay +- ravichaturvedi +reviewers: +- anthonydahanne +- henri-tremblay +- ravichaturvedi \ No newline at end of file diff --git a/stable/terracotta/README.md b/stable/terracotta/README.md new file mode 100644 index 0000000000..1ed374f4dd --- /dev/null +++ b/stable/terracotta/README.md @@ -0,0 +1,82 @@ +# Terracotta + +The [Terracotta 5.x OSS](http://www.terracotta.org/) offering includes the following: + + * Ehcache 3.x compatibility + * Distributed In-Memory Data Management with fault-tolerance via Terracotta Server (1 stripe – active with optional mirror) + * In memory off-heap storage - take advantage of all the RAM in your server + + +## Quick Start + +```bash +$ helm install stable/terracotta +``` + +## Introduction + +This chart bootstraps a [Terracotta server](https://github.com/Terracotta-OSS/docker) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.10+ + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/terracotta +``` + +The command deploys Terracotta on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **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 Terracotta chart and their default values. + +| Parameter | Description | Default | +|--------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------| +| `image.repository` | Terracotta Image name | `terracotta/terracotta-server-oss` | +| `image.tag` | Terracotta Image tag | `{VERSION}` | +| `image.pullPolicy` | Image pull policy | `Always` | +| `replicaCount` | Number of Terracotta members | 2 | +| `offheaps` | Offheap resource defintions, as a list of {name, size, unit} | `[{offheap-1, 512, MB}, {offheap-2, 256, MB}]` | +| `nodeSelector` | Terracotta Node labels for pod assignment | `nil` | +| `resources` | CPU/Memory resource requests/limits | `nil` | +| `service.type` | Kubernetes service type ('ClusterIP', 'LoadBalancer', or 'NodePort') | `ClusterIP` | +| `service.clusterIP` | Kubernetes service ClusterIP | `None` | +| `service.terracottaPort` | Kubernetes main service port | `9410` | +| `service.syncPort` | Kubernetes sync service port | `9430` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +helm install --dry-run --name my-release --set replicaCount=4 --debug stable/terracotta + +```bash +$ helm install --name my-release \ + --set replicaCount=3 --set offheaps[0].name=otherOffheap --set offheaps[0].unit=GB --set offheaps[0].size=6 \ + stable/terracotta +``` + +The above command sets number of Terracotta nodes to 3, and it defines just 1 offheap resource named otherOffheap, 6 GB large + +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/terracotta +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/stable/terracotta/templates/NOTES.txt b/stable/terracotta/templates/NOTES.txt new file mode 100644 index 0000000000..f7fb124367 --- /dev/null +++ b/stable/terracotta/templates/NOTES.txt @@ -0,0 +1,13 @@ +** Terracotta cluster is being deployed! ** + +------------------------------------------------------------------------------- + +To access your Terracotta cluster from within the Kubernetes cluster: + +Configure your Ehcache3 client with the following Terracotta URL : terracotta://{{ template "terracotta.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + +For example, you can deploy the sample ehcache client with : + +kubectl run ehcache-sample --image={{ .Values.sampleEhcacheClientImage.repository }}:{{ .Values.sampleEhcacheClientImage.tag }} --env="TERRACOTTA_SERVER_URL={{ template "terracotta.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local" + +You can get more info on {{ .Values.website }} \ No newline at end of file diff --git a/stable/terracotta/templates/_helpers.tpl b/stable/terracotta/templates/_helpers.tpl new file mode 100644 index 0000000000..e0b60b9b8e --- /dev/null +++ b/stable/terracotta/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "terracotta.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 "terracotta.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 "terracotta.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "terracotta.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "terracotta.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stable/terracotta/templates/config.yaml b/stable/terracotta/templates/config.yaml new file mode 100644 index 0000000000..787d2122d2 --- /dev/null +++ b/stable/terracotta/templates/config.yaml @@ -0,0 +1,33 @@ +{{- $root := . -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "terracotta.fullname" . }}-configuration + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + tc-config.xml: | + + + + + + {{- range .Values.offheaps }} + {{ .size }} + {{- end}} + + + + + {{ range $i := until (int .Values.replicaCount) }} + + stdout: + 9410 + 9430 + + {{ end }} + + diff --git a/stable/terracotta/templates/role.yaml b/stable/terracotta/templates/role.yaml new file mode 100644 index 0000000000..afef179f0b --- /dev/null +++ b/stable/terracotta/templates/role.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ template "terracotta.fullname" . }} + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +rules: +- apiGroups: + - "" + resources: + - endpoints + verbs: + - get + - list +{{- end -}} diff --git a/stable/terracotta/templates/rolebinding.yaml b/stable/terracotta/templates/rolebinding.yaml new file mode 100644 index 0000000000..d6b6dc1ebd --- /dev/null +++ b/stable/terracotta/templates/rolebinding.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ template "terracotta.fullname" . }} + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ template "terracotta.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "terracotta.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{ end }} diff --git a/stable/terracotta/templates/service.yaml b/stable/terracotta/templates/service.yaml new file mode 100644 index 0000000000..70f084f1de --- /dev/null +++ b/stable/terracotta/templates/service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "terracotta.fullname" . }} + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + # see https://github.com/kubernetes/kubernetes/issues/39363 , to have dns entries available immediately + service.alpha.kubernetes.io/tolerate-unready-endpoints: "{{ .Values.tolerateUnreadyEndpoints }}" +spec: + type: {{ .Values.service.type }} + {{- if .Values.service.clusterIP }} + clusterIP: {{ .Values.service.clusterIP }} + {{- end }} + ports: + - name: terracotta-port + port: {{ .Values.service.terracottaPort }} + - name: sync-port + port: {{ .Values.service.syncPort }} + selector: + app: {{ template "terracotta.name" . }} + release: "{{ .Release.Name }}" diff --git a/stable/terracotta/templates/serviceaccount.yaml b/stable/terracotta/templates/serviceaccount.yaml new file mode 100644 index 0000000000..09f916c159 --- /dev/null +++ b/stable/terracotta/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "terracotta.serviceAccountName" . }} + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +{{- end -}} diff --git a/stable/terracotta/templates/statefulset.yaml b/stable/terracotta/templates/statefulset.yaml new file mode 100644 index 0000000000..17258fccb7 --- /dev/null +++ b/stable/terracotta/templates/statefulset.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ template "terracotta.fullname" . }} + labels: + app: {{ template "terracotta.name" . }} + chart: {{ template "terracotta.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "terracotta.name" . }} + release: "{{ .Release.Name }}" + serviceName: {{ template "terracotta.fullname" . }} + template: + metadata: + labels: + app: {{ template "terracotta.name" . }} + release: "{{ .Release.Name }}" + spec: + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + initContainers: + # be careful with busybox versions : https://github.com/docker-library/busybox/issues/48 + - name: init-{{ template "terracotta.fullname" . }} + image: busybox:1.28 + # check service name resolution works fine; if it can't resolve the service, a split brain could occur + command: ['sh', '-c', 'until nslookup {{ include "terracotta.fullname" . }}; do echo "waiting for {{ include "terracotta.fullname" . }} to resolve"; sleep 2; done;'] + containers: + - name: {{ template "terracotta.fullname" . }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy | quote }} + command: ["bin/start-tc-server.sh"] + args: ["-f", "/config/tc-config.xml", "-n", "$(POD_NAME)"] + resources: +{{ toYaml .Values.resources | indent 10 }} + ports: + - name: terracotta-port + containerPort: 9410 + - name: sync-port + containerPort: 9430 + volumeMounts: + - name: config-volume + mountPath: /config + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + volumes: + - name: config-volume + configMap: + name: {{ template "terracotta.fullname" . }}-configuration diff --git a/stable/terracotta/values.yaml b/stable/terracotta/values.yaml new file mode 100644 index 0000000000..2ebc9ad552 --- /dev/null +++ b/stable/terracotta/values.yaml @@ -0,0 +1,64 @@ +# Terracotta Image definitions are available at : https://github.com/Terracotta-OSS/docker + +image: + repository: terracotta/terracotta-server-oss + tag: 5.5.1 + pullPolicy: Always + +website: "https://github.com/Terracotta-OSS/docker" + +sampleEhcacheClientImage: + repository: terracotta/sample-ehcache-client + tag: 5.5.1 + + +replicaCount: 2 + +# specify as many offheap resources as you want; provided you have enough resources on the node +# and you have caching clients using those resources for their clustered tiers ! +offheaps: + - name: offheap-1 + unit: MB + size: 512 + - name: offheap-2 + unit: MB + size: 256 + + +service: + type: ClusterIP + terracottaPort: 9410 + syncPort: 9430 + # None is headless service; still useful for the StatefulSet that relies on it + clusterIP: "None" + +tolerateUnreadyEndpoints: true + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: