KOPS_STATE_STORE : is the source of truth for all clusters managed by Kops
- Kubectl Installation
apt-get update && apt-get install -y apt-transport-https && apt-get install -y curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubectl
- Kops installation
wget https://github.com/kubernetes/kops/releases/download/1.9.0/kops-linux-amd64
chmod +x kops-linux-amd64
mv kops-linux-amd64 /usr/local/bin/kops
-
Aws cli install & configure
-
Installation
# pip install
pip -V || sudo apt-get install python-pip
# aws cli install
aws --version || pip install awscli --upgrade --user
# Add Aws to the path
export PATH=~/.local/bin:$PATH
- Configuration
aws configure
AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxx
Default region name [None]: eu-west-1
Default output format [None]: json
# export default AWS_PROFILE
export AWS_PROFILE=default
aws autocomplete install
complete -C '$(which aws_completer)' aws
- Create a route53 domain for your cluster
- Create an S3 bucket to store your clusters state
S3 bucket used to store all cluster configuration information
# Configurer les zones de dispo de KOPS :
export AWS_AVAILABILITY_ZONES="$(aws ec2 describe-availability-zones --query 'AvailabilityZones[].ZoneName' --output text | awk -v OFS="," '$1=$1')"
# Create the S3 bucket using
export S3_BUCKET=kops-state-store-$(cat /dev/urandom | LC_ALL=C tr -dc "[:alpha:]" | tr '[:upper:]' '[:lower:]' | head -c 32)
export KOPS_STATE_STORE=s3://${S3_BUCKET}
# S3 bucket creation
aws s3 mb $KOPS_STATE_STORE
# Activate S3 versioning
aws s3api put-bucket-versioning --bucket $S3_BUCKET --versioning-configuration Status=Enabled
- Build your cluster configuration
# Create ssh default user ssh key
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Créer un cluster dans un vpc privé
kops create cluster --name hef.cluster.k8s.local --master-count 3 --node-count 5 --zones $AWS_AVAILABILITY_ZONES --topology private --networking kube-router
# Lister les clusters existants
kops get cluster
# Editer un cluster
kops edit cluster hef.cluster.k8s.local
# Editer le fichier de config des nodes
kops edit ig --name=hef.cluster.k8s.local nodes
# Editer la config d'un master
kops edit ig --name=hef.cluster.k8s.local master-eu-west-1a
- Create the cluster in AWS
# Mettre a jour le cluster :
kops update cluster hef.cluster.k8s.local --yes
# Valider l'état du cluster :
kops validate cluster
# Récupérer le DNS du load balancer d'api :
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].DNSName'
- Installer le dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
- Récupérer le mot de passe admin
kops get secrets admin --type secret -oplaintext
- Updating cluster configuration
kops rolling-update cluster --yes
- Cleanup
kops delete cluster hef.cluster.k8s.local --yes
- Kubernetes upgrading version (Manual update)
kops edit cluster $NAME
set the KubernetesVersion to the target version (e.g. v1.3.5)
kops update cluster $NAME to preview, then kops update cluster $NAME --yes
kops rolling-update cluster $NAME to preview, then kops rolling-update cluster $NAME --yes
Installing Kubernetes on AWS with kops (Kubernetes doc off) create cluster