Skip to content

Instantly share code, notes, and snippets.

View amcginlay's full-sized avatar

Alan McGinlay amcginlay

View GitHub Profile
@amcginlay
amcginlay / eks.sh
Last active August 11, 2021 12:57
You can reference this file from https://bit.ly/amcginlay-eks
#######################################################################
# TOPICS
#######################################################################
# 1. BUILD CLOUD9 FROM CLOUDSHELL
# 2. BUILD EKS CLUSTER FROM CLOUD9
# 3. BUILD A CONTAINER IMAGE
# 4. PUSH CONTAINER IMAGE TO ECR
# 5. DEPLOY FROM ECR TO K8S
# 6. CONTAINER ORCHESTRATION - balancing that which is desired against that which exists
# 7. K8S CLUSTERIP SERVICES - because pods need to talk to each other
@amcginlay
amcginlay / dd-mkdosfs.sh
Created January 10, 2021 19:01
How to build a filesystem image from scratch
#!/bin/bash # requires mtools package
dd if=/dev/zero of=test.img bs=1M count=2
mkdosfs test.img
mdir -i test.img
echo "Hello" > simple.txt
mcopy -i test.img simple.txt ::/simple.txt
mmd -i test.img stuff
mdir -i test.img stuff
rm simple.txt
mcopy -i test.img ::/simple.txt simple.txt
# the minumum manifest required for scaled nginx exposed as a service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
@amcginlay
amcginlay / helm.sh
Last active October 30, 2021 10:21
You can reference this file from https://bit.ly/amcginlay-helm3
#######################################################################
# HELM - the k8s package manager
#######################################################################
# install utils
sudo yum install -y tree
# install helm (https://helm.sh/docs/intro/install/)
curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
@amcginlay
amcginlay / alpha.sh
Last active March 18, 2021 11:17
[work in progress]
INSTRUCTIONS
# we'll assume the AWS LOAD BALANCER (INGRESS) CONTROLLER is already installed
app_name=alpha
app_version=1.0.0
export AWS_DEFAULT_REGION=$(curl --silent curl --silent http://169.254.169.254/latest/meta-data/placement/region)
eksctl utils associate-iam-oidc-provider \
export AWS_DEFAULT_REGION=$(curl --silent http://169.254.169.254/latest/meta-data/placement/region)
cluster=dev
namespace=passthru
mkdir -p ~/environment/${namespace}/
# build the namespace manifest
kubectl create namespace ${namespace} -o yaml --dry-run=client | kubectl neat > ~/environment/${namespace}/namespace.yaml
# the following will demonstrate how combined CPU requirements
# can stop a pod from being scheduled inside a given namespace
# create the manifest.yaml file shown below
# note the pod, named combo, is built from a pair of containers (nginx and redis)
cat > ./manifest.yaml << EOF
apiVersion: v1
kind: Namespace
metadata:
name: rqtest
@amcginlay
amcginlay / eks-irsa.sh
Last active February 10, 2022 14:26
You can reference this file from https://bit.ly/amcginlay-eks-irsa
# https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/
# requires https://github.com/itaysk/kubectl-neat
# set up variables
cluster=dev
namespace=irsa
mkdir -p ~/environment/${namespace}/
@amcginlay
amcginlay / kms.sh
Last active January 18, 2022 12:14
You can reference this file from https://bit.ly/amcginlay-kms
# inspired by: https://www.youtube.com/watch?v=f3APF1dP8w0
########################################################################
# create a customer managed key
########################################################################
export AWS_DEFAULT_REGION=us-west-2
# create the key
key_id=$(aws kms create-key --query "KeyMetadata.KeyId" --output text)
#######################################################################
# TOPICS
#######################################################################
# 0. ASSUMPTIONS
# 1. CONFIGURE CLOUD9 (EC2) ENVIRONMENT
# 2. INSTALL APPMESH
# 3. BUILD CONTAINER IMAGE
# 4. PUSH CONTAINER IMAGE TO ECR
# 5. DEPLOY OUR APPS TO K8S WITHOUT APPMESH
# 6. MESHIFY THE BACKEND COMPONENTS