Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
k8smulti/provision.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
206 lines (181 sloc)
6.13 KB
This file contains 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 -eux | |
KUBELET_IP=$1; export KUBELET_IP | |
source /vagrant/versions.rc | |
PATH=$PATH:/usr/local/bin; export PATH | |
DEBIAN_FRONTEND=noninteractive; export DEBIAN_FRONTEND | |
echo 'Acquire::http { Proxy "http://192.168.56.99:3142"; };' > /etc/apt/apt.conf.d/02proxy | |
dpkg --remove docker docker-engine docker.io containerd runc | |
# k8s repo setup | |
curl -q -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
curl -q -s https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu/ $(lsb_release -cs) stable" | |
# disable swap | |
swapoff -a | |
grep -v swap /etc/fstab > /etc/fstab.tmp && mv /etc/fstab.tmp /etc/fstab | |
# install OS packages | |
apt-get update -qq | |
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common \ | |
lvm2 net-tools htop \ | |
containerd.io=${CONTAINERD_VERSION} \ | |
kubelet=${KUBE_PKG_VERSION} kubeadm=${KUBE_PKG_VERSION} kubectl=${KUBE_PKG_VERSION} | |
mkdir -p /etc/containerd | |
cat <<EOF > /etc/containerd/config.toml | |
version = 2 | |
root = "/var/lib/containerd" | |
state = "/run/containerd" | |
plugin_dir = "" | |
disabled_plugins = [] | |
required_plugins = [] | |
oom_score = 0 | |
[grpc] | |
address = "/run/containerd/containerd.sock" | |
tcp_address = "" | |
tcp_tls_cert = "" | |
tcp_tls_key = "" | |
uid = 0 | |
gid = 0 | |
max_recv_message_size = 16777216 | |
max_send_message_size = 16777216 | |
[ttrpc] | |
address = "" | |
uid = 0 | |
gid = 0 | |
[debug] | |
address = "" | |
uid = 0 | |
gid = 0 | |
level = "" | |
[metrics] | |
address = "" | |
grpc_histogram = false | |
[cgroup] | |
path = "" | |
[timeouts] | |
"io.containerd.timeout.shim.cleanup" = "5s" | |
"io.containerd.timeout.shim.load" = "5s" | |
"io.containerd.timeout.shim.shutdown" = "3s" | |
"io.containerd.timeout.task.state" = "2s" | |
[plugins] | |
[plugins."io.containerd.gc.v1.scheduler"] | |
pause_threshold = 0.02 | |
deletion_threshold = 0 | |
mutation_threshold = 100 | |
schedule_delay = "0s" | |
startup_delay = "100ms" | |
[plugins."io.containerd.grpc.v1.cri"] | |
disable_tcp_service = true | |
stream_server_address = "127.0.0.1" | |
stream_server_port = "0" | |
stream_idle_timeout = "4h0m0s" | |
enable_selinux = false | |
selinux_category_range = 1024 | |
sandbox_image = "k8s.gcr.io/pause:3.2" | |
stats_collect_period = 10 | |
systemd_cgroup = false | |
enable_tls_streaming = false | |
max_container_log_line_size = 16384 | |
disable_cgroup = false | |
disable_apparmor = false | |
restrict_oom_score_adj = false | |
max_concurrent_downloads = 3 | |
disable_proc_mount = false | |
unset_seccomp_profile = "" | |
tolerate_missing_hugetlb_controller = true | |
disable_hugetlb_controller = true | |
ignore_image_defined_volumes = false | |
[plugins."io.containerd.grpc.v1.cri".containerd] | |
snapshotter = "overlayfs" | |
default_runtime_name = "runc" | |
no_pivot = false | |
disable_snapshot_annotations = true | |
discard_unpacked_layers = false | |
[plugins."io.containerd.grpc.v1.cri".containerd.default_runtime] | |
runtime_type = "" | |
runtime_engine = "" | |
runtime_root = "" | |
privileged_without_host_devices = false | |
base_runtime_spec = "" | |
[plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime] | |
runtime_type = "" | |
runtime_engine = "" | |
runtime_root = "" | |
privileged_without_host_devices = false | |
base_runtime_spec = "" | |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes] | |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] | |
runtime_type = "io.containerd.runc.v2" | |
runtime_engine = "" | |
runtime_root = "" | |
privileged_without_host_devices = false | |
base_runtime_spec = "" | |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] | |
SystemdCgroup = true | |
[plugins."io.containerd.grpc.v1.cri".cni] | |
bin_dir = "/opt/cni/bin" | |
conf_dir = "/etc/cni/net.d" | |
max_conf_num = 1 | |
conf_template = "" | |
[plugins."io.containerd.grpc.v1.cri".registry] | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors] | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] | |
endpoint = ["http://192.168.56.99:5000"] | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."192.168.56.99:5001"] | |
endpoint = ["http://192.168.56.99:5001"] | |
[plugins."io.containerd.grpc.v1.cri".image_decryption] | |
key_model = "" | |
[plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming] | |
tls_cert_file = "" | |
tls_key_file = "" | |
[plugins."io.containerd.internal.v1.opt"] | |
path = "/opt/containerd" | |
[plugins."io.containerd.internal.v1.restart"] | |
interval = "10s" | |
[plugins."io.containerd.metadata.v1.bolt"] | |
content_sharing_policy = "shared" | |
[plugins."io.containerd.monitor.v1.cgroups"] | |
no_prometheus = false | |
[plugins."io.containerd.runtime.v1.linux"] | |
shim = "containerd-shim" | |
runtime = "runc" | |
runtime_root = "" | |
no_shim = false | |
shim_debug = false | |
[plugins."io.containerd.runtime.v2.task"] | |
platforms = ["linux/amd64"] | |
[plugins."io.containerd.service.v1.diff-service"] | |
default = ["walking"] | |
[plugins."io.containerd.snapshotter.v1.devmapper"] | |
root_path = "" | |
pool_name = "" | |
base_image_size = "" | |
async_remove = false | |
EOF | |
systemctl daemon-reload | |
systemctl restart containerd | |
modprobe br_netfilter ip_vs | |
# networking config | |
cat <<EOF > /etc/sysctl.d/99-kubernetes-cri.conf | |
net.bridge.bridge-nf-call-iptables = 1 | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.ipv4.ip_forward = 1 | |
net.ipv4.conf.lxc*.rp_filter = 0 | |
EOF | |
sysctl --system | |
echo "KUBELET_EXTRA_ARGS=--node-ip=${KUBELET_IP}" > /etc/default/kubelet | |
# enable the kubelet | |
systemctl enable --now kubelet | |
systemctl daemon-reload | |
systemctl restart kubelet.service | |
if [ "master" = `hostname -s` ]; then | |
YAML=cluster.yaml | |
cp /vagrant/${YAML} . | |
echo "kubernetesVersion: v${KUBE_VERSION}" >> ${YAML} | |
kubeadm init --config=${YAML} | |
#--pod-network-cidr=10.217.0.0/16 | |
else | |
kubeadm join \ | |
192.168.56.100:6443 \ | |
--token abcdef.0123456789abcdef \ | |
--discovery-token-unsafe-skip-ca-verification | |
fi |