18. Development: Vagrant
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Box 'freebsd/FreeBSD-11.0-STABLE' could not be found.
Attempting to find and install...
default: Box Provider: vmware_desktop, vmware_fusion,
vmware_workstation
default: Box Version: >= 0
==> default: Loading metadata for box 'freebsd/FreeBSD-11.0-STABLE'
default: URL: https://atlas.hashicorp.com/freebsd/FreeBSD-11.0-STABLE
==> default: Adding box 'freebsd/FreeBSD-11.0-STABLE' (v2016.11.01) for
provider: vmware_desktop
default: Downloading: https://atlas.hashicorp.com/freebsd/boxes/
FreeBSD-11.0-STABLE/versions/2016.11.01/providers/vmware_desktop.box
19. Development: Vagrant
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.39.128:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection refused. Retrying...
The configured shell (config.ssh.shell) is invalid and unable
to properly execute commands. The most common cause for this is
using a shell that is unavailable on the system. Please verify
you're using the full path to the shell and that the shell is
executable by the SSH user.
22. Vagrant: FreeBSD Take Two
$ vagrant up --destroy-on-error
==> default: Machine booted and ready!
==> default: Forwarding ports...
default: -- 22 => 2222
==> default: Configuring network adapters within the VM...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator
privileges will be required...
==> default: Mounting NFS shared folders...
23. $ vagrant ssh
$ vagrant ssh
FreeBSD 11.0-STABLE (GENERIC) #0 r308135: Mon
Oct 31 19:17:52 UTC 2016
vagrant@:~ % cd /vagrant/
vagrant@:/vagrant % uname -a > uname.out
vagrant@:/vagrant % logout
Shared connection to 192.168.39.130 closed.
$ cat uname.out
24. $ vagrant suspend
$ time vagrant suspend
==> default: Suspending the VMware VM...
2.85 real 2.05 user 0.21 sys
$ time vagrant up
$ vagrant ssh
25. $ vagrant up (resume)
$ time vagrant up
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Checking if box 'freebsd/FreeBSD-11.0-STABLE' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Starting the VMware VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.39.132:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Forwarding ports...
default: -- 22 => 2200
18.36 real 6.32 user 1.00 sys
26. $ vagrant status
$ vagrant status
Current machine states:
default running (vmware_fusion)
The VM is running. To stop this VM, you can run `vagrant halt`
to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.
27. $ vagrant status
$ vagrant status
Current machine states:
default saved
(virtualbox)
28. $ vagrant destroy
$ vagrant destroy
default: Are you sure you want to destroy the
'default' VM? [y/N] y
==> default: Stopping the VMware VM...
Connection to 192.168.39.130 closed by remote host.
==> default: Deleting the VM...
==> default: Pruning invalid NFS exports.
Administrator privileges will be required...
41. GCE Setup
$ gcloud config list project
Your active configuration is: [default]
[core]
project (unset)
$ gcloud config set project meetbsd-2016
Updated property [core/project].
$ gcloud config list project
Your active configuration is: [default]
[core]
project = meetbsd-2016
42. Poll: How many use Terraform?
• Never heard of Terraform
• Heard of Terraform but never used it
• Used it once or twice
• My life is a shell script:
set -e
while true; do
$EDITOR foo.tf
terraform plan
terraform apply
done
59. Computes in the Clouds
$ gcloud compute zones list
ERROR: (gcloud.compute.zones.list) Some requests did not
succeed:
- Access Not Configured. Compute Engine API has not
been used in project 474274720932 before or it is
disabled. Enable it by visiting https://
console.developers.google.com/apis/api/
compute_component/overview?project=474274720932 then
retry. If you enabled this API recently, wait a few
minutes for the action to propagate to our systems and
retry.
61. Compute Regions
$ gcloud compute regions list
NAME CPUS DISKS_GB ADDRESSES RESERVED_ADDRESSES
STATUS TURNDOWN_DATE
asia-east1 0/24 0/10240 0/23 0/7 UP
asia-northeast1 0/24 0/10240 0/23 0/7 UP
europe-west1 0/24 0/10240 0/23 0/7 UP
us-central1 0/24 0/10240 0/23 0/7 UP
us-east1 0/24 0/10240 0/23 0/7 UP
us-west1 0/24 0/10240 0/23 0/7 UP
62. Zones in a Region
$ gcloud compute zones list | grep us-west1
NAME REGION STATUS
us-west1-a us-west1 UP
us-west1-b us-west1 UP
75. Planning The Future
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.
Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.
76. DAG walked: 1 resource to be added
+ google_compute_instance.host
can_ip_forward: "false"
disk.#: "1"
disk.0.auto_delete: "true"
disk.0.image: "freebsd-org-cloud-dev/freebsd-11-0-stable-amd64-2016-11-01"
machine_type: "n1-standard-1"
metadata_fingerprint: "<computed>"
name: "meetbsd1"
network_interface.#: "1"
network_interface.0.access_config.#: "1"
network_interface.0.access_config.0.assigned_nat_ip: "<computed>"
network_interface.0.address: "<computed>"
network_interface.0.name: "<computed>"
network_interface.0.network: "default"
self_link: "<computed>"
tags.#: "1"
tags.2670015358: "meetbsd"
tags_fingerprint: "<computed>"
zone: "us-west1-a"
Plan: 1 to add, 0 to change, 0 to destroy.
78. Hold Please
google_compute_instance.host: Still creating... (10s elapsed)
google_compute_instance.host: Still creating... (20s elapsed)
google_compute_instance.host: Still creating... (30s elapsed)
google_compute_instance.host: Still creating... (40s elapsed)
google_compute_instance.host: Provisioning with 'file'...
google_compute_instance.host: Still creating... (50s elapsed)
google_compute_instance.host: Still creating... (1m0s
elapsed)
google_compute_instance.host: Still creating... (1m10s
elapsed)
[snip]
82. Cleanup Time
> terraform destroy
Do you really want to destroy?
Terraform will delete all your managed infrastructure.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
google_compute_instance.host: Refreshing state... (ID: meetbsd1)
google_compute_instance.host: Destroying...
google_compute_instance.host: Still destroying... (10s elapsed)
google_compute_instance.host: Still destroying... (20s elapsed)
google_compute_instance.host: Still destroying... (30s elapsed)
google_compute_instance.host: Still destroying... (40s elapsed)
google_compute_instance.host: Still destroying... (50s elapsed)
google_compute_instance.host: Still destroying... (1m0s elapsed)
google_compute_instance.host: Still destroying... (1m10s elapsed)
google_compute_instance.host: Still destroying... (1m20s elapsed)
google_compute_instance.host: Still destroying... (1m30s elapsed)
google_compute_instance.host: Destruction complete
83. Tubing at Scale
> $EDITOR main.tf
count = 100
> terraform plan
+ google_compute_instance.host.99
[snip]
network_interface.0.network: "default"
self_link: "<computed>"
tags.#: "1"
tags.2670015358: "meetbsd"
tags_fingerprint: "<computed>"
zone: "us-west1-a"
Plan: 99 to add, 10 to change, 0 to destroy.
84. Dev to Prod KPIs
Low resource acquisition cost for development
Resource acquisition cost for production
85. Advanced Tips and Topics
• Tip: Minimize blast radius
Topic: Layered configs
• Tip: Pre-create your own images
Topic: Packer or Terraform
• Tip: Use GCE Autoscaling Groups or AWS auto-scaling groups
(ASGs)
• Tip: Consider build-time vs run-time concerns
Topic: Use distributed databases to maintain runtime state (Consul)
86. Advanced Tips and Topics
• Tip: Perform as much work as possible at image build-time
• Tip: Images are repeatable fossilized artifacts
Topic: Codified descriptions of artifacts
• Tip: Support standards
Topic: Design for fungible OSes
88. It started out as this...
$ cat freebsd-vars.tf
variable "iso-image-org" {
default = "ubuntu"
}
variable "freebsd-version" {
default = "trusty64"
}
89. Dev to Prod KPIs
Low resource acquisition cost for development
Resource acquisition cost for production
Translation cost between development and
production
91. Packer Templates
# Hat tip to brd@ for doing the initial heavy lifting!
$ git clone https://github.com/brd/packer-freebsd.git
$ cd packer-freebsd
$ ./automatic-11.0-current-ufs.sh —only=vmware-iso
[snip]
$ vagrant up
$ vagrant ssh
92. Why? I like working in FreeBSD
http://brendangregg.com/Perf/freebsd_observability_tools.png
93. Dev to Prod KPIs
Low resource acquisition cost for development
Resource acquisition cost for production
Translation cost between development and
production
95. Dev to Prod KPIs
Low resource acquisition cost for development
Resource acquisition cost for production
Translation cost between development and
production
Safety in numbers: are your peer organizations
using FreeBSD in large numbers?
97. KPIs from Cloud Providers
• Friction: Effort required to spin up a new
instance
• Street cred: Number of blog posts/Stack
Overflow questions referring about ${TOPIC}
on ${AWS,GCP,DigitalOcean,etc}
98. Dev to Prod KPIs
Low resource acquisition cost for development
Resource acquisition cost for production
Translation cost between development and production
Safety in numbers: are your peer organizations using
FreeBSD in large numbers?
Production cost of mapping immutable artifact from
laptop to production