Skip to content

Instantly share code, notes, and snippets.

View samof76's full-sized avatar
🐒
Swinging branches

Samuel Vijaykumar M samof76

🐒
Swinging branches
View GitHub Profile
@samof76
samof76 / 01_cluster_autoscaler.tf
Last active August 7, 2020 03:44
Terraforming EKS Blog
data "template_file" "cluster_autoscaler" {
template = "${file("cluster_autoscaler.yml.tpl")}"
vars = {
worker_node_min_size = "${var.nodes_min_size}"
worker_node_max_size = "${var.nodes_max_size}"
worker_node_asg_name = "${aws_autoscaling_group.fd_eks_nodes_asg.name}"
aws_region = "${var.region}"
}
}
@samof76
samof76 / kustomize_build.sh
Created March 9, 2020 11:32
Kustomize build
kustomize build deployments/staging/stagingvpc-shell-main/blue | kubectl apply -f -
@samof76
samof76 / make_deployment.sh
Created March 9, 2020 11:27
Make deployments
make deployments/staging/stagingvpc-shell-main/blue
@samof76
samof76 / kustomization.yaml
Created March 9, 2020 11:23
Kustomization YAML
---
bases:
- "./../base"
nameSuffix: "-stagingvpc-shell-main-blue"
commonLabels:
shell: stagingvpc-shell-main-blue
images:
- name: eagle
newName: someawsnumber.dkr.ecr.us-east-1.amazonaws.com/app-stg
newTag: FDx.x.x
@samof76
samof76 / deployment_dir_structure
Last active March 9, 2020 11:18
GitOps Deployment structure
deployments
├── base # base from where everything is inherited
│ └── shell
│ ├── bg
│ │ ├── bg-sidekiq.yaml
│ │ └── bg-utility.yaml
│ ├── fg
│ │ ├── app-api-public.yaml
│ │ ├── app-email.yaml
│ │ └── app.yaml
@samof76
samof76 / update_nlb_targets.rb
Created February 18, 2020 12:24
Update the NLB targets
# The following code gets the EKS endpoint IPs
endpoint = $eks_client.describe_cluster({name: eks_name}).data.cluster.endpoint
u = URI.parse(endpoint)
ips = []
txt = Resolv::DNS.open do |dns|
records = dns.getresources(u.host, Resolv::DNS::Resource::IN::A)
records.each {|r|
ips << r.address.to_s
}
@samof76
samof76 / confd.sh
Last active January 7, 2019 09:35
confd.sh
#!/bin/bash
# Get the instance id
instance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id 2> /dev/null)
# Get the instance name
instance_hostname=$(aws ec2 describe-instances --instance-ids $instance_id | jq -r '.Reservations[0].Instances[0].Tags[] | select(.Key == "opsworks:instance") | .Value')
# Get the instance ip
instance_ipaddress=$(aws ec2 describe-instances --instance-ids $instance_id | jq -r '.Reservations[0].Instances[0].PrivateIpAddress')
@samof76
samof76 / database_server_double_spawn.exs
Created September 29, 2018 07:07
Database server from the Sasa's book.
defmodule DatabaseServer do
# start/0 is the fuction of the Databaserver
# that starts the server process by spawning
# loop/0 and returns its PID.
def start do
spawn(&loop/0)
end
# loop/0 is the fuction of the DatabaseServer
# that that basically waits to `receive` messages
@samof76
samof76 / test_streams.exs
Created August 25, 2018 07:36
Elixir in Action - Exercises
defmodule TestStreams do
def lines_lengths!(path) do
File.stream!(path)
|> Stream.map(&String.replace(&1, "\n",""))
|> Enum.map(&String.length(&1))
end
def longest_line_length!(path) do
File.stream!(path)
|> Stream.map(&String.replace(&1, "\n", ""))
@samof76
samof76 / error.txt
Created August 17, 2018 07:17
Crashdump for a iex run
iex --name sam --cookie secret
2018-08-17 12:39:22.425266
args: []
format: "Can't set long node name!\nPlease check your configuration\n"
label: {error_logger,info_msg}
2018-08-17 12:39:22.425344 crash_report #{label=>{proc_lib,crash},report=>[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.59.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,358}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[net_sup,kernel_sup,<0.45.0>]},{message_queue_len,0},{messages,[]},{links,[<0.56.0>]},{dictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,833}],[]]}
2018-08-17 12:39:22.425812 supervisor_report #{label=>{supervisor,start_error},report=>[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{id,net_kernel},{mfargs,{net_kernel,start_link,[[sam,longnames],true]}},{restart_type,per