Consul - Using the KV Store with a Watch

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

You are required to perform the following tasks in this hands-on lab:

1. Create a KV pair in the Key Store.
2. Use the CLI method to watch for changes to the KV pair.
3. Confirm if the script runs when the watch is triggered.

You will be provided a Consul server in dev mode along with the script.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log in to the Server
  1. Log in to the server using the provided credentials.
  2. Verify Consul is ready for use.
  3. Check if script handler.sh and file key-changed.txt are in the home folder of your user.

    (Note: For this lab it may take several minutes before Consul is ready for use and you will need two terminal sessions)

Create a Key Value Pair
  1. Create the key called "aws" with a value of eu-central-1.
  2. Verify this value exists.
Run a Consul Watch
  1. Run a watch for the "aws" key using the script handler.sh located in your home folder.
Verify Consul Watch
  1. Using the second terminal, change the "aws" value.
  2. Check the output from the script.
  3. Verify Consul watch is working as expected by confirming the output is sent to file key-changed.txt with the date and time of when the key value aws changed.

Additional Resources

You have been tasked with creating a Consul Watch to monitor when a key in the Consul Key Store changes. When the key changes it will run a script sending an output about the change including the time and date of the change to a file.

The script for your watch run is /opt/handler.sh and when the change occurs it will send the output to file /opt/key-changed.txt. You will need to add the key pair called "aws" to the key store. The initial value of the key in the store is eu-central-1. Use the Consul CLI command to start a watch on the key for aws using the /opt/handler.sh script.

Once the key has been created and the Consul watch is in place, use a second terminal to log into the same server to change the value of the aws key to another value such as us-central-1. The contents of file /opt/key-changed.txt should reflect the change when you change the value of the aws key pair.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!