Skip to content

Instantly share code, notes, and snippets.

View imbriaco's full-sized avatar

Mark Imbriaco imbriaco

View GitHub Profile
@imbriaco
imbriaco / 00-README.md
Last active May 26, 2018 08:02
Example deployment descriptor for running Cog on Kubernetes. Uses the secret store as well as persistent disks for Postgres, Cog, and Relay data.

Cog on Kubernetes

This experiment was originally built on Google Cloud's Kubernetes and makes use of gcePersistentDisk. If you are not using Google Cloud, you'll need to adjust the gcePersistentDisk volumes to use the persistent disk technology available in your cluster.

At a high level the steps look something like this, though there may be subtle errors. This experiment happened a few weeks ago and I'm creating these from memory along with the test descriptors I used.

  1. Setup Kubernetes and create the necessary persistent disks that are referenced in the deployment.
### Keybase proof
I hereby claim:
* I am imbriaco on github.
* I am imbriaco (https://keybase.io/imbriaco) on keybase.
* I have a public key ASA2X3VhgO3_XxpAeRQuZSP6qtcaeTrFu5ZD2bzUIa7l7Ao
To claim this, I am signing this object:
@imbriaco
imbriaco / 01-main.tf
Last active June 8, 2016 22:16
I'll take stupid Terraform tricks for $500, Alex
module "my_instance" {
source = "../path/to/crazy_module.tf"
...
count = 1
include_eip = "true"
}
@imbriaco
imbriaco / example.md
Last active February 19, 2016 20:25
Cog Sneak Peek

Cog Sneak Peek

This is just a quick example of what adding a very simple shell script as a Cog command would look like. Everything is a work in progress at this stage of alpha and this command does not make use of many of the advanced features in Cog, but I thought folks might find it interesting.

This is a representation of what it would look like if I (@imbriaco) were talking to a bot named cog that was running this bundle.

imbriaco: @cog: simple foo bar baz
cog:

ARG[0]: foo
@imbriaco
imbriaco / gist:5605757
Created May 18, 2013 20:53
Hacking on a Ruby client for the new Arista Networks Command API
[1] pry(main)> host, user, password = %w(EAPI_HOST EAPI_USER EAPI_PASSWORD).map { |n| ENV[n] }; nil
=> nil
[2] pry(main)> Arista::EAPI::Switch.new(host, user, password).version
=> {:model_name=>"DCS-7048T-A-R",
:internal_version=>"4.12.0-1244071.EOS4120",
:system_mac_address=>"00:1c:73:16:c2:c8",
:serial_number=>"*redacted*",
:mem_total=>4009152,
:bootup_timestamp=>1368735672.686644,
:mem_free=>1851640,
2015-12-11 14:06:52.247 [error] GenServer #PID<0.615.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for %Ecto.Changeset{action: :insert, changes: %{command_id: "183926b9-1fc9-46d4-bbfa-6f675469825a", id: "23c0aaa6-4aa0-4b18-b286-8ea851d2ccf2", parse_tree: "{\"score\":0,\"permission_selector\":{\"perms\":{\"value\":\"ec2:read\",\"quotes\":null,\"line\":1,\"col\":35,\"$ast$\":\"string\"},\"op\":\"has\",\"line\":1,\"col\":35,\"$ast$\":\"perm_expr\"},\"command_selector\":{\"right\":{\"value\":\"ec2:list\",\"quotes\":null,\"line\":1,\"col\":16,\"$ast$\":\"string\"},\"parens\":false,\"op\":\"is\",\"line\":1,\"left\":{\"name\":\"command\",\"$ast$\":\"var\"},\"col\":13,\"$ast$\":\"binary_expr\"},\"command\":\"ec2:list\",\"$ast$\":\"rule\"}", score: 0}, constraints: [%{constraint: "rules_command_id_parse_tree_index", field: :no_dupes, message: "has already been taken", type: :unique}], errors: [no_dupes: "has already been taken"], filters: %{}, model: %Loop.Models.Rule{__meta__: #Ecto.
dynamic!(:my_security_group, :nat, {
:description => 'My Shiny Security Group',
:ingress => [
{
:cidr_ip => '0.0.0.0/0',
:ip_protocol => 'icmp',
:from_port => -1,
:to_port => -1
}
]
def process_metric(event)
metric_setter = "#{event[:metric]}="
send(metric_setter, event[:value]) if respond_to? metric_setter
end
D, [2011-08-13T22:11:06.310036 #99479] DEBUG -- net.ssh.service.forward[810e839c]: received connection on #<UNIXServer:0x0000010201baf0>
D, [2011-08-13T22:11:06.310289 #99479] DEBUG -- tcpsocket[808a3b28]: queueing packet nr 7 type 90 len 60
D, [2011-08-13T22:11:06.310603 #99479] DEBUG -- tcpsocket[808a3b28]: sent 84 bytes
D, [2011-08-13T22:11:06.337773 #99479] DEBUG -- tcpsocket[808a3b28]: read 52 bytes
D, [2011-08-13T22:11:06.337942 #99479] DEBUG -- tcpsocket[808a3b28]: received packet nr 7 type 91 len 28
I, [2011-08-13T22:11:06.338075 #99479] INFO -- net.ssh.connection.session[810e8518]: channel_open_confirmation: 0 0 2097152 32768
I, [2011-08-13T22:11:06.338156 #99479] INFO -- net.ssh.connection.channel[810df620]: direct channel established
D, [2011-08-13T22:11:09.485092 #99479] DEBUG -- unixsocket[810e23e8]: read 13 bytes
D, [2011-08-13T22:11:09.485237 #99479] DEBUG -- net.ssh.connection.channel[810df620]: read 13 bytes from client, sending over local forwarded connection
D, [2011-08-13T22:11:09.485418
namespace :pending do
desc <<-DESC
Displays the `diff' since your last deploy. This is useful if you want \
to examine what changes are about to be deployed. Note that this might \
not be supported on all SCM's.
DESC
task :diff, :except => { :no_release => true } do
system(source.local.diff(current_revision))
end