From 699515245e4741688c194df4cafa69c53272062a Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Thu, 8 Nov 2018 16:27:11 +0100 Subject: [PATCH 1/6] [bitnami/cassandra] First version --- bitnami/cassandra/.helmignore | 17 ++ bitnami/cassandra/Chart.yaml | 12 ++ bitnami/cassandra/README.md | 129 ++++++++++++ bitnami/cassandra/templates/NOTES.txt | 59 ++++++ bitnami/cassandra/templates/_helpers.tpl | 77 ++++++++ .../cassandra/templates/cassandra-secret.yaml | 20 ++ bitnami/cassandra/templates/headless-svc.yaml | 31 +++ .../cassandra/templates/networkPolicy.yaml | 31 +++ bitnami/cassandra/templates/service.yaml | 27 +++ bitnami/cassandra/templates/statefulset.yaml | 184 ++++++++++++++++++ bitnami/cassandra/values-production.yaml | 174 +++++++++++++++++ bitnami/cassandra/values.yaml | 174 +++++++++++++++++ 12 files changed, 935 insertions(+) create mode 100644 bitnami/cassandra/.helmignore create mode 100644 bitnami/cassandra/Chart.yaml create mode 100644 bitnami/cassandra/README.md create mode 100644 bitnami/cassandra/templates/NOTES.txt create mode 100644 bitnami/cassandra/templates/_helpers.tpl create mode 100644 bitnami/cassandra/templates/cassandra-secret.yaml create mode 100644 bitnami/cassandra/templates/headless-svc.yaml create mode 100644 bitnami/cassandra/templates/networkPolicy.yaml create mode 100644 bitnami/cassandra/templates/service.yaml create mode 100644 bitnami/cassandra/templates/statefulset.yaml create mode 100644 bitnami/cassandra/values-production.yaml create mode 100644 bitnami/cassandra/values.yaml diff --git a/bitnami/cassandra/.helmignore b/bitnami/cassandra/.helmignore new file mode 100644 index 0000000000..5e03def0cf --- /dev/null +++ b/bitnami/cassandra/.helmignore @@ -0,0 +1,17 @@ +# 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 +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +OWNERS diff --git a/bitnami/cassandra/Chart.yaml b/bitnami/cassandra/Chart.yaml new file mode 100644 index 0000000000..dbc19bc05e --- /dev/null +++ b/bitnami/cassandra/Chart.yaml @@ -0,0 +1,12 @@ +name: cassandra +version: 1.0.0 +appVersion: 3.11.3 +description: Apache Cassandra is a free and open-source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients. +icon: https://d33np9n32j53g7.cloudfront.net/assets/stacks/cassandra/img/cassandra-stack-220x234-071ca9e210d165c3972d41ff9f96bd60.png +sources: +- https://github.com/bitnami/bitnami-docker-cassandra +home: http://cassandra.apache.org +maintainers: +- name: Bitnami + email: containers@bitnami.com +engine: gotpl diff --git a/bitnami/cassandra/README.md b/bitnami/cassandra/README.md new file mode 100644 index 0000000000..cdc1e821be --- /dev/null +++ b/bitnami/cassandra/README.md @@ -0,0 +1,129 @@ +# cassandra + +[cassandra](https://cassandra.apache.org) Apache Cassandra is a free and open-source distributed database management system designed to handle large amounts of data across many commodity servers or datacenters. + +## TL;DR; + +```console +$ helm install . +``` + +## Introduction + +This chart bootstraps a [Cassandra](https://github.com/bitnami/bitnami-docker-cassandra) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) for deployment and management of Helm Charts in clusters. + +## Prerequisites + +- Kubernetes 1.8+ +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release ./cassandra +``` + +The command deploys one node with Cassandra 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` petset: + +```console +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the cassandra chart and their default values. + +| Parameter | Description | Default | +|--------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------| +| `global.imageRegistry` | Global Docker image registry | `nil` | +| `image.registry` | Cassandra Image registry | `docker.io` | +| `image.repository` | Cassandra Image name | `bitnami/cassandra` | +| `image.tag` | Cassandra Image tag | `3.11.3` | +| `image.pullPolicy` | Image pull policy | `Always` | +| `image.pullSecrets` | Specify docker-registry secret names as an array | `nil` | +| `service.type` | Kubernetes Service type | `ClusterIP` | +| `service.nodePort` | Kubernetes Service nodePort | `nil` | +| `service.loadBalancerIP` | LoadBalancerIP if service type is `LoadBalancer` | `nil` | +| `service.annotations` | Annotations for the service | {} | +| `persistence.enabled` | Use PVCs to persist data | `true` | +| `persistence.storageClass` | Storage class of backing PVC | `generic` | +| `persistence.annotations` | Annotations for the PVC | {} | +| `persistence.accessModes` | Persistent Volume Access Modes | `[ReadWriteOnce]` | +| `persistence.size` | Size of data volume | `8Gi` | +| `resources` | CPU/Memory resource requests/limits | `{}` | +| `cluster.name` | Cassandra cluster name | `cassandra` | +| `cluster.replicaCount` | Number of cassandra nodes | `1` | +| `cluster.seedCount` | Number of seed nodes (note: must be greater or equal than 1 and less or equal to `cluster.replicaCount`) | `1` | +| `dbUser.user` | Cassandra admin user | `cassandra` | +| `dbUser.forcePassword` | Force the user to provide a non-empty password for `dbUser.user` | `false` | +| `dbUser.password` | Password for `dbUser.user`. Randomly generated if empty | (Random generated) | +| `dbUser.existingSecret` | Use an existing secret object for `dbUser.user` password (will ignore `dbUser.password`) | `` | +| `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 | `30` | +| `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. | `5` | +| `readinessProbe.enabled` | Turn on and off readiness probe | `true` | +| `readinessProbe.initialDelaySeconds`| Delay before readiness probe is initiated | `5` | +| `readinessProbe.periodSeconds` | How often to perform the probe | `10` | +| `readinessProbe.timeoutSeconds` | When the probe times out | `5` | +| `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. | `5` | +| `podAnnotations` | Additional pod annotations | `{}` | +| `podLabels` | Additional pod labels | `{}` | +| `statefulset.updateStrategy` | Update strategy for StatefulSet | onDelete | +| `statefulset.rollingUpdatePartition` | Partition update strategy | `` | +| `securityContext.enabled` | Enable security context | `true` | +| `securityContext.fsGroup` | Group ID for the container | `1001` | +| `securityContext.runAsUser` | User ID for the container | `1001` | +| `affinity` | Enable node/pod affinity | {} | +| `tolerations` | Toleration labels for pod assignment | [] | +| `networkPolicy.enabled` | Enable NetworkPolicy | `false` | +| `networkPolicy.allowExternal` | Don't require client label for connections | `true` | +| `metrics.enabled` | Start a side-car prometheus exporter | `false` | +| `metrics.image.registry` | Cassandra exporter image registry | `docker.io` | +| `metrics.image.repository` | Cassandra exporter image name | `criteo/cassandra_exporter` | +| `metrics.image.tag` | Cassandra exporter image tag | `2.0.4` | +| `metrics.image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `metrics.image.pullSecrets` | Specify docker-registry secret names as an array | `nil` | +| `metrics.podAnnotations` | Additional annotations for Metrics exporter | `{prometheus.io/scrape: "true", prometheus.io/port: "8080"}` | +| `metrics.resources` | Exporter resource requests/limit | `{}` | + +The above parameters map to the env variables defined in [bitnami/cassandra](http://github.com/bitnami/bitnami-docker-cassandra). For more information please refer to the [bitnami/cassandra](http://github.com/bitnami/bitnami-docker-cassandra) image documentation. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set cassandraUser=admin,cassandraPassword=password\ + ./cassandra +``` + + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install --name my-release -f values.yaml ./cassandra +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +The [Bitnami cassandra](https://github.com/bitnami/bitnami-docker-cassandra) image stores the cassandra data at the `/bitnami/cassandra` path of the container. + +Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube. +See the [Configuration](#configuration) section to configure the PVC or to disable persistence. diff --git a/bitnami/cassandra/templates/NOTES.txt b/bitnami/cassandra/templates/NOTES.txt new file mode 100644 index 0000000000..1e79d5d590 --- /dev/null +++ b/bitnami/cassandra/templates/NOTES.txt @@ -0,0 +1,59 @@ +** Please be patient while the chart is being deployed ** + +Cassandra can be accessed through the following urls from within the cluster: + + - CQL: {{ template "cassandra.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.cqlPort }} + - Thrift: {{ template "cassandra.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.thriftPort }} + +To get your password run: + + export CASSANDRA_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }} -o jsonpath="{.data.cassandra-password}" | base64 --decode) + +Check the cluster status by running: + + kubectl exec -it --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.name" . }},release={{ .Release.Name }} -o jsonpath='{.items[0].metadata.name}') nodetool status + +To connect to your Cassandra cluster using CQL: + +1. Run a Cassandra pod that you can use as a client: + + kubectl run --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }}-client --rm --tty -i \ + --env CASSANDRA_PASSWORD=$CASSANDRA_PASSWORD \ + {{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "cassandra.name" . }}-client=true" \{{- end }} \ + --image {{ template "cassandra.image" . }} -- bash + +2. Connect using the cqlsh client: + + cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD {{ template "cassandra.fullname" . }} + +{{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }} +Note: Since NetworkPolicy is enabled, only pods with label +{{ template "cassandra.fullname" . }}-client=true" +will be able to connect to Cassandra. +{{- else -}} + +To connect to your database from outside the cluster execute the following commands: + +{{- if contains "NodePort" .Values.service.type }} + + 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 "cassandra.fullname" . }}) + + cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD $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. + Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "redis.fullname" . }}' + + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "redis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD $SERVICE_IP + +{{- else if contains "ClusterIP" .Values.service.type }} + + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "cassandra.fullname" . }} {{ .Values.service.cqlPort }}:{{ .Values.service.cqlPort }} & + cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD 127.0.0.1 {{ .Values.service.cqlPort }} + +{{- end }} +{{- end }} + diff --git a/bitnami/cassandra/templates/_helpers.tpl b/bitnami/cassandra/templates/_helpers.tpl new file mode 100644 index 0000000000..4761c82e8a --- /dev/null +++ b/bitnami/cassandra/templates/_helpers.tpl @@ -0,0 +1,77 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "cassandra.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 "cassandra.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 "cassandra.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "cassandra.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "cassandra.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Return the proper Cassandra image name +*/}} +{{- define "cassandra.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $tag := .Values.image.tag | toString -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. +Also, we can't use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} +{{- end -}} + + +{{/* +Return the proper metrics image name +*/}} +{{- define "metrics.image" -}} +{{- $registryName := .Values.metrics.image.registry -}} +{{- $repositoryName := .Values.metrics.image.repository -}} +{{- $tag := .Values.metrics.image.tag | toString -}} +{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} diff --git a/bitnami/cassandra/templates/cassandra-secret.yaml b/bitnami/cassandra/templates/cassandra-secret.yaml new file mode 100644 index 0000000000..b481e961d2 --- /dev/null +++ b/bitnami/cassandra/templates/cassandra-secret.yaml @@ -0,0 +1,20 @@ +{{- if (not .Values.dbUser.existingSecret) -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "cassandra.fullname" . }} + labels: + app: "{{ template "cassandra.name" . }}" + chart: {{ template "cassandra.chart" . }} + release: {{ .Release.Name | quote }} + heritage: {{ .Release.Service | quote }} +type: Opaque +data: + {{- if .Values.dbUser.password }} + cassandra-password: "{{ .Values.dbUser.password | b64enc }}" + {{- else if (not .Values.dbUser.forcePassword) }} + cassandra-password: "{{ randAlphaNum 10 | b64enc }}" + {{ else }} + cassandra-password: {{ required "A Cassandra Password is required!" .Values.dbUser.password }} + {{- end }} +{{- end }} diff --git a/bitnami/cassandra/templates/headless-svc.yaml b/bitnami/cassandra/templates/headless-svc.yaml new file mode 100644 index 0000000000..7d5a6be8ca --- /dev/null +++ b/bitnami/cassandra/templates/headless-svc.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "cassandra.fullname" . }}-headless + labels: + app: {{ template "cassandra.name" . }} + chart: {{ template "cassandra.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + clusterIP: None + publishNotReadyAddresses: true + ports: + - name: intra + port: 7000 + targetPort: intra + - name: tls + port: 7001 + targetPort: tls + - name: jmx + port: 7199 + targetPort: jmx + - name: cql + port: {{ default 9042 .Values.service.cqlPort }} + targetPort: cql + - name: thrift + port: {{ default 9160 .Values.service.thriftPort }} + targetPort: thrift + selector: + app: {{ template "cassandra.name" . }} + release: {{ .Release.Name }} diff --git a/bitnami/cassandra/templates/networkPolicy.yaml b/bitnami/cassandra/templates/networkPolicy.yaml new file mode 100644 index 0000000000..5eaf1bb8b5 --- /dev/null +++ b/bitnami/cassandra/templates/networkPolicy.yaml @@ -0,0 +1,31 @@ +{{- if .Values.networkPolicy.enabled }} +kind: NetworkPolicy +apiVersion: {{ template "networkPolicy.apiVersion" . }} +metadata: + name: "{{ template "cassandra.fullname" . }}" + labels: + app: {{ template "cassandra.name" . }} + chart: {{ template "cassandra.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + podSelector: + matchLabels: + app: {{ template "cassandra.name" . }} + release: "{{ .Release.Name }}" + ingress: + # Allow inbound connections + - ports: + - port: 6379 + {{- if not .Values.networkPolicy.allowExternal }} + from: + - podSelector: + matchLabels: + {{ template "cassandra.fullname" . }}-client: "true" + {{- end }} + {{- if .Values.metrics.enabled }} + # Allow prometheus scrapes for metrics + - ports: + - port: 8080 + {{- end }} +{{- end }} diff --git a/bitnami/cassandra/templates/service.yaml b/bitnami/cassandra/templates/service.yaml new file mode 100644 index 0000000000..1b1f66d0f1 --- /dev/null +++ b/bitnami/cassandra/templates/service.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "cassandra.fullname" . }} + labels: + app: {{ template "cassandra.name" . }} + chart: {{ template "cassandra.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: +{{- if .Values.service.nodePort }} + nodePort: {{ .Values.service.nodePort }} +{{- end }} +{{ if eq .Values.service.type "LoadBalancer" -}} {{ if .Values.service.loadBalancerIP -}} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} +{{ end -}} + type: {{ .Values.service.type }} + ports: + - name: cql + port: {{ default 9042 .Values.service.cqlPort }} + targetPort: cql + - name: thrift + port: {{ default 9160 .Values.service.thriftPort }} + targetPort: thrift + selector: + app: {{ template "cassandra.name" . }} + release: {{ .Release.Name }} diff --git a/bitnami/cassandra/templates/statefulset.yaml b/bitnami/cassandra/templates/statefulset.yaml new file mode 100644 index 0000000000..2de8362cb0 --- /dev/null +++ b/bitnami/cassandra/templates/statefulset.yaml @@ -0,0 +1,184 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ template "cassandra.fullname" . }} + labels: + app: {{ template "cassandra.name" . }} + chart: {{ template "cassandra.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + app: {{ template "cassandra.name" . }} + release: {{ .Release.Name }} + serviceName: {{ template "cassandra.fullname" . }}-headless + replicas: {{ .Values.cluster.replicaCount }} + updateStrategy: + type: {{ .Values.statefulset.updateStrategy }} + {{- if .Values.statefulset.rollingUpdatePartition }} + rollingUpdate: + partition: {{ .Values.statefulset.rollingUpdatePartition }} + {{- end }} + template: + metadata: + labels: + app: {{ template "cassandra.name" . }} + release: {{ .Release.Name }} +{{- if .Values.podLabels }} +{{ toYaml .Values.podLabels | indent 8 }} +{{- end }} +{{- if or .Values.podAnnotations .Values.metrics.enabled }} + annotations: + {{- if .Values.podAnnotations }} +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + {{- if .Values.metrics.enabled }} +{{ toYaml .Values.metrics.podAnnotations | indent 8 }} + {{- end }} +{{- end }} + spec: +{{- if .Values.selector }} +{{ toYaml .Values.selector | indent 6 }} +{{- end }} + {{- if .Values.securityContext.enabled }} + securityContext: + fsGroup: {{ .Values.securityContext.fsGroup }} + runAsUser: {{ .Values.securityContext.runAsUser }} + {{- end }} +{{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 8 }} +{{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + containers: + - name: cassandra + command: + - bash + - -ec + # Node 0 is the password seeder + - | + if [[ $HOSTNAME =~ (.*)-0$ ]]; then + echo "Setting node as password seeder" + export CASSANDRA_PASSWORD_SEEDER=yes + fi + /app-entrypoint.sh /run.sh + + image: {{ template "cassandra.image" . }} + imagePullPolicy: {{ .Values.image.pullPolicy | quote }} + resources: +{{ toYaml .Values.resources | indent 10 }} + env: + - name: CASSANDRA_CLUSTER_NAME + value: {{ .Values.cluster.name }} + - name: CASSANDRA_SEEDS + {{- $global := . }} + {{- $replicas := .Values.cluster.seedCount | int }} + value: "{{- range $i, $e := until $replicas }}{{ template "cassandra.fullname" $global }}-{{ $i }}.{{ template "cassandra.fullname" $global }}-headless.{{ $global.Release.Namespace }}.svc.cluster.local{{- if (lt ( add1 $i ) $replicas ) }},{{- end }}{{- end }}" + - name: CASSANDRA_PASSWORD + valueFrom: + secretKeyRef: + name: {{ if .Values.dbUser.existingSecret }}{{ .Values.dbUser.existingSecret }}{{- else }}{{ template "cassandra.fullname" . }}{{- end }} + key: cassandra-password + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP +{{- if .Values.livenessProbe.enabled }} + livenessProbe: + exec: + command: [ "/bin/sh", "-c", "nodetool status" ] + 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: + exec: + command: [ "/bin/sh", "-c", "nodetool status | grep -E \"^UN\\s+${POD_IP}\"" ] + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} +{{- end }} + ports: + - name: intra + containerPort: 7000 + - name: tls + containerPort: 7001 + - name: jmx + containerPort: 7199 + - name: cql + containerPort: 9042 + - name: thrift + containerPort: 9160 + volumeMounts: + - name: data + mountPath: /bitnami/cassandra + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + - name: {{ .Values.image.pullSecrets }} + {{- end }} +{{- if .Values.metrics.enabled }} + - name: metrics + image: {{ template "metrics.image" . }} + imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} + {{- if .Values.metrics.image.pullSecrets }} + imagePullSecrets: + - name: {{ .Values.metrics.image.pullSecrets }} + {{- end }} + ports: + - name: metrics + containerPort: 8080 + protocol: TCP + - name: jmx + containerPort: 5555 + livenessProbe: + tcpSocket: + port: metrics + readinessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: 20 + timeoutSeconds: 45 +{{- end }} +{{- if not .Values.persistence.enabled }} + volumes: + - name: data + emptyDir: {} +{{- else }} + volumeClaimTemplates: + - metadata: + name: data + labels: + app: {{ template "cassandra.name" . }} + chart: {{ template "cassandra.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 8 }} +{{- end }} + spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- if .Values.persistence.storageClass }} + {{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" + {{- end }} + {{- end }} +{{- end }} diff --git a/bitnami/cassandra/values-production.yaml b/bitnami/cassandra/values-production.yaml new file mode 100644 index 0000000000..1f8afcba16 --- /dev/null +++ b/bitnami/cassandra/values-production.yaml @@ -0,0 +1,174 @@ +## Global Docker image registry +## Please, note that this will override the image registry for all the images, including dependencies, configured to use the global value +## +# global: +# imageRegistry: + +## Bitnami Cassandra image version +## ref: https://hub.docker.com/r/bitnami/cassandra/tags/ +## +image: + registry: docker.io + repository: bitnami/cassandra + ## Bitnami Cassandra image tag + ## ref: https://github.com/bitnami/bitnami-docker-cassandra#supported-tags-and-respective-dockerfile-links + ## + tag: 3.11.3 + ## Specify a imagePullPolicy + ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' + ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images + ## + pullPolicy: Always + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + # pullSecrets: + # - myRegistrKeySecretName + +## Specify a service type +## ref: http://kubernetes.io/docs/user-guide/services/ +service: + type: ClusterIP + cqlPort: 9042 + thriftPort: 9160 + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + # nodePort: 30001 + # loadBalancerIP: + + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + +## Enable persistence using Persistent Volume Claims +## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistence: + ## If true, use a Persistent Volume Claim, If false, use emptyDir + ## + enabled: true + ## Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + ## Persistent Volume Claim annotations + ## + annotations: + ## Persistent Volume Access Mode + ## + accessModes: + - ReadWriteOnce + ## Persistent Volume size + ## + size: 8Gi + ## + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## Minimum memory for development is 4GB and 2 CPU cores +## Minimum memory for production is 8GB and 4 CPU cores +## ref: http://docs.datastax.com/en/archived/cassandra/2.0/cassandra/architecture/architecturePlanningHardware_c.html +resources: {} + # requests: + # memory: 4Gi + # cpu: 2 + # limits: + # memory: 4Gi + # cpu: 2 + +## Change cassandra configuration parameters below: +## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html +## Recommended max heap size is 1/2 of system memory +## Recommeneed heap new size is 1/4 of max heap size +## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsTuneJVM.html +cluster: + name: cassandra + replicaCount: 3 + seedCount: 2 + +dbUser: + user: cassandra + forcePassword: false + # password: + # existingSecret: + +## Liveness and Readiness probe values. +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ +livenessProbe: + enabled: true + initialDelaySeconds: 60 + periodSeconds: 30 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 +readinessProbe: + enabled: true + initialDelaySeconds: 60 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + +## Additional pod annotations +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} + +## Additional pod labels +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +statefulset: + updateStrategy: OnDelete + # rollingUpdatePartition: + +## Pod Security Context +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ +## +securityContext: + enabled: true + fsGroup: 1001 + runAsUser: 1001 + +## Affinity for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +affinity: {} + +## Tolerations for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +## +tolerations: [] + +networkPolicy: + ## Specifies whether a NetworkPolicy should be created + ## + enabled: true + + ## The Policy model to apply. When set to false, only pods with the correct + ## client label will have network access to the port Redis is listening + ## on. When true, Redis will accept connections from any source + ## (with the correct destination port). + ## + # allowExternal: true + +## Cassandra exporter configuration +## ref: https://github.com/criteo/cassandra_exporter +metrics: + enabled: true + image: + registry: docker.io + pullPolicy: IfNotPresent + repository: criteo/cassandra_exporter + tag: 2.0.4 + # pullSecrets: + resources: {} + podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8080" diff --git a/bitnami/cassandra/values.yaml b/bitnami/cassandra/values.yaml new file mode 100644 index 0000000000..00df01a56b --- /dev/null +++ b/bitnami/cassandra/values.yaml @@ -0,0 +1,174 @@ +## Global Docker image registry +## Please, note that this will override the image registry for all the images, including dependencies, configured to use the global value +## +# global: +# imageRegistry: + +## Bitnami Cassandra image version +## ref: https://hub.docker.com/r/bitnami/cassandra/tags/ +## +image: + registry: docker.io + repository: bitnami/cassandra + ## Bitnami Cassandra image tag + ## ref: https://github.com/bitnami/bitnami-docker-cassandra#supported-tags-and-respective-dockerfile-links + ## + tag: 3.11.3 + ## Specify a imagePullPolicy + ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' + ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images + ## + pullPolicy: Always + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + # pullSecrets: + # - myRegistrKeySecretName + +## Specify a service type +## ref: http://kubernetes.io/docs/user-guide/services/ +service: + type: ClusterIP + cqlPort: 9042 + thriftPort: 9160 + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + # nodePort: 30001 + # loadBalancerIP: + + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + +## Enable persistence using Persistent Volume Claims +## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistence: + ## If true, use a Persistent Volume Claim, If false, use emptyDir + ## + enabled: true + ## Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + ## Persistent Volume Claim annotations + ## + annotations: + ## Persistent Volume Access Mode + ## + accessModes: + - ReadWriteOnce + ## Persistent Volume size + ## + size: 8Gi + ## + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## Minimum memory for development is 4GB and 2 CPU cores +## Minimum memory for production is 8GB and 4 CPU cores +## ref: http://docs.datastax.com/en/archived/cassandra/2.0/cassandra/architecture/architecturePlanningHardware_c.html +resources: {} + # requests: + # memory: 4Gi + # cpu: 2 + # limits: + # memory: 4Gi + # cpu: 2 + +## Change cassandra configuration parameters below: +## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html +## Recommended max heap size is 1/2 of system memory +## Recommeneed heap new size is 1/4 of max heap size +## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsTuneJVM.html +cluster: + name: cassandra + replicaCount: 1 + seedCount: 1 + +dbUser: + user: cassandra + forcePassword: false + # password: + # existingSecret: + +## Liveness and Readiness probe values. +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ +livenessProbe: + enabled: true + initialDelaySeconds: 60 + periodSeconds: 30 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 +readinessProbe: + enabled: true + initialDelaySeconds: 60 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + +## Additional pod annotations +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} + +## Additional pod labels +## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +statefulset: + updateStrategy: OnDelete + # rollingUpdatePartition: + +## Pod Security Context +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ +## +securityContext: + enabled: true + fsGroup: 1001 + runAsUser: 1001 + +## Affinity for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +affinity: {} + +## Tolerations for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +## +tolerations: [] + +networkPolicy: + ## Specifies whether a NetworkPolicy should be created + ## + enabled: false + + ## The Policy model to apply. When set to false, only pods with the correct + ## client label will have network access to the port Redis is listening + ## on. When true, Redis will accept connections from any source + ## (with the correct destination port). + ## + # allowExternal: true + +## Cassandra exporter configuration +## ref: https://github.com/criteo/cassandra_exporter +metrics: + enabled: false + image: + registry: docker.io + pullPolicy: IfNotPresent + repository: criteo/cassandra_exporter + tag: 2.0.4 + # pullSecrets: + resources: {} + podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8080" From f60d8fdf29b84f587b0f02d9ddf5c409608cde6f Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Fri, 9 Nov 2018 10:12:58 +0100 Subject: [PATCH 2/6] Fix cassandra metrics image template --- bitnami/cassandra/templates/_helpers.tpl | 2 +- bitnami/cassandra/templates/statefulset.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bitnami/cassandra/templates/_helpers.tpl b/bitnami/cassandra/templates/_helpers.tpl index 4761c82e8a..09c676b8f7 100644 --- a/bitnami/cassandra/templates/_helpers.tpl +++ b/bitnami/cassandra/templates/_helpers.tpl @@ -69,7 +69,7 @@ Also, we can't use a single if because lazy evaluation is not an option {{/* Return the proper metrics image name */}} -{{- define "metrics.image" -}} +{{- define "cassandra.metrics.image" -}} {{- $registryName := .Values.metrics.image.registry -}} {{- $repositoryName := .Values.metrics.image.repository -}} {{- $tag := .Values.metrics.image.tag | toString -}} diff --git a/bitnami/cassandra/templates/statefulset.yaml b/bitnami/cassandra/templates/statefulset.yaml index 2de8362cb0..61eb10ec70 100644 --- a/bitnami/cassandra/templates/statefulset.yaml +++ b/bitnami/cassandra/templates/statefulset.yaml @@ -127,7 +127,7 @@ spec: {{- end }} {{- if .Values.metrics.enabled }} - name: metrics - image: {{ template "metrics.image" . }} + image: {{ template "cassandra.metrics.image" . }} imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }} {{- if .Values.metrics.image.pullSecrets }} imagePullSecrets: From d6f8de5393dc0f65918e6de606849c2f07f1cb51 Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Fri, 9 Nov 2018 11:32:10 +0100 Subject: [PATCH 3/6] Fix service missing end --- bitnami/cassandra/templates/service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/cassandra/templates/service.yaml b/bitnami/cassandra/templates/service.yaml index 1b1f66d0f1..365d04f4af 100644 --- a/bitnami/cassandra/templates/service.yaml +++ b/bitnami/cassandra/templates/service.yaml @@ -13,7 +13,7 @@ spec: {{- end }} {{ if eq .Values.service.type "LoadBalancer" -}} {{ if .Values.service.loadBalancerIP -}} loadBalancerIP: {{ .Values.service.loadBalancerIP }} -{{ end -}} +{{- end -}} {{- end }} type: {{ .Values.service.type }} ports: - name: cql From 69b61f8afb75f6916044ba88af57fb60b51ba216 Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Fri, 9 Nov 2018 12:21:44 +0100 Subject: [PATCH 4/6] Fix network policies --- bitnami/cassandra/templates/_helpers.tpl | 11 +++++++++++ bitnami/cassandra/values-production.yaml | 2 +- bitnami/cassandra/values.yaml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bitnami/cassandra/templates/_helpers.tpl b/bitnami/cassandra/templates/_helpers.tpl index 09c676b8f7..9769bb7760 100644 --- a/bitnami/cassandra/templates/_helpers.tpl +++ b/bitnami/cassandra/templates/_helpers.tpl @@ -6,6 +6,17 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Return the appropriate apiVersion for networkpolicy. +*/}} +{{- define "networkPolicy.apiVersion" -}} +{{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "extensions/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- 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). diff --git a/bitnami/cassandra/values-production.yaml b/bitnami/cassandra/values-production.yaml index 1f8afcba16..5a5983bc60 100644 --- a/bitnami/cassandra/values-production.yaml +++ b/bitnami/cassandra/values-production.yaml @@ -165,7 +165,7 @@ metrics: image: registry: docker.io pullPolicy: IfNotPresent - repository: criteo/cassandra_exporter + repository: criteord/cassandra_exporter tag: 2.0.4 # pullSecrets: resources: {} diff --git a/bitnami/cassandra/values.yaml b/bitnami/cassandra/values.yaml index 00df01a56b..49320b8bc3 100644 --- a/bitnami/cassandra/values.yaml +++ b/bitnami/cassandra/values.yaml @@ -165,7 +165,7 @@ metrics: image: registry: docker.io pullPolicy: IfNotPresent - repository: criteo/cassandra_exporter + repository: criteord/cassandra_exporter tag: 2.0.4 # pullSecrets: resources: {} From 065ed7cf83a733903080e85925ea8bb9555f65f7 Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Fri, 9 Nov 2018 15:39:29 +0100 Subject: [PATCH 5/6] Apply all requested changes --- bitnami/cassandra/Chart.yaml | 2 +- bitnami/cassandra/README.md | 40 +++++++++---------- bitnami/cassandra/templates/NOTES.txt | 22 +++++----- bitnami/cassandra/templates/_helpers.tpl | 11 ----- .../cassandra/templates/cassandra-secret.yaml | 10 ++--- bitnami/cassandra/templates/headless-svc.yaml | 8 ++-- .../cassandra/templates/networkPolicy.yaml | 14 ++++--- bitnami/cassandra/templates/service.yaml | 4 +- bitnami/cassandra/templates/statefulset.yaml | 2 +- bitnami/cassandra/values-production.yaml | 26 ++++++++---- bitnami/cassandra/values.yaml | 24 +++++++---- 11 files changed, 88 insertions(+), 75 deletions(-) diff --git a/bitnami/cassandra/Chart.yaml b/bitnami/cassandra/Chart.yaml index dbc19bc05e..fcdd7607ad 100644 --- a/bitnami/cassandra/Chart.yaml +++ b/bitnami/cassandra/Chart.yaml @@ -1,5 +1,5 @@ name: cassandra -version: 1.0.0 +version: 0.0.1 appVersion: 3.11.3 description: Apache Cassandra is a free and open-source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients. icon: https://d33np9n32j53g7.cloudfront.net/assets/stacks/cassandra/img/cassandra-stack-220x234-071ca9e210d165c3972d41ff9f96bd60.png diff --git a/bitnami/cassandra/README.md b/bitnami/cassandra/README.md index cdc1e821be..977186af65 100644 --- a/bitnami/cassandra/README.md +++ b/bitnami/cassandra/README.md @@ -5,7 +5,8 @@ ## TL;DR; ```console -$ helm install . +$ helm repo add bitnami https://charts.bitnami.com/bitnami +$ helm install bitnami/cassandra ``` ## Introduction @@ -24,7 +25,7 @@ Bitnami charts can be used with [Kubeapps](https://kubeapps.com/) for deployment To install the chart with the release name `my-release`: ```console -$ helm install --name my-release ./cassandra +$ helm install --name my-release bitnami/cassandra ``` The command deploys one node with Cassandra on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. @@ -33,7 +34,7 @@ The command deploys one node with Cassandra on the Kubernetes cluster in the def ## Uninstalling the Chart -To uninstall/delete the `my-release` petset: +To uninstall/delete the `my-release` release: ```console $ helm delete my-release @@ -47,29 +48,29 @@ The following tables lists the configurable parameters of the cassandra chart an | Parameter | Description | Default | |--------------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------| -| `global.imageRegistry` | Global Docker image registry | `nil` | +| `global.imageRegistry` | Global Docker Image registry | `nil` | | `image.registry` | Cassandra Image registry | `docker.io` | | `image.repository` | Cassandra Image name | `bitnami/cassandra` | -| `image.tag` | Cassandra Image tag | `3.11.3` | +| `image.tag` | Cassandra Image tag | `{VERSION}` | | `image.pullPolicy` | Image pull policy | `Always` | -| `image.pullSecrets` | Specify docker-registry secret names as an array | `nil` | +| `image.pullSecrets` | Specify `docker-registry` secret names as an array | `nil` | | `service.type` | Kubernetes Service type | `ClusterIP` | | `service.nodePort` | Kubernetes Service nodePort | `nil` | | `service.loadBalancerIP` | LoadBalancerIP if service type is `LoadBalancer` | `nil` | | `service.annotations` | Annotations for the service | {} | | `persistence.enabled` | Use PVCs to persist data | `true` | -| `persistence.storageClass` | Storage class of backing PVC | `generic` | -| `persistence.annotations` | Annotations for the PVC | {} | +| `persistence.storageClass` | Persistent Volume Storage Class | `generic` | +| `persistence.annotations` | Persistent Volume Claim annotations Annotations | {} | | `persistence.accessModes` | Persistent Volume Access Modes | `[ReadWriteOnce]` | -| `persistence.size` | Size of data volume | `8Gi` | +| `persistence.size` | Persistent Volume Size | `8Gi` | | `resources` | CPU/Memory resource requests/limits | `{}` | | `cluster.name` | Cassandra cluster name | `cassandra` | -| `cluster.replicaCount` | Number of cassandra nodes | `1` | +| `cluster.replicaCount` | Number of Cassandra nodes | `1` | | `cluster.seedCount` | Number of seed nodes (note: must be greater or equal than 1 and less or equal to `cluster.replicaCount`) | `1` | | `dbUser.user` | Cassandra admin user | `cassandra` | | `dbUser.forcePassword` | Force the user to provide a non-empty password for `dbUser.user` | `false` | | `dbUser.password` | Password for `dbUser.user`. Randomly generated if empty | (Random generated) | -| `dbUser.existingSecret` | Use an existing secret object for `dbUser.user` password (will ignore `dbUser.password`) | `` | +| `dbUser.existingSecret` | Use an existing secret object for `dbUser.user` password (will ignore `dbUser.password`) | `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 | `30` | @@ -85,7 +86,7 @@ The following tables lists the configurable parameters of the cassandra chart an | `podAnnotations` | Additional pod annotations | `{}` | | `podLabels` | Additional pod labels | `{}` | | `statefulset.updateStrategy` | Update strategy for StatefulSet | onDelete | -| `statefulset.rollingUpdatePartition` | Partition update strategy | `` | +| `statefulset.rollingUpdatePartition` | Partition update strategy | `nil` | | `securityContext.enabled` | Enable security context | `true` | | `securityContext.fsGroup` | Group ID for the container | `1001` | | `securityContext.runAsUser` | User ID for the container | `1001` | @@ -94,11 +95,11 @@ The following tables lists the configurable parameters of the cassandra chart an | `networkPolicy.enabled` | Enable NetworkPolicy | `false` | | `networkPolicy.allowExternal` | Don't require client label for connections | `true` | | `metrics.enabled` | Start a side-car prometheus exporter | `false` | -| `metrics.image.registry` | Cassandra exporter image registry | `docker.io` | -| `metrics.image.repository` | Cassandra exporter image name | `criteo/cassandra_exporter` | -| `metrics.image.tag` | Cassandra exporter image tag | `2.0.4` | +| `metrics.image.registry` | Cassandra exporter Image registry | `docker.io` | +| `metrics.image.repository` | Cassandra exporter Image name | `criteo/cassandra_exporter` | +| `metrics.image.tag` | Cassandra exporter Image tag | `2.0.4` | | `metrics.image.pullPolicy` | Image pull policy | `IfNotPresent` | -| `metrics.image.pullSecrets` | Specify docker-registry secret names as an array | `nil` | +| `metrics.image.pullSecrets` | Specify `docker-registry` secret names as an array | `nil` | | `metrics.podAnnotations` | Additional annotations for Metrics exporter | `{prometheus.io/scrape: "true", prometheus.io/port: "8080"}` | | `metrics.resources` | Exporter resource requests/limit | `{}` | @@ -108,15 +109,14 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm ```console $ helm install --name my-release \ - --set cassandraUser=admin,cassandraPassword=password\ - ./cassandra + --set dbUser.user=admin,dbUser.password=password\ + bitnami/cassandra ``` - Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, ```console -$ helm install --name my-release -f values.yaml ./cassandra +$ helm install --name my-release -f values.yaml bitnami/cassandra ``` > **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/bitnami/cassandra/templates/NOTES.txt b/bitnami/cassandra/templates/NOTES.txt index 1e79d5d590..688189e7ac 100644 --- a/bitnami/cassandra/templates/NOTES.txt +++ b/bitnami/cassandra/templates/NOTES.txt @@ -1,17 +1,17 @@ ** Please be patient while the chart is being deployed ** -Cassandra can be accessed through the following urls from within the cluster: +Cassandra can be accessed through the following URLs from within the cluster: - CQL: {{ template "cassandra.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.cqlPort }} - Thrift: {{ template "cassandra.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.thriftPort }} To get your password run: - export CASSANDRA_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }} -o jsonpath="{.data.cassandra-password}" | base64 --decode) + export CASSANDRA_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }} -o jsonpath="{.data.cassandra-password}" | base64 --decode) Check the cluster status by running: - kubectl exec -it --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.name" . }},release={{ .Release.Name }} -o jsonpath='{.items[0].metadata.name}') nodetool status + kubectl exec -it --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.name" . }},release={{ .Release.Name }} -o jsonpath='{.items[0].metadata.name}') nodetool status To connect to your Cassandra cluster using CQL: @@ -19,7 +19,7 @@ To connect to your Cassandra cluster using CQL: kubectl run --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }}-client --rm --tty -i \ --env CASSANDRA_PASSWORD=$CASSANDRA_PASSWORD \ - {{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "cassandra.name" . }}-client=true" \{{- end }} \ + {{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "cassandra.name" . }}-client=true"{{ end }} \ --image {{ template "cassandra.image" . }} -- bash 2. Connect using the cqlsh client: @@ -36,23 +36,23 @@ To connect to your database from outside the cluster execute the following comma {{- if contains "NodePort" .Values.service.type }} - 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 "cassandra.fullname" . }}) + 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 "cassandra.fullname" . }}) cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD $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. - Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "redis.fullname" . }}' + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "redis.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "redis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "redis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD $SERVICE_IP {{- else if contains "ClusterIP" .Values.service.type }} - kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "cassandra.fullname" . }} {{ .Values.service.cqlPort }}:{{ .Values.service.cqlPort }} & - cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD 127.0.0.1 {{ .Values.service.cqlPort }} + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "cassandra.fullname" . }} {{ .Values.service.cqlPort }}:{{ .Values.service.cqlPort }} & + cqlsh -u {{ .Values.dbUser.user }} -p $CASSANDRA_PASSWORD 127.0.0.1 {{ .Values.service.cqlPort }} {{- end }} {{- end }} diff --git a/bitnami/cassandra/templates/_helpers.tpl b/bitnami/cassandra/templates/_helpers.tpl index 9769bb7760..c4bfbbce4f 100644 --- a/bitnami/cassandra/templates/_helpers.tpl +++ b/bitnami/cassandra/templates/_helpers.tpl @@ -42,17 +42,6 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{/* -Create the name of the service account to use -*/}} -{{- define "cassandra.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "cassandra.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} - {{/* Return the proper Cassandra image name */}} diff --git a/bitnami/cassandra/templates/cassandra-secret.yaml b/bitnami/cassandra/templates/cassandra-secret.yaml index b481e961d2..b7904437c1 100644 --- a/bitnami/cassandra/templates/cassandra-secret.yaml +++ b/bitnami/cassandra/templates/cassandra-secret.yaml @@ -4,16 +4,16 @@ kind: Secret metadata: name: {{ template "cassandra.fullname" . }} labels: - app: "{{ template "cassandra.name" . }}" + app: {{ template "cassandra.name" . }} chart: {{ template "cassandra.chart" . }} - release: {{ .Release.Name | quote }} - heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} type: Opaque data: {{- if .Values.dbUser.password }} - cassandra-password: "{{ .Values.dbUser.password | b64enc }}" + cassandra-password: {{ .Values.dbUser.password | b64enc | quote }} {{- else if (not .Values.dbUser.forcePassword) }} - cassandra-password: "{{ randAlphaNum 10 | b64enc }}" + cassandra-password: {{ randAlphaNum 10 | b64enc | quote }} {{ else }} cassandra-password: {{ required "A Cassandra Password is required!" .Values.dbUser.password }} {{- end }} diff --git a/bitnami/cassandra/templates/headless-svc.yaml b/bitnami/cassandra/templates/headless-svc.yaml index 7d5a6be8ca..f3acf742bb 100644 --- a/bitnami/cassandra/templates/headless-svc.yaml +++ b/bitnami/cassandra/templates/headless-svc.yaml @@ -5,8 +5,8 @@ metadata: labels: app: {{ template "cassandra.name" . }} chart: {{ template "cassandra.chart" . }} - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: clusterIP: None publishNotReadyAddresses: true @@ -21,10 +21,10 @@ spec: port: 7199 targetPort: jmx - name: cql - port: {{ default 9042 .Values.service.cqlPort }} + port: {{ .Values.service.cqlPort }} targetPort: cql - name: thrift - port: {{ default 9160 .Values.service.thriftPort }} + port: {{ .Values.service.thriftPort }} targetPort: thrift selector: app: {{ template "cassandra.name" . }} diff --git a/bitnami/cassandra/templates/networkPolicy.yaml b/bitnami/cassandra/templates/networkPolicy.yaml index 5eaf1bb8b5..7d68fda287 100644 --- a/bitnami/cassandra/templates/networkPolicy.yaml +++ b/bitnami/cassandra/templates/networkPolicy.yaml @@ -2,27 +2,31 @@ kind: NetworkPolicy apiVersion: {{ template "networkPolicy.apiVersion" . }} metadata: - name: "{{ template "cassandra.fullname" . }}" + name: {{ template "cassandra.fullname" . }} labels: app: {{ template "cassandra.name" . }} chart: {{ template "cassandra.chart" . }} - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: podSelector: matchLabels: app: {{ template "cassandra.name" . }} - release: "{{ .Release.Name }}" + release: {{ .Release.Name }} ingress: # Allow inbound connections - ports: - - port: 6379 + - port: {{ .Values.service.cqlPort }} {{- if not .Values.networkPolicy.allowExternal }} from: - podSelector: matchLabels: {{ template "cassandra.fullname" . }}-client: "true" {{- end }} + - podSelector: + matchLabels: + app: {{ template "cassandra.name" . }} + release: {{ .Release.Name }} {{- if .Values.metrics.enabled }} # Allow prometheus scrapes for metrics - ports: diff --git a/bitnami/cassandra/templates/service.yaml b/bitnami/cassandra/templates/service.yaml index 365d04f4af..c2bd4d9dd6 100644 --- a/bitnami/cassandra/templates/service.yaml +++ b/bitnami/cassandra/templates/service.yaml @@ -17,10 +17,10 @@ spec: type: {{ .Values.service.type }} ports: - name: cql - port: {{ default 9042 .Values.service.cqlPort }} + port: {{ .Values.service.cqlPort }} targetPort: cql - name: thrift - port: {{ default 9160 .Values.service.thriftPort }} + port: {{ .Values.service.thriftPort }} targetPort: thrift selector: app: {{ template "cassandra.name" . }} diff --git a/bitnami/cassandra/templates/statefulset.yaml b/bitnami/cassandra/templates/statefulset.yaml index 61eb10ec70..6434487757 100644 --- a/bitnami/cassandra/templates/statefulset.yaml +++ b/bitnami/cassandra/templates/statefulset.yaml @@ -178,7 +178,7 @@ spec: {{- if (eq "-" .Values.persistence.storageClass) }} storageClassName: "" {{- else }} - storageClassName: "{{ .Values.persistence.storageClass }}" + storageClassName: {{ .Values.persistence.storageClass | quote }} {{- end }} {{- end }} {{- end }} diff --git a/bitnami/cassandra/values-production.yaml b/bitnami/cassandra/values-production.yaml index 5a5983bc60..9f0e30c77a 100644 --- a/bitnami/cassandra/values-production.yaml +++ b/bitnami/cassandra/values-production.yaml @@ -28,6 +28,7 @@ image: ## Specify a service type ## ref: http://kubernetes.io/docs/user-guide/services/ +## service: type: ClusterIP cqlPort: 9042 @@ -69,13 +70,13 @@ persistence: ## Persistent Volume size ## size: 8Gi - ## ## Configure resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## Minimum memory for development is 4GB and 2 CPU cores ## Minimum memory for production is 8GB and 4 CPU cores ## ref: http://docs.datastax.com/en/archived/cassandra/2.0/cassandra/architecture/architecturePlanningHardware_c.html +## resources: {} # requests: # memory: 4Gi @@ -84,24 +85,24 @@ resources: {} # memory: 4Gi # cpu: 2 -## Change cassandra configuration parameters below: -## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html -## Recommended max heap size is 1/2 of system memory -## Recommeneed heap new size is 1/4 of max heap size -## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsTuneJVM.html +## Cluster parameters +## cluster: name: cassandra replicaCount: 3 seedCount: 2 +## Database credentials +## dbUser: user: cassandra - forcePassword: false + forcePassword: true # password: # existingSecret: ## Liveness and Readiness probe values. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ +## livenessProbe: enabled: true initialDelaySeconds: 60 @@ -119,12 +120,16 @@ readinessProbe: ## Additional pod annotations ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +## podAnnotations: {} ## Additional pod labels ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +## podLabels: {} +## StatefulSet settings +## statefulset: updateStrategy: OnDelete # rollingUpdatePartition: @@ -139,6 +144,7 @@ securityContext: ## Affinity for pod assignment ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## affinity: {} ## Tolerations for pod assignment @@ -146,6 +152,9 @@ affinity: {} ## tolerations: [] +## Network policies +## Ref: https://kubernetes.io/docs/concepts/services-networking/network-policies/ +## networkPolicy: ## Specifies whether a NetworkPolicy should be created ## @@ -159,7 +168,8 @@ networkPolicy: # allowExternal: true ## Cassandra exporter configuration -## ref: https://github.com/criteo/cassandra_exporter +## Ref: https://github.com/criteo/cassandra_exporter +## metrics: enabled: true image: diff --git a/bitnami/cassandra/values.yaml b/bitnami/cassandra/values.yaml index 49320b8bc3..2e5106398a 100644 --- a/bitnami/cassandra/values.yaml +++ b/bitnami/cassandra/values.yaml @@ -28,6 +28,7 @@ image: ## Specify a service type ## ref: http://kubernetes.io/docs/user-guide/services/ +## service: type: ClusterIP cqlPort: 9042 @@ -69,13 +70,13 @@ persistence: ## Persistent Volume size ## size: 8Gi - ## ## Configure resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## Minimum memory for development is 4GB and 2 CPU cores ## Minimum memory for production is 8GB and 4 CPU cores ## ref: http://docs.datastax.com/en/archived/cassandra/2.0/cassandra/architecture/architecturePlanningHardware_c.html +## resources: {} # requests: # memory: 4Gi @@ -84,16 +85,15 @@ resources: {} # memory: 4Gi # cpu: 2 -## Change cassandra configuration parameters below: -## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/configCassandra_yaml.html -## Recommended max heap size is 1/2 of system memory -## Recommeneed heap new size is 1/4 of max heap size -## ref: http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsTuneJVM.html +## Cluster parameters +## cluster: name: cassandra replicaCount: 1 seedCount: 1 +## Database credentials +## dbUser: user: cassandra forcePassword: false @@ -102,6 +102,7 @@ dbUser: ## Liveness and Readiness probe values. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ +## livenessProbe: enabled: true initialDelaySeconds: 60 @@ -119,12 +120,16 @@ readinessProbe: ## Additional pod annotations ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +## podAnnotations: {} ## Additional pod labels ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +## podLabels: {} +## StatefulSet settings +## statefulset: updateStrategy: OnDelete # rollingUpdatePartition: @@ -139,6 +144,7 @@ securityContext: ## Affinity for pod assignment ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## affinity: {} ## Tolerations for pod assignment @@ -146,6 +152,9 @@ affinity: {} ## tolerations: [] +## Network policies +## Ref: https://kubernetes.io/docs/concepts/services-networking/network-policies/ +## networkPolicy: ## Specifies whether a NetworkPolicy should be created ## @@ -159,7 +168,8 @@ networkPolicy: # allowExternal: true ## Cassandra exporter configuration -## ref: https://github.com/criteo/cassandra_exporter +## Ref: https://github.com/criteo/cassandra_exporter +## metrics: enabled: false image: From ed2b3f7fef88b5063cf0980afa86195678546683 Mon Sep 17 00:00:00 2001 From: "Javier J. Salmeron Garcia" Date: Fri, 9 Nov 2018 16:55:21 +0100 Subject: [PATCH 6/6] Typo --- bitnami/cassandra/templates/NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/cassandra/templates/NOTES.txt b/bitnami/cassandra/templates/NOTES.txt index 688189e7ac..46a6629611 100644 --- a/bitnami/cassandra/templates/NOTES.txt +++ b/bitnami/cassandra/templates/NOTES.txt @@ -28,7 +28,7 @@ To connect to your Cassandra cluster using CQL: {{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }} Note: Since NetworkPolicy is enabled, only pods with label -{{ template "cassandra.fullname" . }}-client=true" +"{{ template "cassandra.fullname" . }}-client=true" will be able to connect to Cassandra. {{- else -}}