AWS EKS
GETTING STARTING
EKS: GETTING STARTED
- Prerequisites
- Creating the Cluster
- Building the Application
- Deploying an Application
EKS: PREREQUISITES
EKS: AWS-CLI
############################
# Get Python & Pip (pyenv example)
############################
brew install pyenv # https://github.com/pyenv/pyenv
eval "$(pyenv init -)"
pyenv install 3.6.2
pyenv global 3.6.2
pyenv shell 3.6.2
pip install --upgrade pip setuptools
############################
# AWS CLI Tools (Required)
############################
pip install awscli
aws configure
EKS: DOCKER
- Linux
- native (package installs)
- Mac
- Docker-Machine (VirtualBox)
- Docker for Mac (xhyve)
- Windows
- Docker-Machine (VirtualBox)
- Docker for Windows (Hyper-V)
EKS: Docker-Machine
###################
# Install
###################
brew cask install docker-toolbox
###################
# Setup
###################
docker-machine create --driver virtualbox default
docker-machine start # only if not started
###################
# Environment
###################
eval $(docker-machine env)
EKS: KUBECTL
brew install kubectl
EKS: HEPTIO AUTHENTICATOR
############################
# Compile It in Go
############################
brew install go
mkdir ~/go
export GOPATH=${HOME}/go
export PATH=${GOPATH}/bin:${PATH}
go get -u -v github.com/heptio/authenticator/cmd/heptio-authenticator-aws
############################
# Download it from AWS
############################
HEPTIO_S3_PATH="1.10.3/2018-06-05/bin/darwin/amd64/heptio-authenticator-aws"
HEPTIO_S3_SITE="amazon-eks.s3-us-west-2.amazonaws.com"
HEPTIO_S3_URL="https://${HEPTIO_S3_SITE}/${HEPTIO_S3_PATH}"
curl -o heptio-authenticator-aws ${HEPTIO_S3_URL}
chmod +x ./heptio-authenticator-aws
cp heptio-authenticator-aws /usr/local/bin # assumes homebrew environment
EKS: EKSCTL
EKSCTL_PKG="eksctl_$(uname -s)_amd64.tar.gz"
EKSCTL_URL="https://github.com/weaveworks/eksctl/releases/download/latest_release/${EKSCTL_PKG}"
curl --silent --location "${EKSCTL_URL}" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
EKS: CREATE THE CLUSTER
EKS: CREATE THE CLUSTER
export EKS_CLUSTER_NAME="mycluster"
ssh-keygen -q -N "" -f ~/.ssh/${EKS_CLUSTER_NAME}.id_rsa
eksctl create cluster \
--cluster-name ${EKS_CLUSTER_NAME} \
--kubeconfig ~/.kube/config \
--nodes 3 \
--ssh-public-key ~/.ssh/${EKS_CLUSTER_NAME}.id_rsa.pub
EKS: CREATE THE CLUSTER
EKS: BUILD THE APP
aws ecr create-repository --repository-name redis-slave
aws ecr create-repository --repository-name guestbook
export ECR_REDIS_REPO=$(aws ecr describe-repositories \
--repository-names "redis-slave" \
--query 'repositories[*].[repositoryUri]' \
--output text
)
export ECR_GUESTBOOK_REPO=$(aws ecr describe-repositories \
--repository-names "guestbook" \
--query 'repositories[*].[repositoryUri]' \
--output text
)
# Log In to ECR
$(aws ecr get-login --no-include-email)
EKS: BUILD THE APP
GUESTBOOK_SITE=s3-us-west-2.amazonaws.com
GUESTBOOK_PATH=heptio-training/k8sintro/guestbook.tar.gz
wget https://${GUESTBOOK_SITE}/${GUESTBOOK_PATH}
tar -zxvf guestbook.tar.gz
cd guestbook/redis-slave
docker build -t redis-slave:v1 .
docker tag redis-slave:v1 ${ECR_REDIS_REPO}:v1
docker push ${ECR_REDIS_REPO}
cd ../guestbook
docker build -t guestbook:v1 .
docker tag guestbook:v1 ${ECR_GUESTBOOK_REPO}:v1
docker push ${ECR_GUESTBOOK_REPO}
cd ..
EKS: DEPLOY THE APP
EKS: DEPLOY THE APP
kubectl apply -f redis-master-service.yaml
kubectl apply -f redis-master-deployment.yaml
kubectl apply -f redis-slave-service.yaml
sed "s@ECR_REDIS_REPO@${ECR_REDIS_REPO}@" \
redis-slave-deployment.yaml > \
redis-slave-deployment-resolved.yaml
kubectl apply -f redis-slave-deployment-resolved.yaml
kubectl create -f frontend-service.yaml
sed "s@ECR_GUESTBOOK_REPO@${ECR_GUESTBOOK_REPO}@" \
frontend-deployment.yaml > \
frontend-deployment-resolved.yaml
kubectl apply -f frontend-deployment-resolved.yaml
deck
By Joaquín Menchaca
deck
- 548