Skip to content

Commit c95d7ed

Browse files
authored
feat: refact karpor chart, add more variables, bump to v0.5 (#36)
* refactor: refine karpor chart, add more variables * chore: support auto generate readme * docs: add helm set help * fix: lint problmes, add lint to makefile
1 parent d445f45 commit c95d7ed

File tree

12 files changed

+426
-89
lines changed

12 files changed

+426
-89
lines changed

charts/karpor/Chart.yaml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1+
# The fields explain in the Chart.yaml can refer:
2+
# https://helm.sh/docs/topics/charts/#the-chartyaml-file
13
apiVersion: v2
24
name: karpor
5+
# The Chart Version
6+
version: 0.5.0
7+
type: application
8+
# The Application Version in the Chart
9+
appVersion: 0.4.2
310
description: A Helm chart for Karpor, a modern kubernetes visualization tool.
411
home: https://github.com/KusionStack/karpor
512
icon: https://kusionstack.io/karpor/assets/logo/logo.svg
6-
7-
# A chart can be either an 'application' or a 'library' chart.
8-
#
9-
# Application charts are a collection of templates that can be packaged into versioned archives
10-
# to be deployed.
11-
#
12-
# Library charts provide useful utilities or functions for the chart developer. They're included as
13-
# a dependency of application charts to inject those utilities and functions into the rendering
14-
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
15-
type: application
16-
17-
# This is the chart version. This version number should be incremented each time you make changes
18-
# to the chart and its templates, including the app version.
19-
# Versions are expected to follow Semantic Versioning (https://semver.org/)
20-
version: 0.4.3
21-
22-
# This is the version number of the application being deployed. This version number should be
23-
# incremented each time you make changes to the application. Versions are not expected to
24-
# follow Semantic Versioning. They should reflect the version the application is using.
25-
# It is recommended to use it with quotes.
26-
appVersion: 0.4.2
27-
2813
maintainers:
2914
- name: kusionstack
15+
3016
url: https://kusionstack.io/karpor
17+
sources:
18+
- https://github.com/KusionStack/charts/tree/master/charts/karpor
19+
- https://github.com/KusionStack/karpor
20+
keywords:
21+
- KusionStack
22+
- karpor

charts/karpor/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To generate help information
2+
.DEFAULT_GOAL := help
3+
.PHONY: help
4+
help: ## This help message :)
5+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6+
7+
.PHONY: lint
8+
lint: ## Lint, will not fix but sets exit code on error
9+
@which yamllint > /dev/null || (echo "Installing yamllint@latest ..."; brew install yamllint && echo -e "Installation complete!\n")
10+
@yamllint --config-file ../../.github/configs/lintconf.yaml *.yaml
11+
12+
.PHONY: doc
13+
doc: ## Auto Generate README with helm-docs and README.md.gotmpl
14+
@which helm-docs > /dev/null || (echo "Installing helm-docs@latest ..."; go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest && echo -e "Installation complete!\n")
15+
@helm-docs

charts/karpor/README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Karpor Chart
2+
3+
![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.4.2](https://img.shields.io/badge/AppVersion-0.4.2-informational?style=flat-square)
4+
5+
A Helm chart for Karpor, a modern kubernetes visualization tool.
6+
7+
**Homepage:** <https://github.com/KusionStack/karpor>
8+
9+
## Maintainers
10+
11+
| Name | Email | Url |
12+
| ---- | ------ | --- |
13+
| kusionstack | <[email protected]> | <https://kusionstack.io/karpor> |
14+
15+
## Source Code
16+
17+
* <https://github.com/KusionStack/charts/tree/master/charts/karpor>
18+
* <https://github.com/KusionStack/karpor>
19+
20+
## Prerequisites
21+
22+
- Helm v3.5.0+
23+
24+
## Installing the Chart
25+
26+
To install the chart with the release name `my-release`:
27+
28+
```bash
29+
$ helm repo add kusionstack https://kusionstack.github.io/charts
30+
$ helm repo update
31+
$ helm install karpor kusionstack/karpor
32+
```
33+
34+
**Note** that installing this chart directly means it will use the [default template values](./values.yaml) for Karpor.
35+
36+
You may have to set your specific configurations if it is deployed into a production cluster, or you want to custom configure `resources`, `replicas`, `port` etc.
37+
38+
```bash
39+
$ helm install my-release kusionstack/karpor --set server.replicas=3 --set syncer.port=7654
40+
```
41+
42+
## Chart Parameters
43+
44+
The following table lists the configurable parameters of the chart and their default values.
45+
46+
### General Parameters
47+
48+
| Key | Type | Default | Description |
49+
|-----|------|---------|-------------|
50+
| namespace | string | `"karpor"` | Which namespace to be deployed. |
51+
| namespaceEnabled | bool | `true` | Whether to generate namespace. |
52+
53+
### Global Parameters
54+
55+
| Key | Type | Default | Description |
56+
|-----|------|---------|-------------|
57+
| global.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy to be applied to all Karpor components. |
58+
59+
### Karpor Server
60+
61+
The Karpor Server Component is main backend server. It itself is an `apiserver`, which also provides `/rest-api` to serve Dashboard.
62+
63+
| Key | Type | Default | Description |
64+
|-----|------|---------|-------------|
65+
| server.image.repo | string | `"kusionstack/karpor"` | Repository for Karpor server image. |
66+
| server.image.tag | string | `""` | Tag for Karpor server image. Defaults to the chart's appVersion if not specified. |
67+
| server.name | string | `"karpor-server"` | Component name for Karpor server. |
68+
| server.port | int | `7443` | Port for Karpor server. |
69+
70+
### Karpor Syncer
71+
72+
The Karpor Syncer Component is independent server to synchronize cluster resources in real-time.
73+
74+
| Key | Type | Default | Description |
75+
|-----|------|---------|-------------|
76+
| syncer.image.repo | string | `"kusionstack/karpor"` | Repository for Karpor syncer image. |
77+
| syncer.image.tag | string | `""` | Tag for Karpor syncer image. Defaults to the chart's appVersion if not specified. |
78+
| syncer.name | string | `"karpor-syncer"` | Component name for Karpor syncer. |
79+
| syncer.port | int | `7443` | Port for Karpor syncer. |
80+
81+
### ElasticSearch
82+
83+
The ElasticSearch Component to store the synchronized resources and user data.
84+
85+
| Key | Type | Default | Description |
86+
|-----|------|---------|-------------|
87+
| elasticsearch.image.repo | string | `"docker.elastic.co/elasticsearch/elasticsearch"` | Repository for ElasticSearch image. |
88+
| elasticsearch.image.tag | string | `"8.6.2"` | Specific tag for ElasticSearch image. |
89+
| elasticsearch.name | string | `"elasticsearch"` | Component name for ElasticSearch. |
90+
| elasticsearch.port | int | `9200` | Port for ElasticSearch. |
91+
92+
### ETCD
93+
94+
The ETCD Component is the storage of Karpor Server as `apiserver`.
95+
96+
| Key | Type | Default | Description |
97+
|-----|------|---------|-------------|
98+
| etcd.image.repo | string | `"quay.io/coreos/etcd"` | Repository for ETCD image. |
99+
| etcd.image.tag | string | `"v3.5.11"` | Specific tag for ETCD image. |
100+
| etcd.name | string | `"etcd"` | Component name for ETCD. |
101+
| etcd.port | int | `2379` | Port for ETCD. |
102+
103+
### Job
104+
105+
This one-time job is used to generate root certificates and some preliminary work.
106+
107+
| Key | Type | Default | Description |
108+
|-----|------|---------|-------------|
109+
| job.image.repo | string | `"golang"` | Repository for the Job image. |
110+
| job.image.tag | string | `"1.19"` | Specific tag for the Job image. |
111+
112+
----------------------------------------------
113+
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)

charts/karpor/README.md.gotmpl

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Karpor Chart
2+
3+
{{ template "chart.badgesSection" . }}
4+
5+
{{ template "chart.description" . }}
6+
7+
{{ template "chart.homepageLine" . }}
8+
9+
{{ template "chart.maintainersSection" . }}
10+
11+
{{ template "chart.sourcesSection" . }}
12+
13+
## Prerequisites
14+
15+
- Helm v3.5.0+
16+
17+
## Installing the Chart
18+
19+
To install the chart with the release name `my-release`:
20+
21+
```bash
22+
$ helm repo add kusionstack https://kusionstack.github.io/charts
23+
$ helm repo update
24+
$ helm install karpor kusionstack/karpor
25+
```
26+
27+
**Note** that installing this chart directly means it will use the [default template values](./values.yaml) for Karpor.
28+
29+
You may have to set your specific configurations if it is deployed into a production cluster, or you want to custom configure `resources`, `replicas`, `port` etc.
30+
31+
```bash
32+
$ helm install my-release kusionstack/karpor --set server.replicas=3 --set syncer.port=7654
33+
```
34+
35+
## Chart Parameters
36+
37+
The following table lists the configurable parameters of the chart and their default values.
38+
39+
### General Parameters
40+
41+
| Key | Type | Default | Description |
42+
|-----|------|---------|-------------|
43+
{{- range .Values }}
44+
{{- if not (or (hasPrefix "global" .Key) (hasPrefix "server" .Key) (hasPrefix "syncer" .Key) (hasPrefix "elasticsearch" .Key) (hasPrefix "etcd" .Key) (hasPrefix "job" .Key) ) }}
45+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
46+
{{- end }}
47+
{{- end }}
48+
49+
### Global Parameters
50+
51+
| Key | Type | Default | Description |
52+
|-----|------|---------|-------------|
53+
{{- range .Values }}
54+
{{- if hasPrefix "global" .Key }}
55+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
56+
{{- end }}
57+
{{- end }}
58+
59+
### Karpor Server
60+
61+
The Karpor Server Component is main backend server. It itself is an `apiserver`, which also provides `/rest-api` to serve Dashboard.
62+
63+
| Key | Type | Default | Description |
64+
|-----|------|---------|-------------|
65+
{{- range .Values }}
66+
{{- if hasPrefix "server" .Key }}
67+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
68+
{{- end }}
69+
{{- end }}
70+
71+
### Karpor Syncer
72+
73+
The Karpor Syncer Component is independent server to synchronize cluster resources in real-time.
74+
75+
| Key | Type | Default | Description |
76+
|-----|------|---------|-------------|
77+
{{- range .Values }}
78+
{{- if hasPrefix "syncer" .Key }}
79+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
80+
{{- end }}
81+
{{- end }}
82+
83+
### ElasticSearch
84+
85+
The ElasticSearch Component to store the synchronized resources and user data.
86+
87+
| Key | Type | Default | Description |
88+
|-----|------|---------|-------------|
89+
{{- range .Values }}
90+
{{- if hasPrefix "elasticsearch" .Key }}
91+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
92+
{{- end }}
93+
{{- end }}
94+
95+
### ETCD
96+
97+
The ETCD Component is the storage of Karpor Server as `apiserver`.
98+
99+
| Key | Type | Default | Description |
100+
|-----|------|---------|-------------|
101+
{{- range .Values }}
102+
{{- if hasPrefix "etcd" .Key }}
103+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
104+
{{- end }}
105+
{{- end }}
106+
107+
### Job
108+
109+
This one-time job is used to generate root certificates and some preliminary work.
110+
111+
| Key | Type | Default | Description |
112+
|-----|------|---------|-------------|
113+
{{- range .Values }}
114+
{{- if hasPrefix "job" .Key }}
115+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
116+
{{- end }}
117+
{{- end }}
118+
119+
{{- if not .SkipVersionFooter }}
120+
{{ template "helm-docs.versionFooter" . }}
121+
{{- end }}

charts/karpor/templates/_common.tpl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{/*
2+
Create chart name and version as used by the chart label.
3+
*/}}
4+
{{- define "karpor.chart" -}}
5+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
6+
{{- end -}}
7+
8+
{{/*
9+
Common labels
10+
*/}}
11+
{{- define "karpor.labels" -}}
12+
helm.sh/chart: {{ include "karpor.chart" .context }}
13+
{{ include "karpor.selectorLabels" (dict "context" .context "component" .component) }}
14+
app.kubernetes.io/managed-by: {{ .context.Release.Service }}
15+
app.kubernetes.io/version: {{ .context.Chart.AppVersion }}
16+
{{- end }}
17+
18+
{{/*
19+
Selector labels
20+
*/}}
21+
{{- define "karpor.selectorLabels" -}}
22+
app.kubernetes.io/name: {{ .context.Chart.Name }}
23+
{{- if .component }}
24+
app.kubernetes.io/component: {{ .component }}
25+
{{- end }}
26+
app.kubernetes.io/instance: {{ .context.Release.Name }}
27+
{{- end }}
28+

charts/karpor/templates/elasticsearch.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ metadata:
55
namespace: {{ .Values.namespace }}
66
spec:
77
ports:
8-
- port: 9200
8+
- port: {{ .Values.elasticsearch.port }}
99
selector:
10-
app: elasticsearch
10+
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 4 }}
1111
---
1212
apiVersion: apps/v1
1313
kind: Deployment
1414
metadata:
1515
labels:
16-
app: elasticsearch
16+
{{- include "karpor.labels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 4 }}
1717
name: elasticsearch
1818
namespace: {{ .Values.namespace }}
1919
spec:
2020
replicas: 1
2121
selector:
2222
matchLabels:
23-
app: elasticsearch
23+
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 6 }}
2424
template:
2525
metadata:
2626
labels:
27-
app: elasticsearch
27+
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 8 }}
2828
spec:
2929
containers:
3030
- env:
@@ -42,11 +42,11 @@ spec:
4242
value: elastic
4343
- name: ES_JAVA_OPTS
4444
value: -Xms1g -Xmx1g
45-
image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
46-
imagePullPolicy: IfNotPresent
45+
image: {{ .Values.elasticsearch.image.repo }}:{{ .Values.elasticsearch.image.tag }}
46+
imagePullPolicy: {{ .Values.global.image.imagePullPolicy }}
4747
name: elasticsearch
4848
ports:
49-
- containerPort: 9200
49+
- containerPort: {{ .Values.elasticsearch.port }}
5050
protocol: TCP
5151
resources:
5252
limits:
@@ -61,5 +61,5 @@ spec:
6161
- mountPath: /usr/share/elasticsearch/data
6262
name: data
6363
volumes:
64-
- emptyDir: { }
64+
- emptyDir: {}
6565
name: data

0 commit comments

Comments
 (0)