Skip to content

Commit

Permalink
feat: create kusion helm chart (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangyang96 authored Jan 16, 2025
1 parent 60c7964 commit 26d8106
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/kusion/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
17 changes: 17 additions & 0 deletions charts/kusion/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: kusion
version: 0.1.0
type: application
appVersion: "1.0.0"
description: A Helm chart for deploying Kusion - An Intent-Driven Platform Orchestrator
home: https://github.com/KusionStack/kusion
icon: https://github.com/KusionStack/kusion/docs/logo.png
maintainers:
- name: kusionstack
email: [email protected]
url: https://kusionstack.io/docs
sources:
- https://github.com/KusionStack/kusion
keywords:
- KusionStack
- kusion
15 changes: 15 additions & 0 deletions charts/kusion/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
119 changes: 119 additions & 0 deletions charts/kusion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Kusion Chart

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kusion)](https://artifacthub.io/packages/helm/kusionstack/kusion)

A Helm chart for deploying Kusion - An Intent-Driven Platform Orchestrator

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

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| kusionstack | <[email protected]> | <https://kusionstack.io/docs> |

## Source Code

* <https://github.com/KusionStack/kusion>

## Prerequisites

- Helm v3+

## Installing the Chart

First, add the Kusion chart repo to your local repository.

```shell
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
```

Then you can use the following command to install the latest version of Kusion.

```shell
helm install kusion-release kusionstack/kusion
```

> Note that installing this chart directly means it will use the [default template values](./values.yaml) for Kusion.
You may have to set your specific configurations if it is deployed into a production cluster, or you want to customize the chart configuration, such as `resources`, `replicas`, `port` etc.

All configurable parameters of the Kusion chart are detailed [here](#chart-parameters).

```shell
helm install kusion-release kusionstack/kusion --set server.port=8080 --set mysql.enabled=true --set mysql.database=kusionDB
```

## Chart Parameters

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

### General Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| namespace | string | `"kusion"` | Which namespace to be deployed |
| namespaceEnabled | bool | `true` | Whether to generate namespace |
| registryProxy | string | `""` | Image registry proxy will be the prefix as all component images |

### Global Parameters

| Key | Type | Default | Description |
|-----|------|---------|-------------|

### Kusion Server

The Kusion Server Component is the main backend server that provides the core functionality and REST APIs.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| server.args.authEnabled | bool | `false` | Whether to enable authentication |
| server.args.authKeyType | string | `"RSA"` | Authentication key type |
| server.args.authWhitelist | list | `[]` | Authentication whitelist |
| server.args.autoMigrate | bool | `true` | Whether to enable automatic migration |
| server.args.dbHost | string | `""` | Database host |
| server.args.dbName | string | `""` | Database name |
| server.args.dbPassword | string | `""` | Database password |
| server.args.dbPort | int | `3306` | Database port |
| server.args.dbUser | string | `""` | Database user |
| server.args.defaultSourceRemote | string | `""` | Default source URL |
| server.args.logFilePath | string | `"/logs/kusion.log"` | Logging |
| server.args.maxAsyncBuffer | int | `100` | Maximum number of buffer zones during concurrent async executions including generate, preview, apply and destroy |
| server.args.maxAsyncConcurrent | int | `1` | Maximum number of concurrent async executions including generate, preview, apply and destroy |
| server.args.maxConcurrent | int | `10` | Maximum number of concurrent executions including preview, apply and destroy |
| server.args.migrateFile | string | `""` | Migration file path |
| server.env | list | `[]` | Additional environment variables for the server |
| server.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy |
| server.image.repo | string | `"kusionstack/kusion"` | Repository for Kusion server image |
| server.image.tag | string | `"latest"` | Tag for Kusion server image. Defaults to the chart's appVersion if not specified |
| server.name | string | `"kusion-server"` | Component name for kusion server |
| server.port | int | `80` | Port for kusion server |
| server.replicas | int | `1` | The number of kusion server pods to run |
| server.resources | object | `{"limits":{"cpu":"500m","memory":"1Gi"},"requests":{"cpu":"250m","memory":"256Mi"}}` | Resource limits and requests for the kusion server pods |
| server.serviceType | string | `"ClusterIP"` | Service type for the kusion server. The available type values list as ["ClusterIP"、"NodePort"、"LoadBalancer"]. |

### MySQL Database

The MySQL database is used to store Kusion's persistent data.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| mysql.database | string | `"kusionDB"` | MySQL database name |
| mysql.enabled | bool | `true` | Whether to enable MySQL deployment |
| mysql.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy |
| mysql.image.repo | string | `"mysql"` | Repository for MySQL image |
| mysql.image.tag | string | `"8.0"` | Specific tag for MySQL image |
| mysql.name | string | `"mysql"` | Component name for MySQL |
| mysql.password | string | `""` | MySQL password |
| mysql.persistence.accessModes | list | `["ReadWriteOnce"]` | Access modes for MySQL PVC |
| mysql.persistence.size | string | `"10Gi"` | Size of MySQL persistent volume |
| mysql.persistence.storageClass | string | `""` | Storage class for MySQL PVC |
| mysql.port | int | `3306` | Port for MySQL |
| mysql.replicas | int | `1` | The number of MySQL pods to run |
| mysql.resources | object | `{"limits":{"cpu":"1000m","memory":"1Gi"},"requests":{"cpu":"250m","memory":"512Mi"}}` | Resource limits and requests for MySQL pods |
| mysql.rootPassword | string | `""` | MySQL root password |
| mysql.user | string | `"kusion"` | MySQL user |

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

{{ template "chart.badgesSection" . }} [![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kusion)](https://artifacthub.io/packages/helm/kusionstack/kusion)

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

## Prerequisites

- Helm v3+

## Installing the Chart

First, add the Kusion chart repo to your local repository.

```shell
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
```

Then you can use the following command to install the latest version of Kusion.

```shell
helm install kusion-release kusionstack/kusion
```

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

You may have to set your specific configurations if it is deployed into a production cluster, or you want to customize the chart configuration, such as `resources`, `replicas`, `port` etc.

All configurable parameters of the Kusion chart are detailed [here](#chart-parameters).

```shell
helm install kusion-release kusionstack/kusion --set server.port=8080 --set mysql.enabled=true --set mysql.database=kusionDB
```

## 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 "mysql" .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 }}

### Kusion Server

The Kusion Server Component is the main backend server that provides the core functionality and REST APIs.

| 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 }}

### MySQL Database

The MySQL database is used to store Kusion's persistent data.

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

----------------------------------------------
Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs)
28 changes: 28 additions & 0 deletions charts/kusion/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

To learn more about the release, try:

$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}

{{- if .Values.mysql.enabled }}

MySQL is enabled. The following credentials were configured:
- Database: {{ .Values.mysql.database }}
- User: {{ .Values.mysql.user }}
Please retrieve the passwords from the secret: {{ .Values.mysql.name }}-secret
{{- end }}

The Kusion server can be accessed:
- Within cluster: {{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}
{{- if eq .Values.server.serviceType "NodePort" }}
- From outside: <node-ip>:<node-port>
You can get the node port by running:
kubectl get svc {{ .Values.server.name }} -n {{ .Values.namespace }} -o jsonpath='{.spec.ports[0].nodePort}'
{{- else if eq .Values.server.serviceType "LoadBalancer" }}
- From outside: <external-ip>:{{ .Values.server.port }}
You can get the external IP by running:
kubectl get svc {{ .Values.server.name }} -n {{ .Values.namespace }}
{{- end }}
35 changes: 35 additions & 0 deletions charts/kusion/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kusion.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "kusion.labels" -}}
helm.sh/chart: {{ include "kusion.chart" .context }}
{{ include "kusion.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 "kusion.selectorLabels" -}}
app.kubernetes.io/name: {{ .context.Chart.Name }}
{{- if .component }}
app.kubernetes.io/component: {{ .component }}
{{- end }}
app.kubernetes.io/instance: {{ .context.Release.Name }}
{{- end }}

{{/*
Real image
*/}}
{{- define "kusion.realImage" -}}
{{- trimPrefix "/" (list (trimAll "/" .context.Values.registryProxy)
.repo | join "/") }}:{{ if .needV }}v{{ end }}{{ default .context.Chart.AppVersion .tag }}
{{- end -}}
Loading

0 comments on commit 26d8106

Please sign in to comment.