A command-line tool for managing Nacos server configurations, services, and namespaces.
go install github.com/k8scat/nacos-cli@latestOr build from source:
git clone https://github.com/k8scat/nacos-cli.git
cd nacos-cli
go buildYou can use command-line flags to provide configuration information or create a config file at $HOME/.nacos-cli.yaml.
Config file example:
server: http://localhost:8848
username: nacos
password: nacos
namespace: publicGlobal flags:
--config string Config file (default is $HOME/.nacos-cli.yaml)
--namespace string Nacos namespace ID
--password string Nacos server password
--server string Nacos server address (default "http://localhost:8848")
--username string Nacos server username
Get configuration:
# Get configuration and print to console
nacos-cli config get --data-id=example --group=DEFAULT_GROUP
# Get configuration and save to file
nacos-cli config get --data-id=example --group=DEFAULT_GROUP --output=config.yamlPublish configuration:
# Publish configuration from command line
nacos-cli config publish --data-id=example --group=DEFAULT_GROUP --content="hello world"
# Publish configuration from file
nacos-cli config publish --data-id=example --group=DEFAULT_GROUP --file=config.yaml
# Publish configuration from stdin
cat config.yaml | nacos-cli config publish --data-id=example --group=DEFAULT_GROUPDelete configuration:
nacos-cli config delete --data-id=example --group=DEFAULT_GROUPListen for configuration changes:
nacos-cli config listen --data-id=example --group=DEFAULT_GROUP --content="current content"Get configuration history:
nacos-cli config history --data-id=example --group=DEFAULT_GROUP --prettyGet configuration history detail:
nacos-cli config history-detail --data-id=example --group=DEFAULT_GROUP --nid=123 --prettyGet previous configuration version:
nacos-cli config previous --data-id=example --group=DEFAULT_GROUP --prettyGet service information:
# Get service information
nacos-cli service get --name=example-service
# Get service information with pretty output
nacos-cli service get --name=example-service --prettyRegister instance:
# Register a simple instance
nacos-cli service register --name=example-service --ip=192.168.1.1 --port=8080
# Register with metadata
nacos-cli service register --name=example-service --ip=192.168.1.1 --port=8080 --metadata='{"version":"1.0.0"}'
# Register with cluster
nacos-cli service register --name=example-service --ip=192.168.1.1 --port=8080 --cluster=DEFAULTDeregister instance:
nacos-cli service deregister --name=example-service --ip=192.168.1.1 --port=8080Modify instance:
nacos-cli service modify-instance --name=example-service --ip=192.168.1.1 --port=8080 --weight=2.0 --metadata='{"version":"2.0.0"}'List instances:
nacos-cli service list-instances --name=example-service --prettyGet instance details:
nacos-cli service get-instance --name=example-service --ip=192.168.1.1 --port=8080 --prettySend instance heartbeat:
nacos-cli service beat --name=example-service --ip=192.168.1.1 --port=8080Create service:
nacos-cli service create --name=example-service --group=DEFAULT_GROUP --protect=0.7 --metadata='{"description":"example service"}'Delete service:
nacos-cli service delete --name=example-service --group=DEFAULT_GROUPUpdate service:
nacos-cli service update --name=example-service --group=DEFAULT_GROUP --protect=0.8 --metadata='{"description":"updated example service"}'List services:
nacos-cli service list --page=1 --size=20 --prettyGet system switches:
nacos-cli service get-switches --prettyUpdate system switch:
nacos-cli service update-switch --entry=distro.enableAll --value=trueGet system metrics:
nacos-cli service metrics --prettyGet servers list:
nacos-cli service servers --prettyGet cluster leader:
nacos-cli service leader --prettyUpdate instance health:
nacos-cli service update-health --name=example-service --ip=192.168.1.1 --port=8080 --healthy=trueList namespaces:
# List all namespaces
nacos-cli namespace list
# List all namespaces with pretty output
nacos-cli namespace list --prettyCreate namespace:
nacos-cli namespace create --id=dev --name="Development Environment" --desc="Used for development"Modify namespace:
nacos-cli namespace modify --id=dev --name="Development" --desc="Development environment"Delete namespace:
nacos-cli namespace delete --id=dev