Browse Source

Add Ubuntu version of heat-config-kubelet

Adds Ubuntu-compatible version of heat-config-kubelet.

Change-Id: Ideb9d57e7ab719e4f45cd5bc8cd92056ad478a64
Mariusz 4 months ago
parent
commit
b1f36deedc
1 changed files with 72 additions and 2 deletions
  1. 72
    2
      heat-config-kubelet/install.d/50-heat-config-kubelet

+ 72
- 2
heat-config-kubelet/install.d/50-heat-config-kubelet View File

@@ -73,10 +73,80 @@ EOF
73 73
     systemctl enable heat-config-kubelet-nat-rule.service
74 74
     systemctl disable firewalld
75 75
 
76
-SCRIPTDIR=$(dirname $0)
77
-install -D -g root -o root -m 0755 ${SCRIPTDIR}/hook-kubelet.py /var/lib/heat-config/hooks/kubelet
76
+elif [[ "ubuntu" =~ "$DISTRO_NAME" ]]; then
77
+    apt-get update
78
+    apt-get install -y apt-transport-https gnupg
79
+    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add
80
+    cat << EOF > /etc/apt/sources.list.d/kubernetes.list
81
+deb http://apt.kubernetes.io/ kubernetes-$(lsb_release -cs) main
82
+EOF
83
+    apt-get update
84
+    apt-get install -y kubelet kubeadm kubectl kubernetes-cni bridge-utils docker.io
85
+
86
+    cat << EOF > /etc/network/interfaces.d/cbr0.cfg
87
+auto cbr0
88
+iface cbr0 inet static
89
+bridge_ports none
90
+bridge_stp on
91
+bridge_waitport 2
92
+bridge_fd 2
93
+address 10.240.1.1
94
+netmask 255.255.255.0
95
+mtu 1450
96
+post-up /bin/ip route add 10.240.0.0/16 dev cbr0 scope link src 10.240.1.1
97
+EOF
98
+
99
+# defer docker starting until cbr0 is up
100
+cat > /etc/systemd/system/docker.service <<EOF
101
+.include /lib/systemd/system/docker.service
102
+[Unit]
103
+After=network-online.target docker.socket
104
+EOF
105
+
106
+    cat > /etc/systemd/system/heat-config-kubelet-nat-rule.service <<EOF
107
+[Unit]
108
+Description=iptables rule to allow nat masquerading out of 10.240.1.0/24
109
+
110
+[Service]
111
+ExecStart=/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 10.240.1.0/24 -j MASQUERADE
112
+Type=oneshot
113
+
114
+[Install]
115
+WantedBy=multi-user.target
116
+EOF
117
+
118
+if [ -f "/opt/heat-docker/images.tar" ]; then
119
+    cat > /etc/systemd/system/heat-config-kubelet-load-images.service <<EOF
120
+[Unit]
121
+Description=Call docker load on /opt/heat-config/images.tar
122
+After=docker.service
123
+Before=os-collect-config.service kubelet.service
124
+
125
+[Service]
126
+ExecStart=/usr/bin/docker load -i /opt/heat-docker/images.tar
127
+ExecStart=/bin/rm -f /opt/heat-docker/images.tar
128
+Type=oneshot
129
+
130
+[Install]
131
+WantedBy=multi-user.target
132
+EOF
133
+    systemctl enable heat-config-kubelet-load-images.service
134
+fi
135
+
136
+    cat << EOF > /etc/docker/daemon.json
137
+{ "bridge": "cbr0", "mtu": 1450, "iptables": false, "insecure-registries": ["192.168.20.112:5001"] }
138
+EOF
139
+
140
+    sed -e 's|KUBELET_EXTRA_ARGS=|KUBELET_EXTRA_ARGS="--config=/var/lib/heat-config/heat-config-kubelet/kubelet-manifests"|g' -i /etc/default/kubelet
141
+    systemctl disable docker.service
142
+    systemctl enable docker.service
143
+    systemctl enable kubelet.service
144
+    systemctl enable heat-config-kubelet-nat-rule.service
78 145
 
79 146
 else
80 147
     echo "Distribution '$DISTRO_NAME' is not supported"
81 148
     exit 1
82 149
 fi
150
+
151
+SCRIPTDIR=$(dirname $0)
152
+install -D -g root -o root -m 0755 ${SCRIPTDIR}/hook-kubelet.py /var/lib/heat-config/hooks/kubelet

Loading…
Cancel
Save