From bbfc1b6e4c407db6dfa4fd396b163fe8d4413e92 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Thu, 26 Dec 2024 20:15:40 +0800 Subject: [PATCH 1/5] feat: create kusion helm chart --- charts/kusion/.helmignore | 23 +++++ charts/kusion/Chart.yaml | 17 ++++ charts/kusion/Makefile | 15 +++ charts/kusion/README.md | 119 ++++++++++++++++++++++ charts/kusion/README.md.gotmpl | 91 +++++++++++++++++ charts/kusion/templates/NOTES.txt | 28 +++++ charts/kusion/templates/_helpers.tpl | 35 +++++++ charts/kusion/templates/kusion-server.yml | 84 +++++++++++++++ charts/kusion/templates/mysql.yml | 90 ++++++++++++++++ charts/kusion/templates/namespace.yaml | 6 ++ charts/kusion/values.yaml | 115 +++++++++++++++++++++ 11 files changed, 623 insertions(+) create mode 100644 charts/kusion/.helmignore create mode 100644 charts/kusion/Chart.yaml create mode 100644 charts/kusion/Makefile create mode 100644 charts/kusion/README.md create mode 100644 charts/kusion/README.md.gotmpl create mode 100644 charts/kusion/templates/NOTES.txt create mode 100644 charts/kusion/templates/_helpers.tpl create mode 100644 charts/kusion/templates/kusion-server.yml create mode 100644 charts/kusion/templates/mysql.yml create mode 100644 charts/kusion/templates/namespace.yaml create mode 100644 charts/kusion/values.yaml diff --git a/charts/kusion/.helmignore b/charts/kusion/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/kusion/.helmignore @@ -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/ diff --git a/charts/kusion/Chart.yaml b/charts/kusion/Chart.yaml new file mode 100644 index 0000000..6adc120 --- /dev/null +++ b/charts/kusion/Chart.yaml @@ -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: kusionstack@gmail.com + url: https://kusionstack.io/docs +sources: + - https://github.com/KusionStack/kusion +keywords: + - KusionStack + - kusion diff --git a/charts/kusion/Makefile b/charts/kusion/Makefile new file mode 100644 index 0000000..c95d9aa --- /dev/null +++ b/charts/kusion/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/kusion/README.md b/charts/kusion/README.md new file mode 100644 index 0000000..31e5eb3 --- /dev/null +++ b/charts/kusion/README.md @@ -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:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| kusionstack | | | + +## Source Code + +* + +## 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) \ No newline at end of file diff --git a/charts/kusion/README.md.gotmpl b/charts/kusion/README.md.gotmpl new file mode 100644 index 0000000..2071efa --- /dev/null +++ b/charts/kusion/README.md.gotmpl @@ -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) \ No newline at end of file diff --git a/charts/kusion/templates/NOTES.txt b/charts/kusion/templates/NOTES.txt new file mode 100644 index 0000000..09ec1db --- /dev/null +++ b/charts/kusion/templates/NOTES.txt @@ -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: : + 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: :{{ .Values.server.port }} + You can get the external IP by running: + kubectl get svc {{ .Values.server.name }} -n {{ .Values.namespace }} +{{- end }} diff --git a/charts/kusion/templates/_helpers.tpl b/charts/kusion/templates/_helpers.tpl new file mode 100644 index 0000000..2ca1dcc --- /dev/null +++ b/charts/kusion/templates/_helpers.tpl @@ -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 -}} \ No newline at end of file diff --git a/charts/kusion/templates/kusion-server.yml b/charts/kusion/templates/kusion-server.yml new file mode 100644 index 0000000..946e6ea --- /dev/null +++ b/charts/kusion/templates/kusion-server.yml @@ -0,0 +1,84 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.server.name }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.server.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 4 }} + type: {{ .Values.server.serviceType }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + {{- include "kusion.labels" (dict "context" . "component" .Values.server.name) | nindent 4 }} + name: {{ .Values.server.name }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.server.replicas }} + selector: + matchLabels: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 6 }} + template: + metadata: + labels: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.server.name) | nindent 8 }} + spec: + containers: + - name: {{ .Values.server.name }} + image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.server.image.repo "tag" .Values.server.image.tag) }} + imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} + ports: + - name: http + containerPort: {{ .Values.server.port }} + protocol: TCP + command: + - /usr/local/bin/kusion + - server + args: + - --port={{ .Values.server.port }} + - --auth-enabled={{ .Values.server.args.authEnabled }} + {{- if .Values.server.args.authWhitelist }} + - --auth-whitelist={{ .Values.server.args.authWhitelist | join "," }} + {{- end }} + - --auth-key-type={{ .Values.server.args.authKeyType }} + - --max-concurrent={{ .Values.server.args.maxConcurrent }} + - --max-async-buffer={{ .Values.server.args.maxAsyncBuffer }} + - --max-async-concurrent={{ .Values.server.args.maxAsyncConcurrent }} + - --log-file-path={{ .Values.server.args.logFilePath }} + - --db-name={{ if .Values.mysql.enabled }}{{ .Values.mysql.database }}{{ else }}{{ .Values.server.args.dbName }}{{ end }} + - --db-user={{ if .Values.mysql.enabled }}{{ .Values.mysql.user }}{{ else }}{{ .Values.server.args.dbUser }}{{ end }} + {{- if .Values.mysql.enabled }} + - --db-pass=$(MYSQL_PASSWORD) + {{- else if .Values.server.args.dbPassword }} + - --db-pass={{ .Values.server.args.dbPassword }} + {{- end }} + - --db-host={{ if .Values.mysql.enabled }}{{ .Values.mysql.name }}.{{ .Values.namespace }}.svc{{ else }}{{ .Values.server.args.dbHost }}{{ end }} + - --db-port={{ if .Values.mysql.enabled }}{{ .Values.mysql.port }}{{ else }}{{ .Values.server.args.dbPort }}{{ end }} + - --auto-migrate={{ if .Values.mysql.enabled }}true{{ else }}{{ .Values.server.args.autoMigrate }}{{ end }} + {{- if and (not .Values.mysql.enabled) .Values.server.args.migrateFile }} + - --migrate-file={{ .Values.server.args.migrateFile }} + {{- end }} + {{- if .Values.server.args.defaultSourceRemote }} + - --default-source-remote={{ .Values.server.args.defaultSourceRemote }} + {{- end }} + env: + {{- range $key, $value := .Values.server.env }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + {{- if .Values.mysql.enabled }} + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.mysql.name }}-secret + key: mysql-password + {{- end }} + resources: + {{- toYaml .Values.server.resources | nindent 12 }} \ No newline at end of file diff --git a/charts/kusion/templates/mysql.yml b/charts/kusion/templates/mysql.yml new file mode 100644 index 0000000..c64c60a --- /dev/null +++ b/charts/kusion/templates/mysql.yml @@ -0,0 +1,90 @@ +{{- if .Values.mysql.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.mysql.name }}-secret + namespace: {{ .Values.namespace }} +type: Opaque +data: + mysql-root-password: {{ if .Values.mysql.rootPassword }}{{ .Values.mysql.rootPassword | b64enc }}{{ else }}{{ randAlphaNum 16 | b64enc }}{{ end }} + mysql-password: {{ if .Values.mysql.password }}{{ .Values.mysql.password | b64enc }}{{ else }}{{ randAlphaNum 16 | b64enc }}{{ end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.mysql.name }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.mysql.port }} + targetPort: mysql + protocol: TCP + name: mysql + selector: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.mysql.name) | nindent 4 }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Values.mysql.name }} + namespace: {{ .Values.namespace }} + labels: + {{- include "kusion.labels" (dict "context" . "component" .Values.mysql.name) | nindent 4 }} +spec: + serviceName: {{ .Values.mysql.name }} + replicas: {{ .Values.mysql.replicas }} + selector: + matchLabels: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.mysql.name) | nindent 6 }} + template: + metadata: + labels: + {{- include "kusion.selectorLabels" (dict "context" . "component" .Values.mysql.name) | nindent 8 }} + spec: + containers: + - name: mysql + image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.mysql.image.repo "tag" .Values.mysql.image.tag) }} + imagePullPolicy: {{ .Values.mysql.image.imagePullPolicy }} + ports: + - name: mysql + containerPort: {{ .Values.mysql.port }} + protocol: TCP + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.mysql.name }}-secret + key: mysql-root-password + - name: MYSQL_DATABASE + value: {{ .Values.mysql.database }} + - name: MYSQL_USER + value: {{ .Values.mysql.user }} + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.mysql.name }}-secret + key: mysql-password + resources: + {{- toYaml .Values.mysql.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /var/lib/mysql + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: + {{- range .Values.mysql.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.mysql.persistence.size | quote }} + {{- if .Values.mysql.persistence.storageClass }} + {{- if (eq "-" .Values.mysql.persistence.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.mysql.persistence.storageClass }}" + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/kusion/templates/namespace.yaml b/charts/kusion/templates/namespace.yaml new file mode 100644 index 0000000..749f665 --- /dev/null +++ b/charts/kusion/templates/namespace.yaml @@ -0,0 +1,6 @@ +{{- if .Values.namespaceEnabled -}} +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} +{{- end }} diff --git a/charts/kusion/values.yaml b/charts/kusion/values.yaml new file mode 100644 index 0000000..d3259a9 --- /dev/null +++ b/charts/kusion/values.yaml @@ -0,0 +1,115 @@ +# -- Which namespace to be deployed +namespace: kusion +# -- Whether to generate namespace +namespaceEnabled: true +# -- Image registry proxy will be the prefix as all component images +registryProxy: "" + +# Configuration for Kusion server +server: + # -- Component name for kusion server + name: kusion-server + # -- The number of kusion server pods to run + replicas: 1 + # -- Port for kusion server + port: 80 + image: + # -- Repository for Kusion server image + repo: kusionstack/kusion + # -- Tag for Kusion server image. Defaults to the chart's appVersion if not specified + tag: "latest" + # -- Image pull policy + imagePullPolicy: IfNotPresent + # -- Resource limits and requests for the kusion server pods + resources: + requests: + cpu: 250m + memory: 256Mi + limits: + cpu: 500m + memory: 1Gi + # -- Service type for the kusion server. The available type values list as ["ClusterIP"、"NodePort"、"LoadBalancer"]. + serviceType: ClusterIP + # Additional command line arguments for the server + args: + # -- Whether to enable authentication + authEnabled: false + # -- Authentication whitelist + authWhitelist: [] + # -- Authentication key type + authKeyType: "RSA" + + # -- Maximum number of concurrent executions including preview, apply and destroy + maxConcurrent: 10 + # -- Maximum number of buffer zones during concurrent async executions including generate, preview, apply and destroy + maxAsyncBuffer: 100 + # -- Maximum number of concurrent async executions including generate, preview, apply and destroy + maxAsyncConcurrent: 1 + + # -- Logging + logFilePath: "/logs/kusion.log" + + # Database connection settings. + # If MySQL is enabled (mysql.enabled=true), these settings will use the MySQL configuration defined below by default. + # Otherwise, provide custom database connection details. + # -- Database name + dbName: "" + # -- Database user + dbUser: "" + # -- Database password + dbPassword: "" + # -- Database host + dbHost: "" + # -- Database port + dbPort: 3306 + # -- Whether to enable automatic migration + autoMigrate: true + # -- Migration file path + migrateFile: "" + # -- Default source URL + defaultSourceRemote: "" + # -- Additional environment variables for the server + env: [] + +# MySQL configuration +mysql: + # -- Whether to enable MySQL deployment + enabled: true + # -- Component name for MySQL + name: mysql + # -- The number of MySQL pods to run + replicas: 1 + # -- Port for MySQL + port: 3306 + image: + # -- Repository for MySQL image + repo: mysql + # -- Specific tag for MySQL image + tag: "8.0" + # -- Image pull policy + imagePullPolicy: IfNotPresent + # -- Resource limits and requests for MySQL pods + resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: 1000m + memory: 1Gi + # -- MySQL root password + rootPassword: "" + # -- MySQL database name + database: kusion + # -- MySQL user + user: kusion + # -- MySQL password + password: "" + # MySQL persistence settings + persistence: + # -- Size of MySQL persistent volume + size: 10Gi + # -- Storage class for MySQL PVC + storageClass: "" + # -- Access modes for MySQL PVC + accessModes: + - ReadWriteOnce From fd256659b0185f00751b58e6b706ab4aec7d433a Mon Sep 17 00:00:00 2001 From: liuhaoming Date: Tue, 14 Jan 2025 20:33:57 +0800 Subject: [PATCH 2/5] feat: add post-run job for kusion --- charts/kusion/templates/post-run-job.yaml | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 charts/kusion/templates/post-run-job.yaml diff --git a/charts/kusion/templates/post-run-job.yaml b/charts/kusion/templates/post-run-job.yaml new file mode 100644 index 0000000..3e85c91 --- /dev/null +++ b/charts/kusion/templates/post-run-job.yaml @@ -0,0 +1,86 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ .Release.Name }}-post-install-job" + namespace: "{{ .Values.namespace }}" + labels: + app.kubernetes.io/instance: "{{ .Release.Name }}" + app.kubernetes.io/version: "{{ .Chart.AppVersion }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + annotations: + "helm.sh/hook": "post-install" + "helm.sh/hook-weight": "0" + "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" +spec: + template: + metadata: + name: "{{ .Release.Name }}" + labels: + app.kubernetes.io/instance: "{{ .Release.Name }}" + app.kubernetes.io/version: "{{ .Chart.AppVersion }}" + helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + spec: + restartPolicy: "Never" + containers: + - name: register-necessary-modules + image: curlimages/curl:latest + env: + - name: KUSION_SERVER_ENDPOINT + value: "{{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}" + command: + - /bin/sh + - -c + - > + echo "Calling Kusion API for Module Registration..."; + + echo "Registering kam module..."; + curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \ + -H "Content-Type: application/json" \ + -d '{"name":"kam","url":"oci://ghcr.io/kusionstack/kam"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \ + -H "Content-Type: application/json" \ + -d '{"name":"kam","description":"The kam module represents a Kusion opinionated abstraction of the core concepts during application delivery."}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \ + -H "Content-Type: application/json" \ + -d '{"name":"kam","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/app-configuration"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \ + -H "Content-Type: application/json" \ + -d '{"name":"kam","url":"oci://ghcr.io/kusionstack/kam"}'; + + echo "Registering service module..."; + curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \ + -H "Content-Type: application/json" \ + -d '{"name":"service","url":"oci://ghcr.io/kusionstack/service"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \ + -H "Content-Type: application/json" \ + -d '{"name":"service","description":"The service module represents a kind of workload profile that describes how to run your application code."}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \ + -H "Content-Type: application/json" \ + -d '{"name":"service","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/workload/service"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \ + -H "Content-Type: application/json" \ + -d '{"name":"service","url":"oci://ghcr.io/kusionstack/service"}'; + + echo "Registering network module..."; + curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \ + -H "Content-Type: application/json" \ + -d '{"name":"network","url":"oci://ghcr.io/kusionstack/network"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \ + -H "Content-Type: application/json" \ + -d '{"name":"network","description":"The network module represents a network accessory of workload, typically containing exposed ports and a load balancer."}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \ + -H "Content-Type: application/json" \ + -d '{"name":"network","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/network"}'; + + curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \ + -H "Content-Type: application/json" \ + -d '{"name":"network","url":"oci://ghcr.io/kusionstack/network"}'; + backoffLimit: 10 From d944bc79a183b436a22bc95ab6d43cf159722dbb Mon Sep 17 00:00:00 2001 From: liuhaoming Date: Tue, 14 Jan 2025 20:53:31 +0800 Subject: [PATCH 3/5] feat: add configurations for kubeconfig files in kusion --- charts/kusion/templates/kusion-server.yml | 20 +++++++++++++++++++- charts/kusion/values.yaml | 10 ++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/charts/kusion/templates/kusion-server.yml b/charts/kusion/templates/kusion-server.yml index 946e6ea..5c0428d 100644 --- a/charts/kusion/templates/kusion-server.yml +++ b/charts/kusion/templates/kusion-server.yml @@ -81,4 +81,22 @@ spec: key: mysql-password {{- end }} resources: - {{- toYaml .Values.server.resources | nindent 12 }} \ No newline at end of file + {{- toYaml .Values.server.resources | nindent 12 }} + volumeMounts: + - name: kubeconfig-volume + mountPath: {{ .Values.kubeConfigVolumeMountPath }} + volumes: + - name: kubeconfig-volume + secret: + secretName: {{ .Values.server.name }}-kubeconfigs +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.server.name }}-kubeconfigs + namespace: {{ .Values.namespace }} +type: Opaque +data: + {{- range .Values.secrets.kubeConfigs }} + {{ .key }}: {{ .value | b64enc | quote }} + {{- end }} diff --git a/charts/kusion/values.yaml b/charts/kusion/values.yaml index d3259a9..20fd6e9 100644 --- a/charts/kusion/values.yaml +++ b/charts/kusion/values.yaml @@ -113,3 +113,13 @@ mysql: # -- Access modes for MySQL PVC accessModes: - ReadWriteOnce + +# -- Volume mount path for KubeConfig files +kubeConfigVolumeMountPath: /var/run/secrets/kubernetes.io/kubeconfigs/ + +# KubeConfig configuration +secrets: + kubeConfigs: + - key: "kubeconfig-0" + value: | + Please fill in your KubeConfig contents here. From 8c6cca925fc5d6bc5a5bbfb959f3fb80a264a696 Mon Sep 17 00:00:00 2001 From: liuhaoming Date: Wed, 15 Jan 2025 14:35:42 +0800 Subject: [PATCH 4/5] fix: a lint error --- charts/kusion/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/kusion/values.yaml b/charts/kusion/values.yaml index 20fd6e9..adb271a 100644 --- a/charts/kusion/values.yaml +++ b/charts/kusion/values.yaml @@ -118,8 +118,8 @@ mysql: kubeConfigVolumeMountPath: /var/run/secrets/kubernetes.io/kubeconfigs/ # KubeConfig configuration -secrets: - kubeConfigs: +secrets: + kubeConfigs: - key: "kubeconfig-0" value: | - Please fill in your KubeConfig contents here. + Please fill in your KubeConfig contents here. From 9c32ed6b76f808d7d5da8c98b2eb01656e4df4a4 Mon Sep 17 00:00:00 2001 From: liuhaoming Date: Thu, 16 Jan 2025 15:39:05 +0800 Subject: [PATCH 5/5] fix: update post-run-job.yaml --- charts/kusion/templates/post-run-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/kusion/templates/post-run-job.yaml b/charts/kusion/templates/post-run-job.yaml index 3e85c91..3b9be2a 100644 --- a/charts/kusion/templates/post-run-job.yaml +++ b/charts/kusion/templates/post-run-job.yaml @@ -48,7 +48,7 @@ spec: curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \ -H "Content-Type: application/json" \ - -d '{"name":"kam","url":"oci://ghcr.io/kusionstack/kam"}'; + -d '{"name":"kam","url":"git://github.com/KusionStack/kam"}'; echo "Registering service module..."; curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \