Browse Source

Added command to wait for cloud-init to be done

If using ubuntu image, cloud-init has to finish before other apt
command can be performed. This patch added logic to make sure
that cloud-init get finished before proceed with other tasks.
This patch also contains changes to make the seeding docker images
more generic so that any docker image can be included in a tar.gz
file, the images in the file will be docker loaded onto each worker
node

Change-Id: I505cdb791673dc978bc21b73f7ad672172340a9d
Tong Li 2 years ago
parent
commit
77439ae873

+ 5
- 0
workloads/ansible/shade/k8s/roles/common/tasks/main.yml View File

@@ -9,6 +9,11 @@
9 9
     service_path: "/lib/systemd/system/"
10 10
   when: app_env.target_os == "ubuntu"
11 11
 
12
+- name: Make sure that cloud-init script has completed
13
+  wait_for:
14
+    path: "/run/cloud-init/result.json"
15
+  when: app_env.target_os == "ubuntu"
16
+
12 17
 - name: Install Docker Engine
13 18
   apt:
14 19
     name: docker.io

+ 18
- 7
workloads/ansible/shade/k8s/roles/worker/tasks/main.yml View File

@@ -139,12 +139,23 @@
139 139
     - kubelet
140 140
     - kube-proxy
141 141
 
142
-- name: Load cockroachdb images
142
+- name: Get all container image tar files
143 143
   command: "{{ item }}"
144 144
   with_items:
145
-    - "wget -q -O /opt/bin/cockroachdb.tar.gz {{ app_env.cockroachdb_repo }}"
146
-    - "tar xf /opt/bin/cockroachdb.tar.gz -C /opt/bin"
147
-    - "docker load --input /opt/bin/cockroachdb.tar"
148
-  when: app_env.cockroachdb_repo != ""
149
-  no_log: True
150
-
145
+    - "mkdir -p /opt/bin/containerimages"
146
+    - "rm -f /opt/bin/containerimages/*"
147
+    - "wget -q -O /opt/bin/cimages.tar.gz {{ app_env.cimages_repo }}"
148
+    - "tar xf /opt/bin/cimages.tar.gz -C /opt/bin/containerimages"
149
+  when: app_env.cimages_repo != ""
150
+
151
+- name: List all the container images tar files
152
+  find:
153
+    paths: "/opt/bin/containerimages"
154
+    patterns: "*.tar"
155
+  when: app_env.cimages_repo != ""
156
+  register: tarfiles
157
+
158
+- name: Load container images
159
+  command: "docker load --input {{ item.path }}"
160
+  with_items: " {{ tarfiles.files }} "
161
+  when: app_env.cimages_repo != ""

+ 1
- 1
workloads/ansible/shade/k8s/vars/coreos.yml View File

@@ -41,7 +41,7 @@ app_env: {
41 41
   dashboard_service_ip: "172.16.0.5",
42 42
 
43 43
   # The following section shows an example when use a local repo.
44
-  cockroachdb_repo: "http://10.0.10.12/cockroachdb.tar.gz",
44
+  cimages_repo: "http://10.0.10.12/cimages.tar.gz",
45 45
   flannel_repo: "http://10.0.10.12/flannel-v0.7.0-linux-amd64.tar.gz",
46 46
   k8s_repo: "http://10.0.10.12/v1.5.4/"
47 47
 }

+ 1
- 1
workloads/ansible/shade/k8s/vars/ubuntu.yml View File

@@ -41,7 +41,7 @@ app_env: {
41 41
   dashboard_service_ip: "172.16.0.5",
42 42
 
43 43
   # The following section shows an example when use a remote repo.
44
-  cockroachdb_repo: "",
44
+  cimages_repo: "",
45 45
   flannel_repo: "https://github.com/coreos/flannel/releases/download/v0.7.0/flannel-v0.7.0-linux-amd64.tar.gz",
46 46
   k8s_repo: "https://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/linux/amd64/"
47 47
 }

Loading…
Cancel
Save