Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yorkie-analytics Helm chart with Starrocks and Kafka #1161

Merged
merged 6 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ This directory contains the Helm charts for Yorkie.
- [yorkie-cluster](./yorkie-cluster): Helm chart for Yorkie cluster
- [yorkie-monitoring](./yorkie-monitoring): Helm chart for Yorkie cluster monitoring system with Prometheus and Grafana
- [yorkie-argocd](./yorkie-argocd): Helm chart for Yorkie cluster continuous delivery system with ArgoCD
- [yorkie-analytics](./yorkie-analytics): Helm chart for Yorkie cluster analytics system with Kafka and StarRocks
23 changes: 23 additions & 0 deletions build/charts/yorkie-analytics/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions build/charts/yorkie-analytics/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: kube-starrocks
repository: https://starrocks.github.io/starrocks-kubernetes-operator
version: 1.9.10
- name: kafka
repository: oci://registry-1.docker.io/bitnamicharts
version: 31.3.1
digest: sha256:6ee18506a9459750de0258ad65cc2c33e56242c382232ee28b90f068966a21c4
generated: "2025-02-19T11:20:06.183033+09:00"
34 changes: 34 additions & 0 deletions build/charts/yorkie-analytics/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v2
name: yorkie-analytics
description: yorkie-analytics provides analytics system with kafka and starrocks for analyzing usage of yorkie cluster
type: application
icon: https://raw.githubusercontent.com/yorkie-team/yorkie-team.github.io/main/public/favicon-512x512.png
maintainers:
- name: hackerwins
email: [email protected]
- name: krapie
email: [email protected]

sources:
- https://github.com/yorkie-team/yorkie
version: 0.6.0
appVersion: "0.6.0"
kubeVersion: ">=1.24.0-0"

keywords:
- yorkie
- cluster
- kubernetes
- kafka
- starrocks

# Kube Kafka and Starrocks stack dependencies
dependencies:
- name: kafka
version: 31.3.1
repository: oci://registry-1.docker.io/bitnamicharts
condition: yorkie-analytics.kafka.enabled
- name: kube-starrocks
version: 1.9.10
repository: https://starrocks.github.io/starrocks-kubernetes-operator
condition: yorkie-analytics.starrocks.enabled
68 changes: 68 additions & 0 deletions build/charts/yorkie-analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# yorkie-analytics

Installs the yorkie-analytics, which provides analytics system with Kafka and StarRocks for analyizing usage of yorkie cluster.

## Prerequisites

- Kubernetes 1.24+
- Helm 3+

## Get Helm Repository Info

```bash
helm repo add yorkie-team https://yorkie-team.github.io/yorkie/helm-charts
helm repo update
```

_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._

## Install Helm Chart

```bash
# Install yorkie analytics helm chart
helm install [RELEASE_NAME] yorkie-team/yorkie-analytics -n analytics --create-namespace
```

_See [configuration](#configuration) below for custom installation_

_See [`helm install`](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Dependencies

By default this chart installs additional, dependent charts:

- [kube-starrocks](https://starrocks.github.io/starrocks-kubernetes-operator)
- [bitnami/kafka](https://github.com/bitnami/charts/tree/main/bitnami/kafka)

_See [`helm dependency`](https://helm.sh/docs/helm/helm_dependency/) for command documentation._

## Uninstall Helm Chart

```bash
helm uninstall [RELEASE_NAME] -n analytics
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [`helm uninstall`](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Upgrading Chart

```bash
helm upgrade [RELEASE_NAME] yorkie-team/yorkie-analytics -n analytics
```

With Helm v3, CRDs created by this chart are not updated by default and should be manually updated.
Consult also the [Helm Documentation on CRDs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions).

_See [`helm upgrade`](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## Configuration

See [Customizing the Chart Before Installing](#customizing-the-chart-before-installing) below for configuration options. To see all configurable options with detailed comments:

```console
helm show values yorkie-team/yorkie-analytics
```
Comment on lines +62 to +66
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Link Fragment Verification in Configuration Section

The link "Customizing the Chart Before Installing" on line 62 does not seem to reference any header within the document. Please verify that the corresponding section exists or update the link to point to a valid header.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

62-62: Link fragments should be valid
null

(MD051, link-fragments)


You may also `helm show values` on this chart's [dependencies](#dependencies) for additional options.
9 changes: 9 additions & 0 deletions build/charts/yorkie-analytics/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- Install Complete ---
{{ .Release.Name }} successfully installed!

For next steps, follow:
$ curl https://github.com/yorkie-team/yorkie/tree/main/charts/yorkie-analytics

To learn more about the release, try:
$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
24 changes: 24 additions & 0 deletions build/charts/yorkie-analytics/templates/kafka/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if index .Values "yorkie-analytics" "kafka" "enabled" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.name }}-init-kafka-topics-script
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/component: kafka
app.kubernetes.io/part-of: yorkie-analytics
data:
init-kafka-topics.sh: |
#!/bin/bash

KAFKA_HOST={{ .Values.name }}-kafka.{{ .Values.namespace }}.svc.cluster.local:9092

echo -e 'Waiting for Kafka to be ready...'
kafka-topics.sh --bootstrap-server $KAFKA_HOST --list

echo -e 'Creating kafka topics'
kafka-topics.sh --bootstrap-server $KAFKA_HOST --create --if-not-exists --topic {{ index .Values "yorkie-analytics" "kafka" "topic" "name" }} --partitions {{ index .Values "yorkie-analytics" "kafka" "topic" "partitions" }} --replication-factor {{ index .Values "yorkie-analytics" "kafka" "topic" "replicationFactor" }}

echo -e 'Successfully created the following topics:'
kafka-topics.sh --bootstrap-server $KAFKA_HOST --list
{{- end }}
34 changes: 34 additions & 0 deletions build/charts/yorkie-analytics/templates/kafka/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if index .Values "yorkie-analytics" "kafka" "enabled" }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Values.name }}-init-kafka-topics-job
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/component: kafka
app.kubernetes.io/part-of: yorkie-analytics
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
serviceAccountName: starrocks
restartPolicy: OnFailure
initContainers:
- name: wait-for-kafka
image: bitnami/kubectl
command: [ "kubectl", "wait", "pod/{{ $.Values.name }}-kafka-controller-0", "--for", "condition=Ready", "--namespace", "{{ .Values.namespace }}", "--timeout", "300s" ]
containers:
- name: init-kafka-topics
image: {{ index .Values "yorkie-analytics" "kafka" "image" "repository" }}:{{ index .Values "yorkie-analytics" "kafka" "image" "tag" }}
command: [ "/bin/bash", "/etc/config/init-kafka-topics.sh" ]
volumeMounts:
- name: init-kafka-topics-script
mountPath: /etc/config
volumes:
- name: init-kafka-topics-script
configMap:
name: {{ .Values.name }}-init-kafka-topics-script
backoffLimit: 10
{{- end }}
75 changes: 75 additions & 0 deletions build/charts/yorkie-analytics/templates/starrocks/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{- if index .Values "yorkie-analytics" "starrocks" "enabled" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.name }}-init-starrocks-database-script
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/component: starrocks
app.kubernetes.io/part-of: yorkie-analytics
data:
init-user-events-db.sql: |
CREATE DATABASE IF NOT EXISTS yorkie;

USE yorkie;

CREATE TABLE user_events (
user_id VARCHAR(64),
timestamp DATETIME,
event_type VARCHAR(32),
project_id VARCHAR(64),
user_agent VARCHAR(32)
) ENGINE = OLAP
DUPLICATE KEY(user_id)
DISTRIBUTED BY HASH(user_id) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);

init-routine-load.sql: |
CREATE ROUTINE LOAD yorkie.events ON user_events
PROPERTIES
(
"format" = "JSON",
"desired_concurrent_number"="1"
)
FROM KAFKA
(
"kafka_broker_list" = "{{ index .Values "yorkie-analytics" "starrocks" "routine-load" "kafka-broker-list" }}",
"kafka_topic" = "{{ index .Values "yorkie-analytics" "starrocks" "routine-load" "kafka-topic" }}",
"property.group.id" = "{{ index .Values "yorkie-analytics" "starrocks" "routine-load" "property-group-id" }}"
);

init-starrocks-database.sh: |
#!/bin/bash

STARROCKS_MYSQL_HOST=kube-starrocks-fe-service.{{ .Values.namespace }}.svc.cluster.local

sleep 5s
echo -e 'Checking Starrocks status'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show frontends\G' | grep 'Alive: true' || echo -e 'Frontend is not ready'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show backends\G' | grep 'Alive: true' || echo -e 'Starrocks BE is not ready'


echo -e 'Creating Yorkie database, tables and routine load'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root < /etc/config/init-user-events-db.sql

echo -e 'Checking Yorkie database'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show databases\G'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show databases\G' | grep 'Database: yorkie' || echo -e 'Yorkie database not found'

echo -e 'Checking user_event table'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show tables from yorkie\G'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show tables from yorkie\G' | grep 'Tables_in_yorkie: user_events' || echo -e 'user_events table not found'


sleep 5s
echo -e 'Creating routine load'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root < /etc/config/init-routine-load.sql

sleep 10s
echo -e 'Checking event routine load'

mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show routine load from yorkie\G'
mysql -h $STARROCKS_MYSQL_HOST -P 9030 -u root -e 'show routine load from yorkie\G' | grep -E "State: NEED_SCHEDULE|State: RUNNING" || echo -e 'Routine load is not running'
{{- end }}
42 changes: 42 additions & 0 deletions build/charts/yorkie-analytics/templates/starrocks/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if index .Values "yorkie-analytics" "starrocks" "enabled" }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Values.name }}-init-starrocks-database-job
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/component: starrocks
app.kubernetes.io/part-of: yorkie-analytics
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
serviceAccountName: starrocks
restartPolicy: OnFailure
initContainers:
- name: wait-for-starrocks-fe
image: bitnami/kubectl
command: [ "kubectl", "wait", "pod/kube-starrocks-fe-0", "--for", "condition=Ready", "--namespace", "{{ .Values.namespace }}", "--timeout", "300s" ]
- name: wait-for-starrocks-be
image: bitnami/kubectl
command: [ "kubectl", "wait", "pod/kube-starrocks-be-0", "--for", "condition=Ready", "--namespace", "{{ .Values.namespace }}", "--timeout", "300s" ]
{{- if index .Values "yorkie-analytics" "kafka" "enabled" }}
- name: wait-for-kafka
image: bitnami/kubectl
command: [ "kubectl", "wait", "pod/{{ $.Values.name }}-kafka-controller-0", "--for", "condition=Ready", "--namespace", "{{ .Values.namespace }}", "--timeout", "300s" ]
{{- end }}
containers:
- name: init-starrocks-database
image: {{ index .Values "yorkie-analytics" "starrocks" "image" "repository" }}:{{ index .Values "yorkie-analytics" "starrocks" "image" "tag" }}
command: [ "/bin/bash", "/etc/config/init-starrocks-database.sh" ]
volumeMounts:
- name: init-starrocks-database-script
mountPath: /etc/config
volumes:
- name: init-starrocks-database-script
configMap:
name: {{ .Values.name }}-init-starrocks-database-script
backoffLimit: 10
{{- end }}
64 changes: 64 additions & 0 deletions build/charts/yorkie-analytics/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: yorkie-analytics
namespace: analytics

yorkie-analytics:
starrocks:
enabled: true
image:
repository: &starrocks-fe-repo starrocks/fe-ubuntu
tag: &starrocks-fe-tag "3.3-latest"
routine-load:
kafka-broker-list: yorkie-analytics-kafka.analytics.svc.cluster.local:9092
kafka-topic: user-events
property-group-id: user_events_group
kafka:
enabled: true
image:
repository: bitnami/kafka
tag: latest
topic:
name: user-events
partitions: 1
replicationFactor: 1

kube-starrocks:
starrocks:
starrocksFESpec:
replicas: 1
image:
repository: *starrocks-fe-repo
tag: *starrocks-fe-tag
resources:
requests:
cpu: "300m"
memory: 1Gi
storageSpec:
name: fe

starrocksBeSpec:
replicas: 1
resources:
requests:
cpu: "300m"
memory: 1Gi
storageSpec:
name: be
storageSize: 15Gi

starrocksFeProxySpec:
enabled: false
service:
type: LoadBalancer

kafka:
kraft:
clusterId: yorkie-analytics
listeners:
client:
protocol: PLAINTEXT
controller:
protocol: PLAINTEXT
serviceAccount:
create: true
rbac:
create: true
Loading
Loading