├── README.md └── cmd-dashboard.png /README.md: -------------------------------------------------------------------------------- 1 | # CMD Tutorial 2 | 3 | This tutorial will walk you through provisioning some VMs on [GCP](https://cloud.google.com) so you can kick the tires on [Cmd](https://cmd.com/) -- Track and Control Users in Production. 4 | 5 | ## Setup CMD 6 | 7 | Walk through the initial [installation instructions](https://help.cmd.com/en/articles/3396542-initial-setup) and grab the [single server deployment url](https://help.cmd.com/en/articles/3396528-adding-a-new-server) 8 | 9 | The URL FQDN may be different from the sub2 example seen here. 10 | Generating the install URL will want a server name, give it something and then strip off the last segment of the URL. 11 | 12 | Example URL before stripping: 13 | 14 | ``` 15 | curl -s -f https://sub2.c-app.cmd.com:443/install/deadbeef1234567890/PRJ-999/abcdef= | sudo bash 16 | ``` 17 | 18 | Example URL after stripping: 19 | ``` 20 | curl -s -f https://sub2.c-app.cmd.com:443/install/deadbeef1234567890/PRJ-999/ | sudo bash 21 | ``` 22 | 23 | Write metadata.txt using the following template, be sure replace values with your Project ID (eg PRJ-999) and API key (eg abcdef123 - long random string) 24 | ``` 25 | b64_hostname=$(hostname | base64) 26 | curl -s -f https://sub2.c-app.cmd.com:443/install/deadbeef1234567890/PRJ-999/${b64_hostname} | sudo bash 27 | ``` 28 | 29 | ## Provisioning Infrastructure 30 | 31 | Create the `cmd-tutorial` network: 32 | 33 | ``` 34 | gcloud compute networks create cmd-tutorial --subnet-mode auto 35 | ``` 36 | 37 | Add a few firewall rules: 38 | 39 | ``` 40 | gcloud compute firewall-rules create cmd-allow-internal \ 41 | --allow tcp,udp,icmp \ 42 | --network cmd-tutorial \ 43 | --source-ranges 10.0.0.0/8 44 | ``` 45 | 46 | ``` 47 | gcloud compute firewall-rules create cmd-allow-external \ 48 | --allow tcp:22,tcp:6443,icmp \ 49 | --network cmd-tutorial \ 50 | --source-ranges 0.0.0.0/0 51 | ``` 52 | 53 | Provision two GCE VMs running Ubuntu 20.04 LTS: 54 | 55 | ``` 56 | for i in 0 1; do 57 | gcloud compute instances create node-${i} \ 58 | --async \ 59 | --boot-disk-size 50GB \ 60 | --can-ip-forward \ 61 | --image-family ubuntu-2004-lts \ 62 | --image-project ubuntu-os-cloud \ 63 | --machine-type e2-micro \ 64 | --scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \ 65 | --network cmd-tutorial \ 66 | --tags cmd-tutorial \ 67 | --metadata-from-file=startup-script=metadata.txt 68 | done 69 | ``` 70 | 71 | Check that the VMs are ready: 72 | 73 | ``` 74 | gcloud compute instances list 75 | ``` 76 | ``` 77 | NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS 78 | node-0 us-west1-c e2-micro 10.XXX.0.2 XX.XX.XX.X RUNNING 79 | node-1 us-west1-c e2-micro 10.XXX.0.3 XX.XXX.XX.XXX RUNNING 80 | ``` 81 | 82 | ## Testing 83 | 84 | Once booted, Cmd should be installed on each node, run an SSH command on them to generate some activity that will show up in the Cmd dashboard. 85 | 86 | ``` 87 | for i in 0 1; do 88 | gcloud compute ssh node-${i} --command "uname -a" 89 | done 90 | ``` 91 | 92 | ``` 93 | Linux node-0 5.4.0-1028-gcp #29-Ubuntu SMP Mon Oct 5 16:42:23 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux 94 | Linux node-1 5.4.0-1028-gcp #29-Ubuntu SMP Mon Oct 5 16:42:23 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux 95 | ``` 96 | 97 | Visit the Cmd dashboard: 98 | 99 | ![Image of Cmd dashboard](cmd-dashboard.png) 100 | 101 | ## Clean Up 102 | 103 | Delete the cloud resources: 104 | 105 | ``` 106 | for i in 0 1; do 107 | gcloud -q compute instances delete node-${i} 108 | done 109 | ``` 110 | 111 | ``` 112 | gcloud -q compute firewall-rules delete cmd-allow-internal 113 | gcloud -q compute firewall-rules delete cmd-allow-external 114 | ``` 115 | 116 | ``` 117 | gcloud -q compute networks delete cmd-tutorial 118 | ``` 119 | -------------------------------------------------------------------------------- /cmd-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kelseyhightower/cmd-tutorial/5b9ba22f0b583b5bd70b3aefec39822c7478583f/cmd-dashboard.png --------------------------------------------------------------------------------