Skip to content

Instantly share code, notes, and snippets.

@andrewwippler
Created June 8, 2018 21:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewwippler/3f031536ef7d761792b8fce1fd967aef to your computer and use it in GitHub Desktop.
Save andrewwippler/3f031536ef7d761792b8fce1fd967aef to your computer and use it in GitHub Desktop.
Single node kubernetes cluster on AWS (with ECR)
apt-get update
apt-get upgrade -y
apt-get update && apt-get install -y apt-transport-https 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 kubelet kubeadm kubectl docker.io
# set up config file
export EXTERNAL_IP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
export INTERNAL_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
cat <<EOF > kubeadm.conf
kind: MasterConfiguration
apiVersion: kubeadm.k8s.io/v1alpha1
apiServerCertSANs:
- 10.96.0.1
- ${EXTERNAL_IP}
- ${INTERNAL_IP}
kubernetesVersion: 1.10.3
cloudProvider: aws
networking:
podSubnet: 10.244.0.0/16
EOF
# use config file
kubeadm init --config=kubeadm.conf
# needed on CentOS, but added for good measure
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# make below commands work
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
#remove the taint
kubectl taint nodes --all node-role.kubernetes.io/master-
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment