Skip to content

feat: update kubeconfig configuration format in kusion #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions charts/kusion/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v2
name: kusion
version: 0.1.0
version: 0.14.0
type: application
appVersion: "1.0.0"
description: A Helm chart for deploying Kusion - An Intent-Driven Platform Orchestrator
appVersion: 0.14.0
description: Kusion - An Intent-Driven Platform Orchestrator
home: https://github.com/KusionStack/kusion
icon: https://github.com/KusionStack/kusion/docs/logo.png
maintainers:
Expand Down
19 changes: 14 additions & 5 deletions charts/kusion/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 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)
![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)

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

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

Expand Down Expand Up @@ -42,7 +42,7 @@ You may have to set your specific configurations if it is deployed into a produc
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
helm install kusion-release kusionstack/kusion --set server.port=8080 --set mysql.enabled=true --set mysql.database=kusion
```

## Chart Parameters
Expand Down Expand Up @@ -86,7 +86,7 @@ The Kusion Server Component is the main backend server that provides the core fu
| 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.image.tag | string | `""` | 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 |
Expand All @@ -99,7 +99,7 @@ The MySQL database is used to store Kusion's persistent data.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| mysql.database | string | `"kusionDB"` | MySQL database name |
| mysql.database | string | `"kusion"` | 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 |
Expand All @@ -115,5 +115,14 @@ The MySQL database is used to store Kusion's persistent data.
| mysql.rootPassword | string | `""` | MySQL root password |
| mysql.user | string | `"kusion"` | MySQL user |

### KubeConfig

The KubeConfig is used to store the KubeConfig files for the Kusion Server.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| kubeconfig.kubeConfigVolumeMountPath | string | `"/var/run/secrets/kubernetes.io/kubeconfigs/"` | Volume mount path for KubeConfig files |
| kubeconfig.kubeConfigs | object | `{}` | KubeConfig contents map |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs)
16 changes: 14 additions & 2 deletions charts/kusion/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You may have to set your specific configurations if it is deployed into a produc
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
helm install kusion-release kusionstack/kusion --set server.port=8080 --set mysql.enabled=true --set mysql.database=kusion
```

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

### KubeConfig

The KubeConfig is used to store the KubeConfig files for the Kusion Server.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if hasPrefix "kubeconfig" .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)
2 changes: 1 addition & 1 deletion charts/kusion/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MySQL is enabled. The following credentials were configured:
{{- end }}

The Kusion server can be accessed:
- Within cluster: {{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}
- Within cluster: {{ .Values.server.name }}.{{ .Values.namespace }}.svc.cluster.local:{{ .Values.server.port }}
{{- if eq .Values.server.serviceType "NodePort" }}
- From outside: <node-ip>:<node-port>
You can get the node port by running:
Expand Down
16 changes: 12 additions & 4 deletions charts/kusion/templates/kusion-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
spec:
containers:
- name: {{ .Values.server.name }}
image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.server.image.repo "tag" .Values.server.image.tag) }}
image: {{ include "kusion.realImage" (dict "context" . "repo" .Values.server.image.repo "tag" .Values.server.image.tag "needV" (not (hasPrefix "v" .Values.server.image.tag))) }}
imagePullPolicy: {{ .Values.server.image.imagePullPolicy }}
ports:
- name: http
Expand Down Expand Up @@ -84,7 +84,7 @@ spec:
{{- toYaml .Values.server.resources | nindent 12 }}
volumeMounts:
- name: kubeconfig-volume
mountPath: {{ .Values.kubeConfigVolumeMountPath }}
mountPath: {{ .Values.kubeconfig.kubeConfigVolumeMountPath }}
volumes:
- name: kubeconfig-volume
secret:
Expand All @@ -97,6 +97,14 @@ metadata:
namespace: {{ .Values.namespace }}
type: Opaque
data:
{{- range .Values.secrets.kubeConfigs }}
{{ .key }}: {{ .value | b64enc | quote }}
{{- range $key, $value := .Values.kubeconfig.kubeConfigs }}
{{- if kindIs "string" $value }}
{{- if contains " " $value }}
{{/* if contains space, it is a plain yaml format */}}
{{ $key }}: {{ $value | b64enc | quote }}
{{- else }}
{{/* if it is a whole string without spaces, it is already base64 encoded */}}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
40 changes: 20 additions & 20 deletions charts/kusion/templates/post-run-job.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
apiVersion: batch/v1
kind: Job
metadata:
metadata:
name: "{{ .Release.Name }}-post-install-job"
namespace: "{{ .Values.namespace }}"
labels:
labels:
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
spec:
template:
metadata:
spec:
template:
metadata:
name: "{{ .Release.Name }}"
labels:
labels:
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
spec:
restartPolicy: "Never"
containers:
containers:
- name: register-necessary-modules
image: curlimages/curl:latest
env:
env:
- name: KUSION_SERVER_ENDPOINT
value: "{{ .Values.server.name }}.{{ .Values.namespace }}.svc:{{ .Values.server.port }}"
command:
command:
- /bin/sh
- -c
- >
Expand All @@ -37,11 +37,11 @@ spec:
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"}';
Expand All @@ -54,32 +54,32 @@ spec:
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"}';
Expand Down
21 changes: 12 additions & 9 deletions charts/kusion/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ server:
# -- Repository for Kusion server image
repo: kusionstack/kusion
# -- Tag for Kusion server image. Defaults to the chart's appVersion if not specified
tag: "latest"
tag: ""
# -- Image pull policy
imagePullPolicy: IfNotPresent
# -- Resource limits and requests for the kusion server pods
Expand Down Expand Up @@ -114,12 +114,15 @@ mysql:
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.
kubeconfig:
# -- Volume mount path for KubeConfig files
kubeConfigVolumeMountPath: /var/run/secrets/kubernetes.io/kubeconfigs/
# -- KubeConfig contents map
kubeConfigs: {}
# Example structure:
# kubeConfigs:
# kubeconfig0: |
# Please fill in your KubeConfig contents here.
# kubeconfig1: |
# Please fill in your KubeConfig contents here.
34 changes: 34 additions & 0 deletions scripts/install-kusion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# check args
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <kubeconfig_key1=kubeconfig_path1> [kubeconfig_key2=kubeconfig_path2 ...]"
exit 1
fi

# Process all kubeconfig key-path pairs
KUBECONFIG_ARGS=""
for arg in "$@"; do
# Split key=path format
IFS='=' read -r key path <<<"$arg"

if [ -z "$key" ] || [ -z "$path" ]; then
echo "Error: Invalid format. Use kubeconfig_key=kubeconfig_path"
exit 1
fi

if [ ! -f "$path" ]; then
echo "Error: Kubeconfig file not found: $path"
exit 1
fi

# base64 encode
content=$(base64 -w 0 "$path")

# Build helm --set argument
KUBECONFIG_ARGS="${KUBECONFIG_ARGS} --set kubeconfig.kubeConfigs.${key}=${content}"
done

# install/upgrade helm chart
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
helm upgrade -i kusion-release kusionstack/kusion ${KUBECONFIG_ARGS}
Loading