Skip to content

Commit

Permalink
Initial commit for Terracotta Server OSS helm chart (helm#8273)
Browse files Browse the repository at this point in the history
* Initial commit for Terracotta Server OSS helm chart

Signed-off-by: Anthony Dahanne <[email protected]>

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

Signed-off-by: Anthony Dahanne <[email protected]>

* Better formatting, as suggested during PR review

Signed-off-by: Anthony Dahanne <[email protected]>

* Add RBAC

Signed-off-by: Anthony Dahanne <[email protected]>
  • Loading branch information
anthonydahanne authored and k8s-ci-robot committed Oct 9, 2018
1 parent 90fe99b commit a4e01d5
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 0 deletions.
21 changes: 21 additions & 0 deletions stable/terracotta/.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
17 changes: 17 additions & 0 deletions stable/terracotta/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
8 changes: 8 additions & 0 deletions stable/terracotta/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- anthonydahanne
- henri-tremblay
- ravichaturvedi
reviewers:
- anthonydahanne
- henri-tremblay
- ravichaturvedi
82 changes: 82 additions & 0 deletions stable/terracotta/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions stable/terracotta/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 43 additions & 0 deletions stable/terracotta/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 changes: 33 additions & 0 deletions stable/terracotta/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions stable/terracotta/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}
19 changes: 19 additions & 0 deletions stable/terracotta/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 25 additions & 0 deletions stable/terracotta/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
11 changes: 11 additions & 0 deletions stable/terracotta/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}
57 changes: 57 additions & 0 deletions stable/terracotta/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit a4e01d5

Please sign in to comment.