Skip to content

Commit

Permalink
feat: refact karpor chart, add more variables, bump to v0.5 (#36)
Browse files Browse the repository at this point in the history
* refactor: refine karpor chart, add more variables

* chore: support auto generate readme

* docs: add helm set help

* fix: lint problmes, add lint to makefile
  • Loading branch information
elliotxx authored Jul 23, 2024
1 parent d445f45 commit c95d7ed
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 89 deletions.
36 changes: 14 additions & 22 deletions charts/karpor/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
# The fields explain in the Chart.yaml can refer:
# https://helm.sh/docs/topics/charts/#the-chartyaml-file
apiVersion: v2
name: karpor
# The Chart Version
version: 0.5.0
type: application
# The Application Version in the Chart
appVersion: 0.4.2
description: A Helm chart for Karpor, a modern kubernetes visualization tool.
home: https://github.com/KusionStack/karpor
icon: https://kusionstack.io/karpor/assets/logo/logo.svg

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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: 0.4.3

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.4.2

maintainers:
- name: kusionstack
email: kusionstack@gmail.com
url: https://kusionstack.io/karpor
sources:
- https://github.com/KusionStack/charts/tree/master/charts/karpor
- https://github.com/KusionStack/karpor
keywords:
- KusionStack
- karpor
15 changes: 15 additions & 0 deletions charts/karpor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To generate help information
.DEFAULT_GOAL := help
.PHONY: help
help: ## This help message :)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: lint
lint: ## Lint, will not fix but sets exit code on error
@which yamllint > /dev/null || (echo "Installing yamllint@latest ..."; brew install yamllint && echo -e "Installation complete!\n")
@yamllint --config-file ../../.github/configs/lintconf.yaml *.yaml

.PHONY: doc
doc: ## Auto Generate README with helm-docs and README.md.gotmpl
@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")
@helm-docs
113 changes: 113 additions & 0 deletions charts/karpor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Karpor Chart

![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)

A Helm chart for Karpor, a modern kubernetes visualization tool.

**Homepage:** <https://github.com/KusionStack/karpor>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| kusionstack | <kusionstack@gmail.com> | <https://kusionstack.io/karpor> |

## Source Code

* <https://github.com/KusionStack/charts/tree/master/charts/karpor>
* <https://github.com/KusionStack/karpor>

## Prerequisites

- Helm v3.5.0+

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm repo add kusionstack https://kusionstack.github.io/charts
$ helm repo update
$ helm install karpor kusionstack/karpor
```

**Note** that installing this chart directly means it will use the [default template values](./values.yaml) for Karpor.

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.

```bash
$ helm install my-release kusionstack/karpor --set server.replicas=3 --set syncer.port=7654
```

## Chart Parameters

The following table lists the configurable parameters of the chart and their default values.

### General Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| namespace | string | `"karpor"` | Which namespace to be deployed. |
| namespaceEnabled | bool | `true` | Whether to generate namespace. |

### Global Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy to be applied to all Karpor components. |

### Karpor Server

The Karpor Server Component is main backend server. It itself is an `apiserver`, which also provides `/rest-api` to serve Dashboard.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| server.image.repo | string | `"kusionstack/karpor"` | Repository for Karpor server image. |
| server.image.tag | string | `""` | Tag for Karpor server image. Defaults to the chart's appVersion if not specified. |
| server.name | string | `"karpor-server"` | Component name for Karpor server. |
| server.port | int | `7443` | Port for Karpor server. |

### Karpor Syncer

The Karpor Syncer Component is independent server to synchronize cluster resources in real-time.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| syncer.image.repo | string | `"kusionstack/karpor"` | Repository for Karpor syncer image. |
| syncer.image.tag | string | `""` | Tag for Karpor syncer image. Defaults to the chart's appVersion if not specified. |
| syncer.name | string | `"karpor-syncer"` | Component name for Karpor syncer. |
| syncer.port | int | `7443` | Port for Karpor syncer. |

### ElasticSearch

The ElasticSearch Component to store the synchronized resources and user data.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| elasticsearch.image.repo | string | `"docker.elastic.co/elasticsearch/elasticsearch"` | Repository for ElasticSearch image. |
| elasticsearch.image.tag | string | `"8.6.2"` | Specific tag for ElasticSearch image. |
| elasticsearch.name | string | `"elasticsearch"` | Component name for ElasticSearch. |
| elasticsearch.port | int | `9200` | Port for ElasticSearch. |

### ETCD

The ETCD Component is the storage of Karpor Server as `apiserver`.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| etcd.image.repo | string | `"quay.io/coreos/etcd"` | Repository for ETCD image. |
| etcd.image.tag | string | `"v3.5.11"` | Specific tag for ETCD image. |
| etcd.name | string | `"etcd"` | Component name for ETCD. |
| etcd.port | int | `2379` | Port for ETCD. |

### Job

This one-time job is used to generate root certificates and some preliminary work.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| job.image.repo | string | `"golang"` | Repository for the Job image. |
| job.image.tag | string | `"1.19"` | Specific tag for the Job image. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
121 changes: 121 additions & 0 deletions charts/karpor/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Karpor Chart

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

## Prerequisites

- Helm v3.5.0+

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm repo add kusionstack https://kusionstack.github.io/charts
$ helm repo update
$ helm install karpor kusionstack/karpor
```

**Note** that installing this chart directly means it will use the [default template values](./values.yaml) for Karpor.

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.

```bash
$ helm install my-release kusionstack/karpor --set server.replicas=3 --set syncer.port=7654
```

## Chart Parameters

The following table lists the configurable parameters of the chart and their default values.

### General Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if not (or (hasPrefix "global" .Key) (hasPrefix "server" .Key) (hasPrefix "syncer" .Key) (hasPrefix "elasticsearch" .Key) (hasPrefix "etcd" .Key) (hasPrefix "job" .Key) ) }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### Global Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "global" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### Karpor Server

The Karpor Server Component is main backend server. It itself is an `apiserver`, which also provides `/rest-api` to serve Dashboard.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "server" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### Karpor Syncer

The Karpor Syncer Component is independent server to synchronize cluster resources in real-time.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "syncer" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### ElasticSearch

The ElasticSearch Component to store the synchronized resources and user data.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "elasticsearch" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### ETCD

The ETCD Component is the storage of Karpor Server as `apiserver`.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "etcd" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

### Job

This one-time job is used to generate root certificates and some preliminary work.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "job" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

{{- if not .SkipVersionFooter }}
{{ template "helm-docs.versionFooter" . }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/karpor/templates/_common.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "karpor.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "karpor.labels" -}}
helm.sh/chart: {{ include "karpor.chart" .context }}
{{ include "karpor.selectorLabels" (dict "context" .context "component" .component) }}
app.kubernetes.io/managed-by: {{ .context.Release.Service }}
app.kubernetes.io/version: {{ .context.Chart.AppVersion }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "karpor.selectorLabels" -}}
app.kubernetes.io/name: {{ .context.Chart.Name }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
app.kubernetes.io/instance: {{ .context.Release.Name }}
{{- end }}

18 changes: 9 additions & 9 deletions charts/karpor/templates/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ metadata:
namespace: {{ .Values.namespace }}
spec:
ports:
- port: 9200
- port: {{ .Values.elasticsearch.port }}
selector:
app: elasticsearch
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 4 }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: elasticsearch
{{- include "karpor.labels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 4 }}
name: elasticsearch
namespace: {{ .Values.namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 6 }}
template:
metadata:
labels:
app: elasticsearch
{{- include "karpor.selectorLabels" (dict "context" . "component" .Values.elasticsearch.name) | nindent 8 }}
spec:
containers:
- env:
Expand All @@ -42,11 +42,11 @@ spec:
value: elastic
- name: ES_JAVA_OPTS
value: -Xms1g -Xmx1g
image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
imagePullPolicy: IfNotPresent
image: {{ .Values.elasticsearch.image.repo }}:{{ .Values.elasticsearch.image.tag }}
imagePullPolicy: {{ .Values.global.image.imagePullPolicy }}
name: elasticsearch
ports:
- containerPort: 9200
- containerPort: {{ .Values.elasticsearch.port }}
protocol: TCP
resources:
limits:
Expand All @@ -61,5 +61,5 @@ spec:
- mountPath: /usr/share/elasticsearch/data
name: data
volumes:
- emptyDir: { }
- emptyDir: {}
name: data
Loading

0 comments on commit c95d7ed

Please sign in to comment.