Skip to content

Commit

Permalink
init commit - cover the old logic and makes this commit as a new base…
Browse files Browse the repository at this point in the history
…line
  • Loading branch information
wyx0k committed Sep 21, 2023
1 parent 7995577 commit f9959dd
Show file tree
Hide file tree
Showing 34 changed files with 1,247 additions and 1,354 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/.idea
/.idea
/initconfig/initconfig
/initconfig/*.tgz
/dist
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
IMAGE_TAG_BASE ?= cnosdb/init-config
DIST ?= dist
init-config-build:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $(DIST)/initconfig initconfig/main.go
init-config-image:
cp initconfig/Dockerfile $(DIST)/Dockerfile
cd $(DIST)&&docker build -t $(IMAGE_TAG_BASE):latest .
init-config: init-config-build init-config-image

helm-package:
cd $(DIST)&&helm package ../charts/cnosdb

build: init-config helm-package

4 changes: 2 additions & 2 deletions charts/cnosdb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: cnosdb
description: An Open Source Distributed Time Series Database with high performance, high compression ratio and high usability.
description: An Open Source Distributed Time Series Database with high performance, high compression ratio and high usability.

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.1
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
69 changes: 0 additions & 69 deletions charts/cnosdb/files/backup-retention-script.sh

This file was deleted.

43 changes: 1 addition & 42 deletions charts/cnosdb/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
CnosDB can be accessed via port {{ .Values.config.http.bind_address | default 8086 }} on the following DNS name from within your cluster:

http://{{ include "cnosdb.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.config.http.bind_address | default 8086 }}

You can connect to the remote instance with the cnos CLI. To forward the API port to localhost:8086, run the following:

kubectl port-forward --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ include "cnosdb.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') 8086:{{ .Values.config.http.bind_address | default 8086 }}

You can also connect to the cnos CLI from inside the container. To open a shell session in the CnosDB pod, run the following:

kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ include "cnosdb.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh

To view the logs for the CnosDB pod, run the following:

kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ include "cnosdb.fullname" . }} -o jsonpath='{ .items[0].metadata.name }')

{{- if .Values.setDefaultUser.enabled }}

To retrieve the default user name:

{{- if .Values.setDefaultUser.user.existingSecret }}

echo $(kubectl get secret {{ .Values.setDefaultUser.user.existingSecret }} -o "jsonpath={.data['cnosdb-user']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- else }}

echo $(kubectl get secret {{ include "cnosdb.fullname" . }}-auth -o "jsonpath={.data['cnosdb-user']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- end }}

To retrieve the default user password:

{{- if .Values.setDefaultUser.user.existingSecret }}

echo $(kubectl get secret {{ .Values.setDefaultUser.user.existingSecret }} -o "jsonpath={.data['cnosdb-password']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- else }}

echo $(kubectl get secret {{ include "cnosdb.fullname" . }}-auth -o "jsonpath={.data['cnosdb-password']}" --namespace {{ .Release.Namespace }} | base64 --decode)

{{- end }}
{{- end }}
todo
56 changes: 33 additions & 23 deletions charts/cnosdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cnosdb.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- 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 "cnosdb.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 -}}
{{- 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 "cnosdb.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
Expand All @@ -41,23 +40,34 @@ helm.sh/chart: {{ include "cnosdb.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cnosdb.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cnosdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cnosdb.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "cnosdb.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cnosdb.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
To Yaml
Usage:
{{ include "cnosdb.toYaml" ( dict "value" .Values.path.to.the.Value ) }}
{{ include "cnosdb.toYaml" ( dict "value" .Values.path.to.the.Value ) }}
*/}}
{{- define "cnosdb.toYaml" -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- $value }}
{{- end -}}
Loading

0 comments on commit f9959dd

Please sign in to comment.