Initial commit for Terracotta Server OSS helm chart (#8273)

* Initial commit for Terracotta Server OSS helm chart

Signed-off-by: Anthony Dahanne <anthony.dahanne@gmail.com>

* Add new line character at end of file, to pass validation

Signed-off-by: Anthony Dahanne <anthony.dahanne@gmail.com>

* Better formatting, as suggested during PR review

Signed-off-by: Anthony Dahanne <anthony.dahanne@gmail.com>

* Add RBAC

Signed-off-by: Anthony Dahanne <anthony.dahanne@gmail.com>
This commit is contained in:
Anthony Dahanne
2018-10-09 12:12:58 -07:00
committed by k8s-ci-robot
parent 90fe99b03c
commit a4e01d5b03
13 changed files with 412 additions and 0 deletions
+21
View File
@@ -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
+17
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
approvers:
- anthonydahanne
- henri-tremblay
- ravichaturvedi
reviewers:
- anthonydahanne
- henri-tremblay
- ravichaturvedi
+82
View File
@@ -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)
+13
View File
@@ -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 }}
+43
View File
@@ -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 -}}
+33
View File
@@ -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: |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tc-config xmlns="http://www.terracotta.org/config">
<plugins>
<config>
<ohr:offheap-resources xmlns:ohr="http://www.terracotta.org/config/offheap-resource">
{{- range .Values.offheaps }}
<ohr:resource name="{{ .name }}" unit="{{ .unit }}">{{ .size }}</ohr:resource>
{{- end}}
</ohr:offheap-resources>
</config>
</plugins>
<servers>
{{ range $i := until (int .Values.replicaCount) }}
<server host="{{ template "terracotta.fullname" $root}}-{{ $i }}.{{ template "terracotta.fullname" $root}}" name="{{ template "terracotta.fullname" $root}}-{{ $i }}" bind="0.0.0.0">
<logs>stdout:</logs>
<tsa-port bind="0.0.0.0">9410</tsa-port>
<tsa-group-port bind="0.0.0.0">9430</tsa-group-port>
</server>
{{ end }}
</servers>
</tc-config>
+19
View File
@@ -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 -}}
@@ -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 }}
+25
View File
@@ -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 }}"
@@ -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 -}}
@@ -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
+64
View File
@@ -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: