Skip to content

Commit

Permalink
add a support for community edition simply (labring#3622)
Browse files Browse the repository at this point in the history
* fix poc bugs

* add namespace check and create logic

* fix some bugs

* modify setup.sh

* add preset-admin user

* a simple edition of community

* fix config
  • Loading branch information
yxxchange authored Aug 3, 2023
1 parent 4027c49 commit 84eaa22
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/licenseissuer/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ ENV RegisterURL "https://license.sealos.io/register"
ENV CloudSyncURL "https://license.sealos.io/datasync"
ENV LicenseMonitorURL "https://license.sealos.io/license"

CMD ["kubectl apply -f manifests/deploy.yaml -f manifests/customconfig.yaml"]
CMD ["chmod +x manifests/setup.sh && bash manifests/setup.sh"]
2 changes: 1 addition & 1 deletion controllers/licenseissuer/deploy/manifests/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ spec:
memory: 1024Mi
requests:
cpu: 10m
memory: 128Mi
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
24 changes: 24 additions & 0 deletions controllers/licenseissuer/deploy/manifests/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /bin/bash

# check and create namespace of sealos-system
if ! kubectl get namespace sealos-system &> /dev/null; then
# if not exist, create namespace and check until it is created
echo "Namespace sealos-system does not exist. Creating..."
kubectl create namespace sealos-system
echo "Waiting for the creation of namespace sealos-system..."
while ! kubectl get namespace sealos-system &> /dev/null; do
sleep 1
done
echo "Namespace sealos-system created."
else
echo "Namespace sealos-system already exists. Skipping creation."
fi

kubectl apply -f manifests/deploy.yaml

while ! kubectl get crd | grep -q "launchers.infostream.sealos.io"; do
echo "Waiting for launchers.infostream.sealos.io CRD to be created..."
sleep 3
done

kubectl apply -f manifests/customconfig.yaml
12 changes: 11 additions & 1 deletion deploy/cloud/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cloudDomain="127.0.0.1.nip.io"
tlsCrtPlaceholder="<tls-crt-placeholder>"
tlsKeyPlaceholder="<tls-key-placeholder>"
mongodbUri=""
saltKey=""

function read_env {
source $1
Expand Down Expand Up @@ -79,6 +80,10 @@ function sealos_authorize {
kubectl apply -f manifests/free-license.yaml
}

function gen_saltKey() {
saltKey=$(tr -dc 'a-z0-9' </dev/urandom | head -c64 | base64 -w 0)
}

function gen_mongodbUri() {
# if mongodbUri is empty then create mongodb and gen mongodb uri
if [ -z "$mongodbUri" ]; then
Expand Down Expand Up @@ -134,9 +139,11 @@ function mutate_desktop_config() {
# mutate etc/sealos/desktop-config.yaml by using mongodb uri and two random base64 string
sed -i -e "s;<your-mongodb-uri-base64>;$(echo -n "$mongodbUri" | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-jwt-secret-base64>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64 | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-password-salt-base64>;$(tr -cd 'a-z0-9' </dev/urandom | head -c64 | base64 -w 0);" etc/sealos/desktop-config.yaml
sed -i -e "s;<your-password-salt-base64>;$saltKey;" etc/sealos/desktop-config.yaml
}



function install {
# read env
read_env etc/sealos/cloud.env
Expand All @@ -153,6 +160,9 @@ function install {
# gen mongodb uri
gen_mongodbUri

# gen saltKey
gen_saltKey

# sealos run controllers
sealos_run_controller

Expand Down

0 comments on commit 84eaa22

Please sign in to comment.