diff --git a/charts/karpor/Chart.yaml b/charts/karpor/Chart.yaml index 0b46d90..9167280 100644 --- a/charts/karpor/Chart.yaml +++ b/charts/karpor/Chart.yaml @@ -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 diff --git a/charts/karpor/Makefile b/charts/karpor/Makefile new file mode 100644 index 0000000..c95d9aa --- /dev/null +++ b/charts/karpor/Makefile @@ -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 diff --git a/charts/karpor/README.md b/charts/karpor/README.md new file mode 100644 index 0000000..3255933 --- /dev/null +++ b/charts/karpor/README.md @@ -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:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| kusionstack | | | + +## Source Code + +* +* + +## 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) diff --git a/charts/karpor/README.md.gotmpl b/charts/karpor/README.md.gotmpl new file mode 100644 index 0000000..0f7e642 --- /dev/null +++ b/charts/karpor/README.md.gotmpl @@ -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 }} diff --git a/charts/karpor/templates/_common.tpl b/charts/karpor/templates/_common.tpl new file mode 100644 index 0000000..618e842 --- /dev/null +++ b/charts/karpor/templates/_common.tpl @@ -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 }} + diff --git a/charts/karpor/templates/elasticsearch.yml b/charts/karpor/templates/elasticsearch.yml index e1ecd0c..acdb301 100644 --- a/charts/karpor/templates/elasticsearch.yml +++ b/charts/karpor/templates/elasticsearch.yml @@ -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: @@ -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: @@ -61,5 +61,5 @@ spec: - mountPath: /usr/share/elasticsearch/data name: data volumes: - - emptyDir: { } + - emptyDir: {} name: data diff --git a/charts/karpor/templates/etcd.yml b/charts/karpor/templates/etcd.yml index d5c325d..eaa8f2e 100644 --- a/charts/karpor/templates/etcd.yml +++ b/charts/karpor/templates/etcd.yml @@ -5,38 +5,41 @@ metadata: namespace: {{ .Values.namespace }} spec: ports: - - port: 2379 + - port: {{ .Values.etcd.port }} selector: - app: etcd + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.etcd.name) | nindent 4 }} --- apiVersion: apps/v1 kind: StatefulSet metadata: name: etcd namespace: {{ .Values.namespace }} + labels: + {{- include "karpor.labels" (dict "context" . "component" .Values.etcd.name) | nindent 4 }} spec: serviceName: etcd replicas: 1 selector: matchLabels: - app: etcd + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.etcd.name) | nindent 6 }} template: metadata: labels: - app: etcd + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.etcd.name) | nindent 8 }} spec: containers: - name: etcd - image: quay.io/coreos/etcd:v3.5.11 + image: {{ .Values.etcd.image.repo }}:{{ .Values.etcd.image.tag }} + imagePullPolicy: {{ .Values.global.image.imagePullPolicy }} command: - /usr/local/bin/etcd - - --listen-client-urls=http://0.0.0.0:2379 - - --advertise-client-urls=http://localhost:2379 + - --listen-client-urls=http://0.0.0.0:{{ .Values.etcd.port }} + - --advertise-client-urls=http://localhost:{{ .Values.etcd.port }} env: - name: ETCD_DATA_DIR value: /etcd-data/default.etcd ports: - - containerPort: 2379 + - containerPort: {{ .Values.etcd.port }} volumeMounts: - name: data mountPath: /etcd-data diff --git a/charts/karpor/templates/job.yml b/charts/karpor/templates/job.yml index 6420556..fbdd19b 100644 --- a/charts/karpor/templates/job.yml +++ b/charts/karpor/templates/job.yml @@ -9,7 +9,8 @@ spec: spec: containers: - name: karpor-generate-cert - image: golang:1.19 + image: {{ .Values.job.image.repo }}:{{ .Values.job.image.tag }} + imagePullPolicy: {{ .Values.global.image.imagePullPolicy }} command: - /bin/sh - -c diff --git a/charts/karpor/templates/karpor-server.yml b/charts/karpor/templates/karpor-server.yml index d7ca0de..8d1d209 100644 --- a/charts/karpor/templates/karpor-server.yml +++ b/charts/karpor/templates/karpor-server.yml @@ -5,40 +5,41 @@ metadata: namespace: {{ .Values.namespace }} spec: ports: - - port: {{ .Values.port }} + - port: {{ .Values.server.port }} selector: - app: karpor-server + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 4 }} --- apiVersion: apps/v1 kind: Deployment metadata: labels: - app: karpor-server + {{- include "karpor.labels" (dict "context" . "component" .Values.server.name) | nindent 4 }} name: karpor-server namespace: {{ .Values.namespace }} spec: replicas: 1 selector: matchLabels: - app: karpor-server + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 6 }} template: metadata: labels: - app: karpor-server + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 8 }} spec: containers: - args: - --search-storage-type=elasticsearch - - --elastic-search-addresses=http://elasticsearch.karpor.svc:9200 - - --etcd-servers=http://etcd.karpor.svc:2379 - - --secure-port={{ .Values.port }} + - --elastic-search-addresses=http://elasticsearch.{{ .Values.namespace }}.svc:{{ .Values.elasticsearch.port }} + - --etcd-servers=http://etcd.{{ .Values.namespace }}.svc:{{ .Values.etcd.port }} + - --secure-port={{ .Values.server.port }} - --client-ca-file=/etc/karpor/ca.crt command: - /karpor - image: kusionstack/karpor:{{ .Values.tag }} + image: {{ .Values.server.image.repo }}:v{{ default .Chart.AppVersion .Values.server.image.tag }} + imagePullPolicy: {{ .Values.global.image.imagePullPolicy }} name: karpor-server ports: - - containerPort: {{ .Values.port }} + - containerPort: {{ .Values.server.port }} volumeMounts: - mountPath: /etc/karpor/ name: karpor-secret diff --git a/charts/karpor/templates/karpor-sync.yml b/charts/karpor/templates/karpor-sync.yml deleted file mode 100644 index 8e5c269..0000000 --- a/charts/karpor/templates/karpor-sync.yml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: karpor-syncer - name: karpor-syncer - namespace: {{ .Values.namespace }} -spec: - replicas: 1 - selector: - matchLabels: - app: karpor-syncer - template: - metadata: - labels: - app: karpor-syncer - spec: - containers: - - command: - - /karpor - args: - - syncer - - --elastic-search-addresses=http://elasticsearch.karpor.svc:9200 - env: - - name: KUBECONFIG - value: /etc/karpor/config - image: kusionstack/karpor:{{ .Values.tag }} - name: karpor-server - ports: - - containerPort: {{ .Values.port }} - volumeMounts: - - mountPath: /etc/karpor/ - name: karpor-kubeconfig - volumes: - - name: karpor-kubeconfig - configMap: - name: karpor-kubeconfig diff --git a/charts/karpor/templates/karpor-syncer.yml b/charts/karpor/templates/karpor-syncer.yml new file mode 100644 index 0000000..f55f1b7 --- /dev/null +++ b/charts/karpor/templates/karpor-syncer.yml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + {{- include "karpor.labels" (dict "context" . "component" .Values.syncer.name) | nindent 4 }} + name: karpor-syncer + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.syncer.name) | nindent 6 }} + template: + metadata: + labels: + {{- include "karpor.selectorLabels" (dict "context" . "component" .Values.syncer.name) | nindent 8 }} + spec: + containers: + - command: + - /karpor + args: + - syncer + - --elastic-search-addresses=http://elasticsearch.{{ .Values.namespace }}.svc:{{ .Values.elasticsearch.port }} + env: + - name: KUBECONFIG + value: /etc/karpor/config + image: {{ .Values.syncer.image.repo }}:v{{ default .Chart.AppVersion .Values.syncer.image.tag }} + imagePullPolicy: {{ .Values.global.image.imagePullPolicy }} + name: karpor-syncer + ports: + - containerPort: {{ .Values.syncer.port }} + volumeMounts: + - mountPath: /etc/karpor/ + name: karpor-kubeconfig + volumes: + - name: karpor-kubeconfig + configMap: + name: karpor-kubeconfig diff --git a/charts/karpor/values.yaml b/charts/karpor/values.yaml index b255e7b..bbc869c 100644 --- a/charts/karpor/values.yaml +++ b/charts/karpor/values.yaml @@ -2,7 +2,69 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. +# -- Which namespace to be deployed. namespace: karpor +# -- Whether to generate namespace. namespaceEnabled: true -port: 7443 -tag: v0.4.2 + +# Global configuration for Karpor components +global: + image: + # -- Image pull policy to be applied to all Karpor components. + imagePullPolicy: IfNotPresent + +# Configuration for Karpor server +server: + # -- Component name for Karpor server. + name: karpor-server + image: + # -- Repository for Karpor server image. + repo: kusionstack/karpor + # -- Tag for Karpor server image. Defaults to the chart's appVersion if not specified. + tag: "" + # -- Port for Karpor server. + port: 7443 + +# Configuration for Karpor syncer +syncer: + # -- Component name for Karpor syncer. + name: karpor-syncer + image: + # -- Repository for Karpor syncer image. + repo: kusionstack/karpor + # -- Tag for Karpor syncer image. Defaults to the chart's appVersion if not specified. + tag: "" + # -- Port for Karpor syncer. + port: 7443 + +# Configuration for ElasticSearch +elasticsearch: + # -- Component name for ElasticSearch. + name: elasticsearch + image: + # -- Repository for ElasticSearch image. + repo: docker.elastic.co/elasticsearch/elasticsearch + # -- Specific tag for ElasticSearch image. + tag: "8.6.2" + # -- Port for ElasticSearch. + port: 9200 + +# Configuration for ETCD +etcd: + # -- Component name for ETCD. + name: etcd + image: + # -- Repository for ETCD image. + repo: quay.io/coreos/etcd + # -- Specific tag for ETCD image. + tag: "v3.5.11" + # -- Port for ETCD. + port: 2379 + +# Configuration for Jobs +job: + image: + # -- Repository for the Job image. + repo: golang + # -- Specific tag for the Job image. + tag: "1.19"