mirror of
https://github.com/labring/sealos.git
synced 2026-09-01 15:38:06 +08:00
feat(deploy): add user values template copying for account and deskto… (#6742)
* feat(deploy): add user values template copying for account and desktop services Signed-off-by: cuisongliu <cuisongliu@qq.com> * feat(helm): add account service values file to helm values documentation Signed-off-by: cuisongliu <cuisongliu@qq.com> --------- Signed-off-by: cuisongliu <cuisongliu@qq.com>
This commit is contained in:
@@ -150,11 +150,21 @@ if [ -n "${ACCOUNT_ENV_MERGE_STRATEGY}" ]; then
|
||||
HELM_SET_ARGS+=(--set-string "accountEnvMergeStrategy=${ACCOUNT_ENV_MERGE_STRATEGY}")
|
||||
fi
|
||||
|
||||
SERVICE_NAME="account-controller"
|
||||
USER_VALUES_PATH="/root/.sealos/cloud/values/core/${SERVICE_NAME}-values.yaml"
|
||||
|
||||
# Copy user values template if not exists
|
||||
if [ ! -f "${USER_VALUES_PATH}" ]; then
|
||||
mkdir -p "$(dirname "${USER_VALUES_PATH}")"
|
||||
cp "./charts/${SERVICE_NAME}/values.yaml" "${USER_VALUES_PATH}"
|
||||
fi
|
||||
|
||||
# merge all helm_opts
|
||||
# 1. AUTO_CONFIG_HELM_OPTS (Configuration automatically obtained from ConfigMap)
|
||||
# 2. HELM_SET_ARGS (parameters set internally in the script)
|
||||
# 3. HELM_OPTS (the parameter passed by the user via --env, with the highest priority, can override the previous configuration)
|
||||
helm upgrade -i "${RELEASE_NAME}" -n "${RELEASE_NAMESPACE}" --create-namespace "${CHART_PATH}" \
|
||||
-f "${USER_VALUES_PATH}" \
|
||||
${AUTO_CONFIG_HELM_OPTS} \
|
||||
"${HELM_SET_ARGS[@]}" \
|
||||
${HELM_OPTS}
|
||||
|
||||
@@ -135,6 +135,18 @@ if kubectl -n "${RELEASE_NAMESPACE}" get ingress sealos-desktop >/dev/null 2>&1;
|
||||
fi
|
||||
fi
|
||||
|
||||
# Prepare values files
|
||||
SERVICE_NAME="desktop-frontend"
|
||||
USER_VALUES_PATH="/root/.sealos/cloud/values/core/desktop-values.yaml"
|
||||
|
||||
# Copy user values template if not exists
|
||||
if [ ! -f "${USER_VALUES_PATH}" ]; then
|
||||
mkdir -p "$(dirname "${USER_VALUES_PATH}")"
|
||||
cp "./charts/${SERVICE_NAME}/values.yaml" "${USER_VALUES_PATH}"
|
||||
fi
|
||||
|
||||
# Deploy Helm chart
|
||||
echo "Deploying Helm chart..."
|
||||
helm upgrade -i "${RELEASE_NAME}" -n "${RELEASE_NAMESPACE}" --create-namespace "${CHART_PATH}" ${HELM_ARGS}
|
||||
helm upgrade -i "${RELEASE_NAME}" -n "${RELEASE_NAMESPACE}" --create-namespace "${CHART_PATH}" \
|
||||
-f "${USER_VALUES_PATH}" \
|
||||
${HELM_ARGS}
|
||||
|
||||
@@ -319,6 +319,25 @@ fi
|
||||
HELM_ARGS="$HELM_ARGS -f /root/.sealos/cloud/values/core/desktop-values.yaml"
|
||||
```
|
||||
|
||||
## Example Dir Structure
|
||||
|
||||
```text
|
||||
/root/.sealos/cloud/values/core/
|
||||
desktop-values.yaml
|
||||
costcenter-values.yaml
|
||||
license-values.yaml
|
||||
account-controller-values.yaml
|
||||
app-controller-values.yaml
|
||||
heartbeat-values.yaml
|
||||
initjob-values.yaml
|
||||
license-controller-values.yaml
|
||||
resources-controller-values.yaml
|
||||
user-controller-values.yaml
|
||||
account-service-values.yaml
|
||||
```
|
||||
|
||||
Only the front end uses <name>-values.yaml, and the variable configurations of other modules can be placed in the same directory for easy management and maintenance.
|
||||
|
||||
## Result
|
||||
|
||||
When users run `sealos run sealos:v5.2.0`, Sealos automatically reads `/root/.sealos/cloud/values/core/desktop-values.yaml`.
|
||||
|
||||
@@ -318,6 +318,26 @@ fi
|
||||
HELM_ARGS="$HELM_ARGS -f /root/.sealos/cloud/values/core/desktop-values.yaml"
|
||||
```
|
||||
|
||||
## 目录示例
|
||||
|
||||
```text
|
||||
/root/.sealos/cloud/values/core/
|
||||
desktop-values.yaml
|
||||
costcenter-values.yaml
|
||||
license-values.yaml
|
||||
account-controller-values.yaml
|
||||
app-controller-values.yaml
|
||||
heartbeat-values.yaml
|
||||
initjob-values.yaml
|
||||
license-controller-values.yaml
|
||||
resources-controller-values.yaml
|
||||
user-controller-values.yaml
|
||||
account-service-values.yaml
|
||||
```
|
||||
|
||||
只有前端使用 <name>-values.yaml, 其他模块的可变配置可以放在同一目录下,便于管理和维护。
|
||||
|
||||
|
||||
## 结论
|
||||
|
||||
用户执行 `sealos run sealos:v5.2.0` 时,Sealos 会自动读取 `/root/.sealos/cloud/values/core/desktop-values.yaml`。
|
||||
|
||||
Reference in New Issue
Block a user