1
1
# cloud-config
2
2
3
3
packages :
4
+ {{if not .OrchestratorProfile.IsCustomEtcdVersion}}
4
5
- etcd
6
+ {{end}}
5
7
- jq
6
8
- traceroute
7
9
@@ -292,6 +294,7 @@ write_files:
292
294
sed -i "/requestheader-group-headers/d" "/etc/kubernetes/manifests/kube-apiserver.yaml"
293
295
sed -i "/requestheader-username-headers/d" "/etc/kubernetes/manifests/kube-apiserver.yaml"
294
296
{{end}}
297
+ sed -i "s|<etcdApiVersion>|{{ .OrchestratorProfile.GetAPIServerEtcdAPIVersion }}|g" "/etc/kubernetes/manifests/kube-apiserver.yaml"
295
298
296
299
- path : " /opt/azure/containers/provision.sh"
297
300
permissions : " 0744"
@@ -307,7 +310,57 @@ write_files:
307
310
content : !!binary |
308
311
{{WrapAsVariable "mountetcdScript"}}
309
312
313
+ {{if .OrchestratorProfile.IsCustomEtcdVersion}}
314
+ - path : " /etc/systemd/system/etcd.service"
315
+ permissions : " 0644"
316
+ owner : " root"
317
+ content : |
318
+ [Unit]
319
+ Description=etcd - highly-available key value store
320
+ Documentation=https://github.com/coreos/etcd
321
+ Documentation=man:etcd
322
+ After=network.target
323
+ Wants=network-online.target
324
+ [Service]
325
+ Environment=DAEMON_ARGS=
326
+ Environment=ETCD_NAME=%H
327
+ Environment=ETCD_DATA_DIR=/var/lib/etcd/default
328
+ EnvironmentFile=-/etc/default/%p
329
+ Type=notify
330
+ User=etcd
331
+ PermissionsStartOnly=true
332
+ ExecStart=/usr/bin/etcd $DAEMON_ARGS
333
+ Restart=always
334
+ [Install]
335
+ WantedBy=multi-user.target
336
+ Alias=etcd.service
337
+
338
+ - path : " /opt/azure/containers/setup-etcd.sh"
339
+ permissions : " 0744"
340
+ owner : " root"
341
+ content : |
342
+ #!/bin/bash
343
+ # if provisioning using any etcd version other than 2.5.2
344
+ # We download it and set it up here
345
+ set -x
346
+ ETCD_VER=v{{ .OrchestratorProfile.KubernetesConfig.EtcdVersion }}
347
+ DOWNLOAD_URL=https://acs-mirror.azureedge.net/github-coreos # we use mirror to github
348
+ mkdir -p /tmp/etcd-download
349
+ curl -L ${DOWNLOAD_URL}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
350
+ tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /usr/bin/ --strip-components=1
351
+ #create etcd user
352
+ useradd -U "etcd"
353
+ usermod -p "$(head -c 32 /dev/urandom | base64)" "etcd"
354
+ passwd -u "$etcd" > /dev/null
355
+ # update systemctl and start service
356
+ systemctl daemon-reload
357
+ systemctl enable etcd.service
358
+ {{end}}
359
+
310
360
runcmd :
361
+ {{ if .OrchestratorProfile.IsCustomEtcdVersion }}
362
+ - /opt/azure/containers/setup-etcd.sh
363
+ {{end}}
311
364
- apt-mark hold walinuxagent {{GetKubernetesMasterPreprovisionYaml}}
312
365
- /bin/echo DAEMON_ARGS=--name "{{WrapAsVerbatim "variables('masterVMNames')[copyIndex(variables('masterOffset'))]"}}" --initial-advertise-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-peer-urls "{{WrapAsVerbatim "variables('masterEtcdPeerURLs')[copyIndex(variables('masterOffset'))]"}}" --advertise-client-urls "{{WrapAsVerbatim "variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))]"}}" --listen-client-urls "{{WrapAsVerbatim "concat(variables('masterEtcdClientURLs')[copyIndex(variables('masterOffset'))], ',http://127.0.0.1:', variables('masterEtcdClientPort'))"}}" --initial-cluster-token "k8s-etcd-cluster" --initial-cluster "{{WrapAsVerbatim "variables('masterEtcdClusterStates')[div(variables('masterCount'), 2)]"}} --data-dir "/var/lib/etcddisk"" --initial-cluster-state "new" | tee -a /etc/default/etcd
313
366
- sudo /bin/chown -R etcd:etcd /var/lib/etcd/default
0 commit comments