Last active
July 31, 2017 22:01
-
-
Save ninnemana/2c46c7eeba189b6dcc73b8b72378cf5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud compute firewall-rules create default-allow-${HOST%.*} \ | |
--allow tcp:6443 \ | |
--target-tags ${HOST%.*}-cluster \ | |
--source-ranges 0.0.0.0/0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud compute instances create ${HOST%.*} \ | |
--can-ip-forward \ | |
--image-family ubuntu-1704 \ | |
--image-project ubuntu-os-cloud \ | |
--machine-type n1-standard-2 \ | |
--metadata kubernetes-version=stable-1.7,startup-script-url=https://raw.githubusercontent.com/ninnemana/kubeadm-single-node-cluster/master/startup.sh \ | |
--tags ${HOST%.*}-cluster \ | |
--scopes cloud-platform,logging-write \ | |
--zone us-central1-a | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF > kubernetes.list | |
deb http://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
sudo mv kubernetes.list /etc/apt/sources.list.d/kubernetes.list | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https | |
sudo apt-get install -y docker.io | |
sudo apt-get install -y kubelet kubeadm | |
sudo systemctl enable docker.service | |
cat <<EOF > 20-cloud-provider.conf | |
Environment="KUBELET_EXTRA_ARGS=--cloud-provider=gce" | |
EOF | |
sudo mv 20-cloud-provider.conf /etc/systemd/system/kubelet.service.d/ | |
systemctl daemon-reload | |
systemctl restart kubelet | |
EXTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ | |
http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip) | |
INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ | |
http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) | |
KUBERNETES_VERSION=$(curl -s -H "Metadata-Flavor: Google" \ | |
http://metadata.google.internal/computeMetadata/v1/instance/attributes/kubernetes-version) | |
cat <<EOF > kubeadm.conf | |
kind: MasterConfiguration | |
apiVersion: kubeadm.k8s.io/v1alpha1 | |
cloudProvider: gce | |
kubernetesVersion: ${KUBERNETES_VERSION} | |
apiServerCertSANs: | |
- 10.96.0.1 | |
- ${EXTERNAL_IP} | |
- ${INTERNAL_IP} | |
EOF | |
sudo kubeadm init \ | |
--config=kubeadm.conf | |
sudo cp /etc/kubernetes/admin.conf $HOME/ | |
sudo chown $(id -u):$(id -g) $HOME/admin.conf | |
export KUBECONFIG=$HOME/admin.conf | |
kubectl taint nodes --all node-role.kubernetes.io/master- \ | |
--kubeconfig $HOME/admin.conf | |
kubectl apply \ | |
-f http://docs.projectcalico.org/v2.3/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml \ | |
--kubeconfig /etc/kubernetes/admin.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment