Skip to content

Commit

Permalink
fix domain key already exists (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
yushiqie authored Dec 18, 2023
1 parent c4b58da commit 98e2d26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/utils/tls/crypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func ParseEncodedKey(keyDataEncoded, keyFile string) (*rsa.PrivateKey, error) {
if err != nil {
return nil, err
}
if keyFile != "" {
if keyFile != "" && !paths.CheckFileExist(keyFile) {
if err = WritePrivateKeyToFile(key, keyFile); err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function deploy_autonomy() {
mount_flag=$(generate_mount_flag)
host_ip=$(getIPV4Address)
# TODO: to be remove
docker run -it --rm -v ${conf_dir}:/tmp ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh autonomy ${DOMAIN_ID} "" "" ${ALLOW_PRIVILEGED}
docker run -it --rm -v ${conf_dir}:/tmp -v ${DOMAIN_CERTS_DIR}:${CTR_CERT_ROOT} ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh autonomy ${DOMAIN_ID} "" "" ${ALLOW_PRIVILEGED}

docker run -dit --privileged --name="${domain_ctr}" --hostname="${domain_ctr}" --restart=always --network=${NETWORK_NAME} -m ${AUTONOMY_MEMORY_LIMIT} \
-p "${DOMAIN_HOST_PORT}":1080 \
Expand Down Expand Up @@ -352,7 +352,7 @@ function deploy_lite() {

host_ip=$(getIPV4Address)
# TODO: to be remove
docker run -it --rm -v ${conf_dir}:/tmp ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh lite ${DOMAIN_ID} ${MASTER_ENDPOINT} ${DOMAIN_TOKEN} ${ALLOW_PRIVILEGED}
docker run -it --rm -v ${conf_dir}:/tmp -v ${DOMAIN_CERTS_DIR}:${CTR_CERT_ROOT} ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh lite ${DOMAIN_ID} ${MASTER_ENDPOINT} ${DOMAIN_TOKEN} ${ALLOW_PRIVILEGED}
# TODO end

docker run -dit --privileged --name="${domain_ctr}" --hostname="${domain_ctr}" --restart=always --network=${NETWORK_NAME} -m $LITE_MEMORY_LIMIT \
Expand Down Expand Up @@ -390,7 +390,7 @@ function deploy_master() {
host_ip=$(getIPV4Address)

# TODO: to be remove
docker run -it --rm -v ${conf_dir}:/tmp ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh master $master_domain_id
docker run -it --rm -v ${conf_dir}:/tmp -v ${DOMAIN_CERTS_DIR}:${CTR_CERT_ROOT} ${KUSCIA_IMAGE} scripts/deploy/init_kuscia_config.sh master $master_domain_id

docker run -dit --name="${domain_ctr}" --hostname="${domain_ctr}" --restart=always --network=${NETWORK_NAME} -m ${MASTER_MEMORY_LIMIT} \
--env NAMESPACE=${master_domain_id} \
Expand Down
9 changes: 8 additions & 1 deletion scripts/deploy/init_kuscia_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ agent:
allowPrivileged: true
"

DOMAIN_KEY_DATA=$(openssl genrsa 2048 | base64 | tr -d "\n")
DOMAIN_KEY_FILE="/home/kuscia/var/certs/domain.key"
if [[ -e ${DOMAIN_KEY_FILE} ]]; then
echo -e "Domain key file already exists"
DOMAIN_KEY_DATA=$(base64 -i ${DOMAIN_KEY_FILE} | tr -d "\n")
else
echo -e "Generate key data"
DOMAIN_KEY_DATA=$(openssl genrsa 2048 | base64 | tr -d "\n")
fi

if [[ $MODE == "lite" ]]; then
CONFIG_DATA=$(sed -e "s!{{.DOMAIN_ID}}!${DOMAIN_ID}!g;
Expand Down

0 comments on commit 98e2d26

Please sign in to comment.