vmware-marketplaceetcd

Connect to Etcd

You can connect to Etcd from the same server where it is installed with the etcdctl client tool. To get the list of available options execute the following command:

$ etcdctl --help

You will see an output similar to this:

Connect to etcd

Let’s see how to use the etcdctl CLI. The example below shows how to add new keys to etcd, recover it, and delete the created keys:

IMPORTANT: The etcdctl CLI requires user authentication. It is necessary to include the default username and password when execute commands in the etcdctl CLI. Replace the PASSWORD placeholder with your admin password in the examples below.

  • Execute the ls command to see the data stored in the instance:

      $ etcdctl -u root:PASSWORD ls
    
  • Create a new key using the set command. In this example, create a new key called “data” with the string “my_data” as value. You should see an output similar to the following:

      $ etcdctl -u root:PASSWORD set /data my_data
      my_data
    
  • Use again the ls command to check the directory content:

      $ etcdctl -u root:PASSWORD ls
      /data
    
  • You can also check the value associated to the “data” key by using the get /data command:

      $ etcdctl -u root:PASSWORD get /data
      my_data
    
  • Delete the recently created key executing the rm /data command:

      $ etcdctl -u root:PASSWORD rm /data
      PrevNode.Value: my_data
    
Last modification December 21, 2022