Skip to content

Instantly share code, notes, and snippets.

@hamdikh
Last active January 30, 2019 15:12
Show Gist options
  • Save hamdikh/8ed0f04f479d4fde493e22576b33533a to your computer and use it in GitHub Desktop.
Save hamdikh/8ed0f04f479d4fde493e22576b33533a to your computer and use it in GitHub Desktop.

Amazon KOPS

Install kubectl and kops

brew update && brew install kubectl

brew install kops

brew install awscli

Kops configuration

aws configure ( for Creds )

Route53 for DNS

S3 Bucket for storage ( KOPS_STATE_STORE for etcd ) you'll get a bucket name and stuff like that exple hkhelil.bucket.com

Cluster creation/deletion

kops create cluster --zone=us-east-1c hkhelil.bucket.com

kops update cluster

kops delete cluster

kops get clusters [-o yaml]

K8S playground

kubeadm init --apiserver-advertise-adress $(hostname)

kubeadm join --token  

kubectl get nodes

K8S Administration Bare Metal

Create your infra ( master and nodes ) 1 master 3 nodes minumum

The master

apt-get update

apt-get install apt-transport-https

apt-get install docker.io

docker --version 

systemctl start docker

systemctl enable docker

curl -s https://packages.cloud.google.com/apt/doc/apt-key.pgp | apt add-key add

vi /etc/apt/sources.list.d/kubernetes.list

file :

deb http://apt.kubernetes.io kubernetes-xenial main

apt-get update 

apt-get install -y kubelet kubeadm kubectl kubernetes-cni

Now that's done !

Kubeadm

kubeadm init

NOTE: this command genrates config files and a token to use for join

Now to configure your master config file you need to

mkdir $HOME/.kube

cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

chown $(id -u):$(id -g) $HOME/.kube/config

Deploy the kube pod network and flannel RBAC

https://github.com/coreos/flannel/

https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

https://github.com/coreos/flannel/blob/master/Documentation/k8s-manifests/kube-flannel-rbac.yml

kubectl apply -f [podnetwork].yaml

kubectl apply -f [kube-flanel-rbac].yaml

Worker nodes - Join nodes

kubeadm join --token $TOKEN $IP_ADR:6443 --discovery-token-ca-cert-hash sha256:$SHA

Test the bootstrapped K8S clusters

kubectl get no --show-labels -owide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment