Skip to content

Instantly share code, notes, and snippets.

View gmaliar's full-sized avatar
💭
Recombobulating

Guy Maliar gmaliar

💭
Recombobulating
View GitHub Profile
@gmaliar
gmaliar / cache-clear.yml
Created September 1, 2017 13:05
Helm example: jobs
# cache-job.yml
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Chart.Name }}-cache-v{{ .Values.release.version }}"
annotations:
"helm.sh/hook": post-upgrade
spec:
template:
metadata:
@gmaliar
gmaliar / deploy.sh
Last active January 22, 2018 14:39
Helm example: deploy script
#!/bin/sh
STAGE=production
VERSION=$(git rev-parse --short=6 HEAD)
TAG=tailor-web:v${VERSION}
# Build Docker Image
docker build -t $TAG -f Dockerfile
# Push Docker Image to ECR
@gmaliar
gmaliar / asg.tf
Created September 1, 2017 13:08
terraform Kubernetes persistent auto scaling groups
# persistent-asg.tf
resource "aws_autoscaling_group" "nodes-production-persistent-us-east-1a-tailor-brands-k8s-com" {
name = "nodes.production.persistent.us-east-1a.tailor-brands-k8s.com"
launch_configuration = "${aws_launch_configuration.nodes-production-tailor-brands-k8s-com.id}"
max_size = 1
min_size = 1
vpc_zone_identifier = ["${aws_subnet.us-east-1a-production-tailor-brands-k8s-com.id}"]
tag = {
key = "KubernetesCluster"
value = "production.tailor-brands-k8s.com"
@gmaliar
gmaliar / label.sh
Created September 1, 2017 13:09
label kubernetes nodes
#!/bin/sh
INSTANCE_A=$(aws autoscaling describe-auto-scaling-instances | jq '.AutoScalingInstances[] | select(.AutoScalingGroupName == "nodes.production.persistent.us-east-1a.tailor-brands-k8s.com") | .InstanceId')
INSTANCE_B=$(aws autoscaling describe-auto-scaling-instances | jq '.AutoScalingInstances[] | select(.AutoScalingGroupName == "nodes.production.persistent.us-east-1b.tailor-brands-k8s.com") | .InstanceId')
INSTANCE_C=$(aws autoscaling describe-auto-scaling-instances | jq '.AutoScalingInstances[] | select(.AutoScalingGroupName == "nodes.production.persistent.us-east-1c.tailor-brands-k8s.com") | .InstanceId')
NODES=$(aws ec2 describe-instances --filters Name=instance-id,Values=$INSTANCE_A,$INSTANCE_B,$INSTANCE_C | jq --raw-output '.Reservations[].Instances[].NetworkInterfaces[].PrivateDnsName')
kubectl label nodes $NODES persistentNode=true
@gmaliar
gmaliar / cluster-autoscaler.yml
Created September 1, 2017 13:10
cluster auto scaler and ingress controller with persistent nodes
# cluster-autoscaler-deployment.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
app: cluster-autoscaler
spec:
replicas: 1
@gmaliar
gmaliar / hpa.yml
Created September 1, 2017 13:11
ingress controller pdb and hpa
# hpa.yml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: ingress-nginx-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: ingress-nginx
@gmaliar
gmaliar / ds.yml
Created September 1, 2017 13:12
logdna Kubernetes DaemonSet
# logdna-ds.yml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: logdna-agent
spec:
template:
metadata:
labels:
app: logdna-agent
@gmaliar
gmaliar / System Design.md
Created February 15, 2018 09:12 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@gmaliar
gmaliar / pre.sh
Last active March 16, 2018 11:02
Auto-renewing secrets using Valut and Kubernetes | pre.sh
brew install vault consul kubectl kubernetes-helm
brew cask install virtualbox
brew cask install minikube
@gmaliar
gmaliar / init.sh
Last active January 18, 2019 14:57
Auto-renewing secrets using Valut and Kubernetes | init.sh
minikube --vm-driver=virualbox start
kubectl config use-context gce
helm init