Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yunusemrecatalcam/f9c185da3cb049aa500878c5a250b489 to your computer and use it in GitHub Desktop.
Save yunusemrecatalcam/f9c185da3cb049aa500878c5a250b489 to your computer and use it in GitHub Desktop.
Creating a self managed kubernetes on aws ec2, integrated with aws-ebs
Spin up an ec2, add KubernetesCluster=kubernetes tag, you can change the name but you should pass it to the kubeadm init.
Login to the ec2 and install them;
sudo apt-get update
sudo apt-get install docker.io -y
sudo apt-get install apt-transport-https curl -y
wget https://packages.cloud.google.com/apt/doc/apt-key.gpg
sudo apt-key add apt-key.gpg
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt-get install kubeadm -y
This is needed for server to auth on aws;
sudo hostnamectl set-hostname $(curl -s http://169.254.169.254/latest/meta-data/local-hostname)
init, pass cidr for the flannel;
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Copy the adming kubeconfig to the default path;
mkdir -p /root/.kube
sudo cp -i /etc/kubernetes/admin.conf /root/.kube/config
sudo chown $(id -u):$(id -g) /root/.kube/config
export KUBECONFIG=/root/admin.conf
Install flannel, I'm also untainting the master as I'm setting up a one-node cluster
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml --kubeconfig /root/.kube/config
kubectl taint nodes --all node-role.kubernetes.io/master- --kubeconfig /root/.kube/config
INSTALL EBS-CSI
curl https://raw.githubusercontent.com/kubernetes-sigs/aws-ebs-csi-driver/master/deploy/kubernetes/secret.yaml > secret.yaml
edit secret, put your user with policy
kubectl apply -f secret.yaml
kubectl apply -k "github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/?ref=release-0.10"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment