Skip to content

Commit 4a868a2

Browse files
authored
feat: update kubeconfig configuration format in kusion (#97)
<!-- Thank you for contributing to KusionStack! Note: 1. With pull requests: - Open your pull request against "main" - Your pull request should have no more than two commits, if not you should squash them. - It should pass all tests in the available continuous integration systems such as GitHub Actions. - You should add/modify tests to cover your proposed code changes. - If your pull request contains a new feature, please document it on the README. 2. Please create an issue first to describe the problem. We recommend that link the issue with the PR in the following question. For more info, check https://kusionstack.io/docs/governance/contribute/ --> #### 1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".): - [X] N - [ ] Y <!-- You can add issue references here. e.g. fix #123, re #123, fix https://github.com/XXX/issues/44 --> #### 2. What is the scope of this PR (e.g. component or file name): charts/kusion scripts/install-kusion.sh <!-- You can add the scope of this change here. e.g. /src/server/core.rs, kusionstack/KCLVM/kclvm-parser --> #### 3. Provide a description of the PR(e.g. more details, effects, motivations or doc link): - add a script to install kusion - update kubeconfig configuration format in values.yaml to support easier installation - bump appversion and chart version to sync kusion's version - update doc - add kubeconfig configuration part and update installation instructions <!-- You can choose a brief description here --> - [X] Affects user behaviors - [ ] Contains syntax changes - [X] Contains variable changes - [ ] Contains experimental features - [ ] Performance regression: Consumes more CPU - [ ] Performance regression: Consumes more Memory - [X] Other <!-- You can add more details here. e.g. Call method "XXXX" to ..... in order to ...., More details: https://XXXX.com/doc...... --> #### 4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link): - [ ] N - [X] Y <!-- You can add more details here. e.g. Calling method "XXXX" will cause the "XXXX", "XXXX" modules to be affected. More details: https://XXXX.com/doc...... --> #### 5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: <!-- You can choose a brief description here --> - [ ] Unit test - [ ] Integration test - [ ] Benchmark (add benchmark stats below) - [X] Manual test (add detailed scripts or steps below) - [ ] Other <!-- You can add more details here. e.g. The test case in XXXX is used to ..... test cases in /src/tests/XXXXX test cases https://github.com/XXX/pull/44 benchmark stats: time XXX ms --> #### 6. Release note <!-- compatibility change, improvement, bugfix, and new feature need a release note --> Please refer to [Release Notes Language Style Guide](https://kusionstack.io/docs/governance/release-policy/) to write a quality release note. ```release-note None ```
1 parent 26d8106 commit 4a868a2

File tree

8 files changed

+110
-44
lines changed

8 files changed

+110
-44
lines changed

charts/kusion/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: v2
22
name: kusion
3-
version: 0.1.0
3+
version: 0.14.0
44
type: application
5-
appVersion: "1.0.0"
6-
description: A Helm chart for deploying Kusion - An Intent-Driven Platform Orchestrator
5+
appVersion: 0.14.0
6+
description: Kusion - An Intent-Driven Platform Orchestrator
77
home: https://github.com/KusionStack/kusion
88
icon: https://github.com/KusionStack/kusion/docs/logo.png
99
maintainers:

charts/kusion/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Kusion Chart
22

3-
![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)
3+
![Version: 0.14.0](https://img.shields.io/badge/Version-0.14.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.14.0](https://img.shields.io/badge/AppVersion-0.14.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)
44

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

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

@@ -42,7 +42,7 @@ You may have to set your specific configurations if it is deployed into a produc
4242
All configurable parameters of the Kusion chart are detailed [here](#chart-parameters).
4343

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

4848
## Chart Parameters
@@ -86,7 +86,7 @@ The Kusion Server Component is the main backend server that provides the core fu
8686
| server.env | list | `[]` | Additional environment variables for the server |
8787
| server.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy |
8888
| server.image.repo | string | `"kusionstack/kusion"` | Repository for Kusion server image |
89-
| server.image.tag | string | `"latest"` | Tag for Kusion server image. Defaults to the chart's appVersion if not specified |
89+
| server.image.tag | string | `""` | Tag for Kusion server image. Defaults to the chart's appVersion if not specified |
9090
| server.name | string | `"kusion-server"` | Component name for kusion server |
9191
| server.port | int | `80` | Port for kusion server |
9292
| server.replicas | int | `1` | The number of kusion server pods to run |
@@ -99,7 +99,7 @@ The MySQL database is used to store Kusion's persistent data.
9999

100100
| Key | Type | Default | Description |
101101
|-----|------|---------|-------------|
102-
| mysql.database | string | `"kusionDB"` | MySQL database name |
102+
| mysql.database | string | `"kusion"` | MySQL database name |
103103
| mysql.enabled | bool | `true` | Whether to enable MySQL deployment |
104104
| mysql.image.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy |
105105
| mysql.image.repo | string | `"mysql"` | Repository for MySQL image |
@@ -115,5 +115,14 @@ The MySQL database is used to store Kusion's persistent data.
115115
| mysql.rootPassword | string | `""` | MySQL root password |
116116
| mysql.user | string | `"kusion"` | MySQL user |
117117

118+
### KubeConfig
119+
120+
The KubeConfig is used to store the KubeConfig files for the Kusion Server.
121+
122+
| Key | Type | Default | Description |
123+
|-----|------|---------|-------------|
124+
| kubeconfig.kubeConfigVolumeMountPath | string | `"/var/run/secrets/kubernetes.io/kubeconfigs/"` | Volume mount path for KubeConfig files |
125+
| kubeconfig.kubeConfigs | object | `{}` | KubeConfig contents map |
126+
118127
----------------------------------------------
119128
Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs)

charts/kusion/README.md.gotmpl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You may have to set your specific configurations if it is deployed into a produc
3636
All configurable parameters of the Kusion chart are detailed [here](#chart-parameters).
3737

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

4242
## Chart Parameters
@@ -48,7 +48,7 @@ The following table lists the configurable parameters of the chart and their def
4848
| Key | Type | Default | Description |
4949
|-----|------|---------|-------------|
5050
{{- range .Values }}
51-
{{- if not (or (hasPrefix "global" .Key) (hasPrefix "server" .Key) (hasPrefix "mysql" .Key)) }}
51+
{{- if not (or (hasPrefix "global" .Key) (hasPrefix "server" .Key) (hasPrefix "mysql" .Key) (hasPrefix "kubeconfig" .Key)) }}
5252
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
5353
{{- end }}
5454
{{- end }}
@@ -87,5 +87,17 @@ The MySQL database is used to store Kusion's persistent data.
8787
{{- end }}
8888
{{- end }}
8989

90+
### KubeConfig
91+
92+
The KubeConfig is used to store the KubeConfig files for the Kusion Server.
93+
94+
| Key | Type | Default | Description |
95+
|-----|------|---------|-------------|
96+
{{- range .Values }}
97+
{{- if hasPrefix "kubeconfig" .Key }}
98+
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
99+
{{- end }}
100+
{{- end }}
101+
90102
----------------------------------------------
91103
Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs)

charts/kusion/templates/NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ MySQL is enabled. The following credentials were configured:
1616
{{- end }}
1717

1818
The Kusion server can be accessed:
19-
- Within cluster: {{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}
19+
- Within cluster: {{ .Values.server.name }}.{{ .Values.namespace }}.svc.cluster.local:{{ .Values.server.port }}
2020
{{- if eq .Values.server.serviceType "NodePort" }}
2121
- From outside: <node-ip>:<node-port>
2222
You can get the node port by running:

charts/kusion/templates/kusion-server.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
spec:
3333
containers:
3434
- name: {{ .Values.server.name }}
35-
image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.server.image.repo "tag" .Values.server.image.tag) }}
35+
image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.server.image.repo "tag" .Values.server.image.tag "needV" (not (hasPrefix "v" .Values.server.image.tag))) }}
3636
imagePullPolicy: {{ .Values.server.image.imagePullPolicy }}
3737
ports:
3838
- name: http
@@ -84,7 +84,7 @@ spec:
8484
{{- toYaml .Values.server.resources | nindent 12 }}
8585
volumeMounts:
8686
- name: kubeconfig-volume
87-
mountPath: {{ .Values.kubeConfigVolumeMountPath }}
87+
mountPath: {{ .Values.kubeconfig.kubeConfigVolumeMountPath }}
8888
volumes:
8989
- name: kubeconfig-volume
9090
secret:
@@ -97,6 +97,14 @@ metadata:
9797
namespace: {{ .Values.namespace }}
9898
type: Opaque
9999
data:
100-
{{- range .Values.secrets.kubeConfigs }}
101-
{{ .key }}: {{ .value | b64enc | quote }}
100+
{{- range $key, $value := .Values.kubeconfig.kubeConfigs }}
101+
{{- if kindIs "string" $value }}
102+
{{- if contains " " $value }}
103+
{{/* if contains space, it is a plain yaml format */}}
104+
{{ $key }}: {{ $value | b64enc | quote }}
105+
{{- else }}
106+
{{/* if it is a whole string without spaces, it is already base64 encoded */}}
107+
{{ $key }}: {{ $value | quote }}
108+
{{- end }}
109+
{{- end }}
102110
{{- end }}

charts/kusion/templates/post-run-job.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
apiVersion: batch/v1
22
kind: Job
3-
metadata:
3+
metadata:
44
name: "{{ .Release.Name }}-post-install-job"
55
namespace: "{{ .Values.namespace }}"
6-
labels:
6+
labels:
77
app.kubernetes.io/instance: "{{ .Release.Name }}"
88
app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
99
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
10-
annotations:
10+
annotations:
1111
"helm.sh/hook": "post-install"
1212
"helm.sh/hook-weight": "0"
1313
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
14-
spec:
15-
template:
16-
metadata:
14+
spec:
15+
template:
16+
metadata:
1717
name: "{{ .Release.Name }}"
18-
labels:
18+
labels:
1919
app.kubernetes.io/instance: "{{ .Release.Name }}"
2020
app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
2121
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
22-
spec:
22+
spec:
2323
restartPolicy: "Never"
24-
containers:
24+
containers:
2525
- name: register-necessary-modules
2626
image: curlimages/curl:latest
27-
env:
27+
env:
2828
- name: KUSION_SERVER_ENDPOINT
2929
value: "{{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}"
30-
command:
30+
command:
3131
- /bin/sh
3232
- -c
3333
- >
@@ -37,11 +37,11 @@ spec:
3737
curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \
3838
-H "Content-Type: application/json" \
3939
-d '{"name":"kam","url":"oci://ghcr.io/kusionstack/kam"}';
40-
40+
4141
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \
4242
-H "Content-Type: application/json" \
4343
-d '{"name":"kam","description":"The kam module represents a Kusion opinionated abstraction of the core concepts during application delivery."}';
44-
44+
4545
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/kam" \
4646
-H "Content-Type: application/json" \
4747
-d '{"name":"kam","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/app-configuration"}';
@@ -54,32 +54,32 @@ spec:
5454
curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \
5555
-H "Content-Type: application/json" \
5656
-d '{"name":"service","url":"oci://ghcr.io/kusionstack/service"}';
57-
57+
5858
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \
5959
-H "Content-Type: application/json" \
6060
-d '{"name":"service","description":"The service module represents a kind of workload profile that describes how to run your application code."}';
61-
61+
6262
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \
6363
-H "Content-Type: application/json" \
6464
-d '{"name":"service","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/workload/service"}';
65-
65+
6666
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/service" \
6767
-H "Content-Type: application/json" \
6868
-d '{"name":"service","url":"oci://ghcr.io/kusionstack/service"}';
69-
69+
7070
echo "Registering network module...";
7171
curl -X POST "${KUSION_SERVER_ENDPOINT}/api/v1/modules" \
7272
-H "Content-Type: application/json" \
7373
-d '{"name":"network","url":"oci://ghcr.io/kusionstack/network"}';
74-
74+
7575
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \
7676
-H "Content-Type: application/json" \
7777
-d '{"name":"network","description":"The network module represents a network accessory of workload, typically containing exposed ports and a load balancer."}';
78-
78+
7979
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \
8080
-H "Content-Type: application/json" \
8181
-d '{"name":"network","doc":"https://www.kusionstack.io/docs/reference/modules/developer-schemas/network"}';
82-
82+
8383
curl -X PUT "${KUSION_SERVER_ENDPOINT}/api/v1/modules/network" \
8484
-H "Content-Type: application/json" \
8585
-d '{"name":"network","url":"oci://ghcr.io/kusionstack/network"}';

charts/kusion/values.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server:
1717
# -- Repository for Kusion server image
1818
repo: kusionstack/kusion
1919
# -- Tag for Kusion server image. Defaults to the chart's appVersion if not specified
20-
tag: "latest"
20+
tag: ""
2121
# -- Image pull policy
2222
imagePullPolicy: IfNotPresent
2323
# -- Resource limits and requests for the kusion server pods
@@ -114,12 +114,15 @@ mysql:
114114
accessModes:
115115
- ReadWriteOnce
116116

117-
# -- Volume mount path for KubeConfig files
118-
kubeConfigVolumeMountPath: /var/run/secrets/kubernetes.io/kubeconfigs/
119-
120117
# KubeConfig configuration
121-
secrets:
122-
kubeConfigs:
123-
- key: "kubeconfig-0"
124-
value: |
125-
Please fill in your KubeConfig contents here.
118+
kubeconfig:
119+
# -- Volume mount path for KubeConfig files
120+
kubeConfigVolumeMountPath: /var/run/secrets/kubernetes.io/kubeconfigs/
121+
# -- KubeConfig contents map
122+
kubeConfigs: {}
123+
# Example structure:
124+
# kubeConfigs:
125+
# kubeconfig0: |
126+
# Please fill in your KubeConfig contents here.
127+
# kubeconfig1: |
128+
# Please fill in your KubeConfig contents here.

scripts/install-kusion.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# check args
3+
if [ "$#" -lt 2 ]; then
4+
echo "Usage: $0 <kubeconfig_key1=kubeconfig_path1> [kubeconfig_key2=kubeconfig_path2 ...]"
5+
exit 1
6+
fi
7+
8+
# Process all kubeconfig key-path pairs
9+
KUBECONFIG_ARGS=""
10+
for arg in "$@"; do
11+
# Split key=path format
12+
IFS='=' read -r key path <<<"$arg"
13+
14+
if [ -z "$key" ] || [ -z "$path" ]; then
15+
echo "Error: Invalid format. Use kubeconfig_key=kubeconfig_path"
16+
exit 1
17+
fi
18+
19+
if [ ! -f "$path" ]; then
20+
echo "Error: Kubeconfig file not found: $path"
21+
exit 1
22+
fi
23+
24+
# base64 encode
25+
content=$(base64 -w 0 "$path")
26+
27+
# Build helm --set argument
28+
KUBECONFIG_ARGS="${KUBECONFIG_ARGS} --set kubeconfig.kubeConfigs.${key}=${content}"
29+
done
30+
31+
# install/upgrade helm chart
32+
helm repo add kusionstack https://kusionstack.github.io/charts
33+
helm repo update
34+
helm upgrade -i kusion-release kusionstack/kusion ${KUBECONFIG_ARGS}

0 commit comments

Comments
 (0)