Add Hazelcast Helm Chart (#6659)

* Add Hazelcast Helm Chart

* Add standard labels and names to RBAC and ConfigMap

* Add filtering by service name and remove the HZ_DATA environment variable

* Add options to set up DNS Lookup Discovery

* Add Role, RoleBinding, and ServiceAccount

* Comment out the default resources

* Use the default .helmignore file

* Change 'apps/v1beta1' to 'apps/v1' in statefulset

* Update values.yaml

* Update README.md

* Change list indendation style to zero spaces

* Remove trailing spaces from values.yaml

* Add missing values to README.md

* Fix typo in NOTES.txt
This commit is contained in:
Rafał Leszko
2018-07-25 08:28:56 -07:00
committed by k8s-ci-robot
parent 2a0fd9884d
commit ee2dd0fae9
13 changed files with 568 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
+22
View File
@@ -0,0 +1,22 @@
name: hazelcast
version: 1.0.0
appVersion: "3.10.2"
description: Hazelcast IMDG is the most widely used in-memory data grid with hundreds of thousands of installed clusters around the world. It offers caching solutions ensuring that data is in the right place when its needed for optimal performance.
keywords:
- hazelcast
- keyvalue
- in-memory
- database
- caching
home: http://hazelcast.com/
icon: http://hazelcast.com/images/logos/HazelcastLogo-Blue_Dark_Icon_200px.png
sources:
- https://github.com/hazelcast/hazelcast
maintainers:
- name: leszko
email: rafal@hazelcast.com
- name: googlielmo
email: guglielmo@hazelcast.com
- name: mesutcelik
email: mesut@hazelcast.com
engine: gotpl
+8
View File
@@ -0,0 +1,8 @@
approvers:
- leszko
- mesutcelik
- googlielmo
reviewers:
- leszko
- mesutcelik
- googlielmo
+122
View File
@@ -0,0 +1,122 @@
# Hazelcast
[Hazelcast IMDG](http://hazelcast.com/) is the most widely used in-memory data grid with hundreds of thousands of installed clusters around the world. It offers caching solutions ensuring that data is in the right place when its needed for optimal performance.
## Quick Start
```bash
$ helm install stable/hazelcast
```
## Introduction
This chart bootstraps a [Hazelcast](https://github.com/hazelcast/hazelcast-docker/tree/master/hazelcast-kubernetes) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Prerequisites
- Kubernetes 1.9+
## Installing the Chart
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release stable/hazelcast
```
The command deploys Hazelcast 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 Hazelcast chart and their default values.
| Parameter | Description | Default |
|--------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `image.repository` | Hazelcast Image name | `hazelcast/hazelcast-kubernetes` |
| `image.tag` | Hazelcast Image tag | `{VERSION}` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.pullSecrets` | Specify docker-registry secret names as an array | `nil` |
| `cluster.memberCount` | Number of Hazelcast members | 2 |
| `hazelcast.rest` | Enable REST endpoints for Hazelcast member | `true` |
| `hazelcast.javaOpts` | Additional JAVA_OPTS properties for Hazelcast member | `nil` |
| `hazelcast.configurationFiles` | Hazelcast configuration files | `{DEFAULT_HAZELCAST_XML}` |
| `nodeSelector` | Hazelcast Node labels for pod assignment | `nil` |
| `livenessProbe.enabled` | Turn on and off liveness probe | `true` |
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | `30` |
| `livenessProbe.periodSeconds` | How often to perform the probe | `10` |
| `livenessProbe.timeoutSeconds` | When the probe times out | `5` |
| `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | `1` |
| `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | `3` |
| `readinessProbe.enabled` | Turn on and off readiness probe | `true` |
| `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | `30` |
| `readinessProbe.periodSeconds` | How often to perform the probe | `10` |
| `readinessProbe.timeoutSeconds` | When the probe times out | `1` |
| `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed | `1` |
| `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | `3` |
| `resources` | CPU/Memory resource requests/limits | `nil` |
| `service.type` | Kubernetes service type ('ClusterIP', 'LoadBalancer', or 'NodePort') | `ClusterIP` |
| `service.port` | Kubernetes service port | `5701` |
| `rbac.create` | Enable installing RBAC Role authorization | `true` |
| `serviceAccount.create` | Enable installing Service Account | `true` |
| `serviceAccount.name` | Name of Service Account, if not set, the name is generated using the fullname template | `nil` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```bash
$ helm install --name my-release \
--set cluster.memberCount=3,hazelcast.rest=false \
stable/hazelcast
```
The above command sets number of Hazelcast members to 3 and disables REST endpoints.
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/hazelcast
```
> **Tip**: You can use the default [values.yaml](values.yaml)
## Custom Hazelcast configuration
Custom Hazelcast configuration can be specified inside `values.yaml`, as the `hazelcast.configurationFiles.hazelcast.xml` property.
```yaml
hazelcast:
configurationFiles:
hazelcast.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.10.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties>
<property name="hazelcast.discovery.enabled">true</property>
</properties>
<network>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="false" />
<discovery-strategies>
<discovery-strategy enabled="true" class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
</discovery-strategy>
</discovery-strategies>
</join>
</network>
<!-- Custom Configuration Placeholder -->
</hazelcast>
```
+70
View File
@@ -0,0 +1,70 @@
** Hazelcast cluster is being deployed! **
-------------------------------------------------------------------------------
To access Hazelcast within the Kubernetes cluster:
- Use Hazelcast Client with Kubernetes Discovery Strategy pointing to DNS: {{ template "hazelcast.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local. Read more at: https://github.com/hazelcast/hazelcast-kubernetes.
{{- if .Values.hazelcast.rest }}
- Use REST endpoint:
*) Insert Data:
$ curl -v -X POST -H "Content-Type: text/plain" -d "bar" http://{{ template "hazelcast.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:5701/hazelcast/rest/maps/mapName/foo
*) Get Data:
$ curl http://{{ template "hazelcast.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:5701/hazelcast/rest/maps/mapName/foo
{{- end }}
-------------------------------------------------------------------------------
To access Hazelcast from outside the Kubernetes cluster:
- Use Hazelcast Client with Smart Routing disabled:
{{- if contains "LoadBalancer" .Values.service.type }}
*) Check service external IP:
$ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "hazelcast.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
*) In Hazelcast Client configuration:
clientConfig.getNetworkConfig().setSmartRouting(false);
clientConfig.getNetworkConfig().addAddress("$SERVICE_IP:{{ .Values.service.port }}");
{{- else if contains "ClusterIP" .Values.service.type }}
*) Forward port from POD:
$ export POD=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "hazelcast.name" . }}" -o jsonpath="{.items[0].metadata.name}")
$ kubectl port-forward --namespace {{ .Release.Namespace }} $POD 5701:5701
*) In Hazelcast Client configure:
clientConfig.getNetworkConfig().setSmartRouting(false);
clientConfig.getNetworkConfig().addAddress("127.0.0.1:5701");
{{- else if contains "NodePort" .Values.service.type }}
*) Check Node IP and Port:
$ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
$ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "hazelcast.fullname" . }})
*) In Hazelcast Client configure:
clientConfig.getNetworkConfig().setSmartRouting(false);
clientConfig.getNetworkConfig().addAddress("$NODE_IP:$NODE_PORT");
{{- end }}
{{- if .Values.hazelcast.rest }}
- Use REST endpoint:
{{- if contains "LoadBalancer" .Values.service.type }}
*) Check service external IP:
$ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "hazelcast.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
*) Insert Data:
$ curl -v -X POST -H "Content-Type: text/plain" -d "bar" http://$SERVICE_IP:{{ .Values.service.port }}/hazelcast/rest/maps/mapName/foo
*) Get Data:
$ curl http://$SERVICE_IP:{{ .Values.service.port }}/hazelcast/rest/maps/mapName/foo
{{- else if contains "ClusterIP" .Values.service.type }}
*) Forward port from POD:
$ export POD=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "hazelcast.name" . }}" -o jsonpath="{.items[0].metadata.name}")
$ kubectl port-forward --namespace {{ .Release.Namespace }} $POD 5701:5701
*) Insert Data:
$ curl -v -X POST -H "Content-Type: text/plain" -d "bar" http://127.0.0.1:5701/hazelcast/rest/maps/mapName/foo
*) Get Data:
$ curl http://127.0.0.1:5701/hazelcast/rest/maps/mapName/foo
{{- else if contains "NodePort" .Values.service.type }}
*) Check Node IP and Port:
$ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
$ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "hazelcast.fullname" . }})
*) Insert Data:
$ curl -v -X POST -H "Content-Type: text/plain" -d "bar" http://$NODE_IP:$NODE_PORT/hazelcast/rest/maps/mapName/foo
*) Get Data:
$ curl http://$NODE_IP:$NODE_PORT/hazelcast/rest/maps/mapName/foo
{{- end }}
{{- end }}
+43
View File
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "hazelcast.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 "hazelcast.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 "hazelcast.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "hazelcast.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "hazelcast.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
+16
View File
@@ -0,0 +1,16 @@
{{- if .Values.hazelcast.configurationFiles }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "hazelcast.fullname" . }}-configuration
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
{{- range $key, $val := .Values.hazelcast.configurationFiles }}
{{ $key }}: |-
{{ $val | indent 4}}
{{- end }}
{{- end -}}
+19
View File
@@ -0,0 +1,19 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "hazelcast.fullname" . }}
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.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 "hazelcast.fullname" . }}
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "hazelcast.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "hazelcast.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
+22
View File
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "hazelcast.fullname" . }}
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
selector:
app: {{ template "hazelcast.name" . }}
release: "{{ .Release.Name }}"
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: hazelcast
name: hzport
@@ -0,0 +1,11 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "hazelcast.serviceAccountName" . }}
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- end -}}
@@ -0,0 +1,73 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "hazelcast.fullname" . }}
labels:
app: {{ template "hazelcast.name" . }}
chart: {{ template "hazelcast.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: {{ .Values.cluster.memberCount }}
selector:
matchLabels:
app: {{ template "hazelcast.name" . }}
release: "{{ .Release.Name }}"
template:
metadata:
labels:
app: {{ template "hazelcast.name" . }}
release: "{{ .Release.Name }}"
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end}}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: {{ template "hazelcast.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources | indent 10 }}
ports:
- name: hazelcast
containerPort: 5701
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /hazelcast/health/node-state
port: 5701
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /hazelcast/health/node-state
port: 5701
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
volumeMounts:
- name: hazelcast-storage
mountPath: /data/hazelcast
env:
- name: JAVA_OPTS
value: "-Dhazelcast.rest.enabled={{ .Values.hazelcast.rest }} -Dhazelcast.config=/data/hazelcast/hazelcast.xml -DserviceName={{ template "hazelcast.fullname" . }} {{ .Values.hazelcast.javaOpts }}"
serviceAccountName: {{ template "hazelcast.serviceAccountName" . }}
volumes:
- name: hazelcast-storage
configMap:
name: {{ template "hazelcast.fullname" . }}-configuration
+122
View File
@@ -0,0 +1,122 @@
## Hazelcast image version
## ref: https://hub.docker.com/r/hazelcast/hazelcast-kubernetes/tags/
##
image:
# repository is the Hazelcast image name
repository: "hazelcast/hazelcast-kubernetes"
# tag is the Hazelcast image tag
tag: "3.10.2"
# pullPolicy is the Docker image pull policy
# It's recommended to change this to 'Always' if the image tag is 'latest'
# ref: http://kubernetes.io/docs/user-guide/images/#updating-images
#
pullPolicy: IfNotPresent
# pullSecrets is an array of docker-registry secret names
# Secrets must be manually created in the namespace.
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
# pullSecrets:
# - myRegistryKeySecretName
# Cluster settings
cluster:
# memberCount is the number Hazelcast members
memberCount: 2
# Hazelcast properties
hazelcast:
# rest is a flag used to enable REST endpoints for Hazelcast member
rest: true
# javaOpts are additional JAVA_OPTS properties for Hazelcast member
javaOpts:
# configurationFiles are Hazelcast configuration files
configurationFiles:
hazelcast.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.10.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties>
<property name="hazelcast.discovery.enabled">true</property>
</properties>
<network>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="false" />
<discovery-strategies>
<discovery-strategy enabled="true" class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
<properties>
<property name="service-name">${serviceName}</property>
</properties>
</discovery-strategy>
</discovery-strategies>
</join>
</network>
</hazelcast>
# nodeSelector is an array of Hazelcast Node labels for POD assignments
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}
# Hazelcast Liveness probe
livenessProbe:
# enabled is a flag to used to enable liveness probe
enabled: true
# initialDelaySeconds is a delay before liveness probe is initiated
initialDelaySeconds: 30
# periodSeconds decides how often to perform the probe
periodSeconds: 10
# timeoutSeconds decides when the probe times out
timeoutSeconds: 5
# successThreshold is the minimum consecutive successes for the probe to be considered successful after having failed
successThreshold: 1
# failureThreshold is the minimum consecutive failures for the probe to be considered failed after having succeeded
failureThreshold: 3
# Hazelcast Readiness probe
readinessProbe:
# enabled is a flag to used to enable readiness probe
enabled: true
# initialDelaySeconds is a delay before readiness probe is initiated
initialDelaySeconds: 30
# periodSeconds decides how often to perform the probe
periodSeconds: 10
# timeoutSeconds decides when the probe times out
timeoutSeconds: 1
# successThreshold is the minimum consecutive successes for the probe to be considered successful after having failed
successThreshold: 1
# failureThreshold is the minimum consecutive failures for the probe to be considered failed after having succeeded
failureThreshold: 3
# Configure resource requests and limits
# ref: http://kubernetes.io/docs/user-guide/compute-resources/
#
# resources:
# requests:
# memory: 256Mi
# cpu: 100m
# Hazelcast Service properties
service:
# type defines the Kubernetes service type ('ClusterIP', 'LoadBalancer', or 'NodePort')
type: ClusterIP
# port is the Kubernetes service port
port: 5701
# clusterIP set to None makes the service headless
# It is required if DNS Lookup is used (https://github.com/hazelcast/hazelcast-kubernetes#dns-lookup)
# clusterIP: "None"
# Role-based Access Control
rbac:
# Specifies whether RBAC resources should be created
# It is not required if DNS Lookup is used (https://github.com/hazelcast/hazelcast-kubernetes#dns-lookup)
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: