Skip to content

Commit

Permalink
chore: update sealos cloud cluster image to adapt desktop using config (
Browse files Browse the repository at this point in the history
#4730)

* chore: update sealos cloud cluster image to adapt desktop using yaml as config.
Signed-off-by: yy <[email protected]>

Signed-off-by: yy <[email protected]>

* chore: update sealos cloud cluster image to adapt desktop using yaml as config.
Signed-off-by: yy <[email protected]>

Signed-off-by: yy <[email protected]>

* chore: update sealos cloud cluster image to adapt desktop using yaml as config.
Signed-off-by: yy <[email protected]>

Signed-off-by: yy <[email protected]>

* chore: update sealos cloud cluster image to adapt desktop using yaml as config.
Signed-off-by: yy <[email protected]>

Signed-off-by: yy <[email protected]>

---------

Signed-off-by: yy <[email protected]>
  • Loading branch information
lingdie authored May 13, 2024
1 parent 49e6422 commit dec95d9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 84 deletions.
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

0 comments on commit dec95d9

Please sign in to comment.