This post is part of “ ” series explaining how to use concepts with . In this part, I will show you how to setup an cluster on using & as shown in the diagram below : IaC Infrastracture as Code Terraform etcd AWS CoreOS Terraform All the templates used in this demo can be found on my . Github So let’s start with “ ” file which contains the global variables such as AWS region, cluster instances type … variables.tf Note: As of writing this article, the latest stable version is . CoreOS 1465.6.0 So make sure to find an that is as close to the latest version as possible. AMI Next, we need to define a for our cluster. For simplicity, Im going to make this open to the world. Even though security is important, this tutorial serves an educational purposes and you should never have all ports open in production. security group security group And finally, we will define our which consists of : cluster 3 Nodes In order to bring up an , I used a file that I passed as a parameter to attribut: etcd cluster cloud config user_data Note: Make sure to grab the and place it into the discovery parameter: discovery token, $ curl https://discovery.etcd.io/new?size=3 https://discovery.etcd.io/3e86b59982e49066c5d813af1c2e2579cbf573de Once you defined all templates required, just type the following command to bring up the : etcd cluster terraform apply Note: Don’t forget to set the as an before: AWS credentials envrionment variables export AWS_ACCESS_KEY_ID=”YOUR ACCESS KEY ID” export AWS_SECRET_ACCESS_KEY=”YOUR SECRET ACCESS KEY” Setting up an in action is shown below: etcd cluster Once done, go to your then navigate to your : AWS Management Console EC2 Dashboard Congratulations ! You have your . CoreOS cluster To verify the c , you can either point your browser to the discovery url you generated earlier: luster health or to one of your cluster nodes using the command: SSH ssh core@<NODE-IP> Then, use the to fetch the : etcd command line cluster status Now we have an ready to use. Let’s see what we can do with it: etcd cluster Through etcdctl: etcdctl set nginx/port 80 etcdctl get nginx/port 80 etcdctl ls nginx etcdctl rm nginx/port Through HTTP API: curl -sS -X PUT -d value=”80" | jq ‘.’ # Create http://localhost:2379/v2/keys/nginx/port curl -sS | jq ‘.’ # Get http://localhost:2379/v2/keys/nginx/port curl -sS -X DELETE | jq ‘.’ # Delete http://localhost:2379/v2/keys/nginx/port
Share Your Thoughts