Skip to content

Commit

Permalink
support node-agent serve port config
Browse files Browse the repository at this point in the history
Signed-off-by: Rambohang <[email protected]>
  • Loading branch information
Rambohang committed Oct 29, 2024
1 parent a2fc0c3 commit b5039f7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/kubenest/node-agent/app/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions hack/node-agent/agent.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
WEB_USER={{WEB_USER}}
WEB_PASS={{WEB_PASS}}
WEB_PORT={{WEB_PORT}}
3 changes: 2 additions & 1 deletion hack/node-agent/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
cp /app/node-agent.service /host-systemd/node-agent.service
3 changes: 2 additions & 1 deletion hack/node-agent/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,4 +58,4 @@ sudo systemctl daemon-reload
sudo systemctl enable node-agent
sudo systemctl start node-agent

echo "Installation completed successfully."
echo "Installation completed successfully."

0 comments on commit b5039f7

Please sign in to comment.