-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s_vm_config.yaml
65 lines (56 loc) · 1.75 KB
/
k8s_vm_config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#cloud-config
apt:
http_proxy: http://__apt_proxy__/
package_update: true
package_upgrade: true
packages:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- jq
- nfs-common
power_state:
delay: "+1"
mode: reboot
write_files:
- path: /opt/k8s_vm_entrypoint.sh
permissions: '0755'
content: |
#!/bin/bash -x
export DEBIAN_FRONTEND=noninteractive
printenv
mkdir -p /opt/config
echo "__docker_version__" > /opt/config/docker_version.txt
echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt
HOST_IP=$(hostname -I)
echo $HOST_IP `hostname` >> /etc/hosts
mkdir -p /etc/docker
if [ ! -z "__docker_proxy__" ]; then
cat > /etc/docker/daemon.json <<EOF
{
"insecure-registries" : ["__docker_proxy__"]
}
EOF
fi
# apt-get -y install linux-image-extra-$(uname -r)
# install docker 17.03
while ! hash docker &> /dev/null; do
curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh
usermod -aG docker ubuntu
sleep 10
done
apt-mark hold docker-ce
mkdir -p /dockerdata-nfs
echo "__rancher_private_ip_addr__:/dockerdata-nfs /dockerdata-nfs nfs noauto,noatime,fg,retry=1,x-systemd.automount,_netdev,soft,nolock,intr,tcp,actimeo=1800 0 0" | tee -a /etc/fstab
while [ ! -e /dockerdata-nfs/rancher_agent_cmd.sh ]; do
mount /dockerdata-nfs
sleep 10
done
cd ~
cp /dockerdata-nfs/rancher_agent_cmd.sh .
sed -i "s/docker run/docker run -e CATTLE_HOST_LABELS='__host_label__=true' -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh
source rancher_agent_cmd.sh
runcmd:
- /opt/k8s_vm_entrypoint.sh