Skip to content
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

chore: update sealos cloud cluster image to adapt desktop using config #4730

Merged
merged 4 commits into from
May 13, 2024
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
21 changes: 5 additions & 16 deletions deploy/cloud/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ function prepare {
# gen regionUID if not set or not found in secret
gen_regionUID

# mutate desktop config
mutate_desktop_config

# create tls secret
create_tls_secret
}
Expand Down Expand Up @@ -152,18 +149,6 @@ function gen_regionUID(){
fi
}

function mutate_desktop_config() {
# mutate etc/sealos/desktop-config.yaml by using mongodb uri and two random string
sed -i -e "s;<your-mongodb-uri>;$(echo -n "${mongodbUri}/sealos-auth?authSource=admin");" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-internal-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-regional-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-global-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-password-salt>;$saltKey;" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-regional-database-url>;$(echo -n "${cockroachdbLocalUri}");" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-global-database-url>;$(echo -n "${cockroachdbGlobalUri}");" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-local-region-uid>;$(echo -n "${localRegionUID}");" etc/sealos/desktop-config.yaml
}

function create_tls_secret {
if grep -q $tlsCrtPlaceholder manifests/tls-secret.yaml; then
echo "mock tls secret"
Expand All @@ -182,7 +167,11 @@ function sealos_run_desktop {
--env cloudPort="$cloudPort" \
--env certSecretName="wildcard-cert" \
--env passwordEnabled="true" \
--config-file etc/sealos/desktop-config.yaml
--env passwordSalt="$saltKey" \
--env regionUID="$localRegionUID" \
--env databaseMongodbURI="${mongodbUri}/sealos-auth?authSource=admin" \
--env databaseLocalCockroachdbURI="$cockroachdbLocalUri" \
--env databaseGlobalCockroachdbURI="$cockroachdbGlobalUri"
}

function sealos_run_controller {
Expand Down
5 changes: 5 additions & 0 deletions frontend/desktop/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ COPY scripts scripts
ENV cloudDomain="127.0.0.1.nip.io"
ENV cloudPort=""
ENV certSecretName="wildcard-cert"
ENV regionUID="randomRegionUID"
ENV databaseMongodbURI=""
ENV databaseGlobalCockroachdbURI=""
ENV databaseLocalCockroachdbURI=""
ENV passwordSalt="randomSalt"

CMD ["bash scripts/init.sh"]
55 changes: 0 additions & 55 deletions frontend/desktop/deploy/manifests/configmap.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
apiVersion: apps.sealos.io/v1beta1
kind: Config
apiVersion: v1
kind: ConfigMap
metadata:
name: secret
spec:
path: manifests/configmap.yaml
strategy: override
data: |
name: desktop-frontend-config
namespace: sealos
data:
config.yaml : |
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -16,17 +15,17 @@ spec:
cloud:
domain: "{{ .cloudDomain }}"
port: "{{ .cloudPort }}"
regionUID: "<your-local-region-uid>"
regionUID: "{{ .regionUID }}"
certSecretName: "{{ .certSecretName }}"
common:
guideEnabled: "false"
apiEnabled: "false"
rechargeEnabled: "false"
cfSiteKey: ""
database:
mongodbURI: "<your-mongodb-uri>"
globalCockroachdbURI: "<your-global-database-url>"
regionalCockroachdbURI: "<your-regional-database-url>"
mongodbURI: "{{ .databaseMongodbURI }}"
globalCockroachdbURI: "{{ .databaseGlobalCockroachdbURI }}"
regionalCockroachdbURI: "{{ .databaseLocalCockroachdbURI }}"
desktop:
layout:
title: "Sealos Cloud"
Expand All @@ -53,4 +52,4 @@ spec:
idp:
password:
enabled: "true"
salt: "<your-password-salt>"
salt: "{{ .passwordSalt }}"
5 changes: 4 additions & 1 deletion frontend/desktop/deploy/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
set -ex
kubectl apply -f manifests/deploy.yaml -f manifests/rbac.yaml -f manifests/ingress.yaml
cm_exists=$(kubectl get cm desktop-frontend-config -n sealos --ignore-not-found=true)
if [[ -n "cm_exists" ]]; then
if [[ -n "$cm_exists" ]]; then
echo "desktop-frontend-config already exists, skip create desktop config"
else
echo "create desktop config"
sed -i -e "s;<your-internal-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" manifests/config.yaml
sed -i -e "s;<your-regional-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" manifests/config.yaml
sed -i -e "s;<your-global-jwt-secret>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64);" manifests/config.yaml
kubectl apply -f manifests/config.yaml --validate=false
fi
Loading