Kubernetes
-
Install JuiceFS (ref: https://juicefs.com/docs/csi/getting_started).
# Add the JuiceFS repository.
helm repo add juicefs https://juicedata.github.io/charts/
# Update the repository.
helm repo update
# Install JuiceFS CSI Driver.
# JuiceFS needs certain permission on cluster, and hence needs
# to be installed in kube-system namespace.
helm install juicefs-csi-driver juicefs/juicefs-csi-driver -n kube-system -
Wait for the respective services and containers to deploy. Use kubectl to check the deployment status of pods
kubectl get pods -n kube-system -l app.kubernetes.io/name=juicefs-csi-driver -
JuiceFS needs a database for storing metadata. Since CubeAPM already uses a database server (MySQL or PostgreSQL), same database server can be used for JuiceFS as well.
- MySQL
- PostgreSQL
CREATE DATABASE cubeapm_logs_archive_meta CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'cubeapm_logs_archive_user'@'%' IDENTIFIED BY 'cubeapm_logs_archive_pass';
GRANT ALL PRIVILEGES ON cubeapm_logs_archive_meta.* TO 'cubeapm_logs_archive_user'@'%';
FLUSH PRIVILEGES;CREATE DATABASE cubeapm_logs_archive_meta;
CREATE USER cubeapm_logs_archive_user WITH PASSWORD 'cubeapm_logs_archive_pass';
GRANT ALL PRIVILEGES ON DATABASE cubeapm_logs_archive_meta TO cubeapm_logs_archive_user;
GRANT ALL ON SCHEMA public TO cubeapm_logs_archive_user;
\c cubeapm_logs_archive_meta
GRANT ALL ON SCHEMA public TO cubeapm_logs_archive_user; -
Create object storage bucket for storing archive logs data. Name the bucket as
cubeapm-logs-archive -
(Applicable to GCP only) Create a service account and give the (ObjectAdmin and Storage Admin) permission to access the gcp bucket from pods running inside kubernetes cluster.
-
(Applicable to GCP only) Generate a (JSON) key of the service account and using that service account key create a kubernetes secret in kube-system and namespace where cubeapm is running.
kubectl create secret generic gc-secret \
--from-file=application_default_credentials.json=./application_default_credentials.json \
-n <namespace> # Match your namespace -
Create Kubernetes Secret configuration file as
cubeapm-logs-archive-secret.yaml. Replace the values with actual values.- AWS
- GCP
apiVersion: v1
kind: Secret
metadata:
name: cubeapm-logs-archive-secret
stringData:
name: logsarchive
# database_string
# MySQL: mysql://cubeapm_logs_archive_user:cubeapm_logs_archive_pass@tcp(localhost:3306)/cubeapm_logs_archive_meta
# PostgreSQL: postgres://cubeapm_logs_archive_user:cubeapm_logs_archive_pass@localhost:5432/cubeapm_logs_archive_meta
metaurl: <database_string>
storage: s3
# bucket_url: https://cubeapm-logs-archive.s3.ap-south-1.amazonaws.com
bucket: <bucket_url>
access-key: <ACCESS_KEY>
secret-key: <SECRET_KEY>
# To create the file system in mount pod, add more juicefs format parameters to format-options.
# format-options: trash-days=1,block-size=4096apiVersion: v1
kind: Secret
metadata:
name: cubeapm-logs-archive-secret
stringData:
name: logsarchive
# database_string
# MySQL: mysql://cubeapm_logs_archive_user:cubeapm_logs_archive_pass@tcp(localhost:3306)/cubeapm_logs_archive_meta
# PostgreSQL: postgres://cubeapm_logs_archive_user:cubeapm_logs_archive_pass@localhost:5432/cubeapm_logs_archive_meta
metaurl: <database_string>
storage: gs
# bucket_url: gs://cubeapm-logs-archive
bucket: <bucket_url>
# GCS auth: Use service account JSON keyfile
configs: "{gc-secret: /root/.config/gcloud}"
envs: "{GOOGLE_APPLICATION_CREDENTIALS: /root/.config/gcloud/application_default_credentials.json}" -
Apply secret to cluster
kubectl apply -f cubeapm-logs-archive-secret.yaml -n <namespace> -
Create Kubernetes StorageClass configuration file as
cubeapm-logs-archive-sc.yaml. Replace the values with actual values.apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: cubeapm-logs-archive-sc
provisioner: csi.juicefs.com
reclaimPolicy: Retain
parameters:
csi.storage.k8s.io/provisioner-secret-name: cubeapm-logs-archive-secret
csi.storage.k8s.io/provisioner-secret-namespace: <namespace>
csi.storage.k8s.io/node-publish-secret-name: cubeapm-logs-archive-secret
csi.storage.k8s.io/node-publish-secret-namespace: <namespace> -
Apply storage class to cluster
kubectl apply -f cubeapm-logs-archive-sc.yaml -n <namespace> -
Update your CubeAPM
values.yamlfile. Set configVars.logs.archive.enabled astrueand runhelm upgrade -
Check for JuiceFS CSI driver mount pod in
kube-systemnamespace. It follows specific pattern asjuicefs-<node-name>-<pvc-id>kubectl get pods -n kube-system