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
Created August 7, 2020 03:50
01_cluster_autoscaler.tf
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 / 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", ""))