diff --git a/cmd/kubenest/node-agent/app/serve/serve.go b/cmd/kubenest/node-agent/app/serve/serve.go index aed88f45a..a4bc5366d 100644 --- a/cmd/kubenest/node-agent/app/serve/serve.go +++ b/cmd/kubenest/node-agent/app/serve/serve.go @@ -57,10 +57,14 @@ func init() { func serveCmdRun(_ *cobra.Command, _ []string) error { user := viper.GetString("WEB_USER") password := viper.GetString("WEB_PASS") + port := viper.GetString("WEB_PORT") if len(user) == 0 || len(password) == 0 { log.Errorf("-user and -password are required %s %s", user, password) return errors.New("-user and -password are required") } + if port != "" { + addr = ":" + port + } return Start(addr, certFile, keyFile, user, password) } diff --git a/hack/node-agent/agent.env b/hack/node-agent/agent.env index ae392e031..9aa151f03 100644 --- a/hack/node-agent/agent.env +++ b/hack/node-agent/agent.env @@ -1,2 +1,3 @@ WEB_USER={{WEB_USER}} WEB_PASS={{WEB_PASS}} +WEB_PORT={{WEB_PORT}} diff --git a/hack/node-agent/init.sh b/hack/node-agent/init.sh index cc522968e..523dbf5f9 100644 --- a/hack/node-agent/init.sh +++ b/hack/node-agent/init.sh @@ -2,7 +2,8 @@ WEB_USER="$WEB_USER" sed -i 's/^WEB_USER=.*/WEB_USER="'"$WEB_USER"'"/' /app/agent.env WEB_PASS="$WEB_PASS" sed -i 's/^WEB_PASS=.*/WEB_PASS="'"$WEB_PASS"'"/' /app/agent.env +WEB_PORT="$WEB_PORT" sed -i 's/^WEB_PORT=.*/WEB_PORT="'"$WEB_PORT"'"/' /app/agent.env sha256sum /app/node-agent > /app/node-agent.sum sha256sum /host-path/node-agent >> /app/node-agent.sum rsync -avz /app/ /host-path/ -cp /app/node-agent.service /host-systemd/node-agent.service \ No newline at end of file +cp /app/node-agent.service /host-systemd/node-agent.service diff --git a/hack/node-agent/install.sh b/hack/node-agent/install.sh index 4e971940f..127463e10 100644 --- a/hack/node-agent/install.sh +++ b/hack/node-agent/install.sh @@ -45,6 +45,7 @@ prompt_for_credentials # Update credentials in the configuration file sudo sed -i 's/^WEB_USER=.*/WEB_USER="'"$WEB_USER"'"/' "${INSTALL_DIR}"/agent.env sudo sed -i 's/^WEB_PASS=.*/WEB_PASS="'"$WEB_PASS"'"/' "${INSTALL_DIR}"/agent.env +sudo sed -i 's/^WEB_PORT=.*/WEB_PORT="'"$WEB_PORT"'"/' "${INSTALL_DIR}"/agent.env # Generate SHA256 checksums sha256sum "${INSTALL_DIR}"/node-agent | sudo tee "${INSTALL_DIR}"/node-agent.sum @@ -57,4 +58,4 @@ sudo systemctl daemon-reload sudo systemctl enable node-agent sudo systemctl start node-agent -echo "Installation completed successfully." \ No newline at end of file +echo "Installation completed successfully."