Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[incubator/cassandra] Standardize labels (#5111)
Browse files Browse the repository at this point in the history
* [incubator/cassandra] standardize labels

* use "cassandra.name" as app label instead of "cassandra.fullname"
* match pods by two labels, release and app

* [incubator/cassandra] update notes

* [incubator/cassandra] bump version to 0.2.7

* [incubator/cassandra] bump version to 0.3.0

* bump the minor version
  • Loading branch information
alebabai authored and k8s-ci-robot committed May 3, 2018
1 parent aca2ba4 commit fba95c3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion incubator/cassandra/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cassandra
version: 0.2.6
version: 0.3.0
appVersion: 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
Expand Down
8 changes: 4 additions & 4 deletions incubator/cassandra/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Cassandra CQL can be accessed via port {{ .Values.config.ports.cql }} on the fol
Cassandra Thrift can be accessed via port {{ .Values.config.ports.thrift }} on the following DNS name from within your cluster:

If you want to connect to the remote instance with your local Cassandra CQL cli. To forward the API port to localhost:9042 run the following:
- kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') 9042:{{ .Values.config.ports.cql }}
- kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.name" . }},release={{ .Release.Name }} -o jsonpath='{ .items[0].metadata.name }') 9042:{{ .Values.config.ports.cql }}

If you want to connect to the Cassandra CQL run the following:
{{- if contains "NodePort" .Values.service.type }}
Expand All @@ -16,12 +16,12 @@ If you want to connect to the Cassandra CQL run the following:
- export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "cassandra.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
- echo cqlsh $SERVICE_IP
{{- else if contains "ClusterIP" .Values.service.type }}
- kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "cassandra.fullname" . }}" -o jsonpath="{.items[0].metadata.name}") 9042:{{ .Values.config.ports.cql }}
- kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "cassandra.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") 9042:{{ .Values.config.ports.cql }}
echo cqlsh 127.0.0.1 9042
{{- end }}

You can also see the cluster status by run the following:
- kubectl exec -it --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.fullname" . }} -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 tail the logs for the Cassandra pod run the following:
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.fullname" . }} -o jsonpath='{ .items[0].metadata.name }')
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cassandra.name" . }},release={{ .Release.Name }} -o jsonpath='{ .items[0].metadata.name }')
23 changes: 19 additions & 4 deletions incubator/cassandra/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
Expand the name of the chart.
*/}}
{{- define "cassandra.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 21 chars because Kubernetes name fields are limited to 24 (by the DNS naming spec)
and Statefulset will append -xx at the end of 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 -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 -}}
{{- 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 -}}
30 changes: 16 additions & 14 deletions incubator/cassandra/templates/cassandra-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: Service
metadata:
name: {{ template "cassandra.fullname" . }}
labels:
app: {{ template "cassandra.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "cassandra.name" . }}
chart: {{ template "cassandra.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
clusterIP: None
type: {{ .Values.service.type }}
Expand All @@ -32,17 +32,18 @@ spec:
targetPort: {{ .Values.config.ports.agent }}
{{- end }}
selector:
app: {{ template "cassandra.fullname" . }}
app: {{ template "cassandra.name" . }}
release: {{ .Release.Name }}
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: {{ template "cassandra.fullname" . }}
labels:
app: {{ template "cassandra.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "cassandra.name" . }}
chart: {{ template "cassandra.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
serviceName: {{ template "cassandra.fullname" . }}
replicas: {{ .Values.config.cluster_size }}
Expand All @@ -52,7 +53,8 @@ spec:
template:
metadata:
labels:
app: {{ template "cassandra.fullname" . }}
app: {{ template "cassandra.name" . }}
release: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -139,10 +141,10 @@ spec:
- metadata:
name: data
labels:
app: {{ template "cassandra.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "cassandra.name" . }}
chart: {{ template "cassandra.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
Expand Down

0 comments on commit fba95c3

Please sign in to comment.