@@ -88,7 +88,6 @@ onAfterScaleOut[cp]:
8888 - set:
8989 nodes: ${event.response.nodes.join(id,)}
9090 ips: ${event.response.nodes.join(extIPs,)}
91- - prepare-worker-integration
9291 - cmd [${this.nodes}]: init-instance.sh --type=worker --initial=true --base-url=$(echo '${baseUrl}' | base64 -w 0)
9392 - connect-workers: ${this.nodes}
9493 - apply-worker-config: ${this.nodes}
@@ -166,17 +165,19 @@ actions:
166165 user: root
167166 sync: false
168167
169- prepare -worker-integration:
168+ apply -worker-integration:
170169 - cmd[${nodes.k8sm.master.id}]: tar zcfv - /var/lib/kubelet/worker-data 2>/dev/null | base64 -w 0
171- - setGlobals :
170+ - set :
172171 worker_integration: ${response.out}
172+ - cmd[${this.nodes}]: |-
173+ mkdir /var/lib/worker &>/dev/null || rm -rf /var/lib/worker/*
174+ echo '${this.worker_integration}' | base64 -d | tar zxv --strip-components=4 -C /var/lib/worker
175+ screen -d -m /usr/bin/bash -c '/usr/local/sbin/worker-integration.sh &>/var/log/kubernetes/k8s-worker-integration.log'
173176
174177 apply-worker-config:
175178 - cmd[${nodes.k8sm.master.id}]: screen -d -m /usr/local/sbin/worker-config -n ${this} -g cp -r ${env.region}
176- - cmd[${this}]: |-
177- mkdir /var/lib/worker &>/dev/null || rm -rf /var/lib/worker/*
178- echo '${globals.worker_integration}' | base64 -d | tar zxv --strip-components=4 -C /var/lib/worker
179- screen -d -m /usr/bin/bash -c '/usr/local/sbin/worker-integration.sh &>/var/log/kubernetes/k8s-worker-integration.log'
179+ - apply-worker-integration:
180+ nodes: ${this}
180181
181182 init-main-master:
182183 - if (${nodes.mbl.length:0}):
@@ -203,7 +204,6 @@ actions:
203204 - cmd[${nodes.k8sm.master.id}]: sed -n '/kubeadm join/,/^$/{/./p}' /var/log/kubeadm-init.log | sed ':a;N;$!ba;s/\\\n//g' | grep -v 'control-plane'
204205 - setGlobals:
205206 worker_join_cmd: ${response.out}
206- - prepare-worker-integration
207207
208208 init-slave-masters:
209209 - script: |
@@ -821,7 +821,7 @@ addons:
821821 csrf_token=$(echo ${page_content} | perl -ne 'print "$1\n" if /new_cluster.*?authenticity_token"[[:blank:]]value="(.+?)"/' | sed -n 1p)
822822 echo "Add cluster CSRF token: ${csrf_token}"
823823 [ -n "${csrf_token}" ] || continue
824- page_content=$(curl -X POST -sk -b gitlab-jar.txt -c gitlab-jar.txt -d "cluster[name]=Kubernetes&cluster[platform_kubernetes_attributes][authorization_type]=rbac&cluster[managed]=1" --data-urlencode "cluster[platform_kubernetes_attributes][api_url]=${this.gitlab_api_url}" --data-urlencode "cluster[platform_kubernetes_attributes][ca_cert]=${this.gitlab_ca_cert}" --data-urlencode "cluster[platform_kubernetes_attributes][token]=${this.gitlab_token}" --data-urlencode "authenticity_token=${csrf_token}" '${this.gitlab_http_endpoint}/admin/clusters/create_user')
824+ page_content=$(curl -X POST -sk -b gitlab-jar.txt -c gitlab-jar.txt -d "cluster[name]=Kubernetes&cluster[platform_kubernetes_attributes][authorization_type]=rbac&cluster[managed]=1&cluster[namespace_per_environment]=1 " --data-urlencode "cluster[platform_kubernetes_attributes][api_url]=${this.gitlab_api_url}" --data-urlencode "cluster[platform_kubernetes_attributes][ca_cert]=${this.gitlab_ca_cert}" --data-urlencode "cluster[platform_kubernetes_attributes][token]=${this.gitlab_token}" --data-urlencode "authenticity_token=${csrf_token}" '${this.gitlab_http_endpoint}/admin/clusters/create_user')
825825 cluster_url=$(echo ${page_content} | perl -ne 'print "$1\n" if /You[[:blank:]]are[[:blank:]]being[[:blank:]]\<a[[:blank:]]href="(.+?)"\>redirected/' | sed -n 1p)
826826 echo "Kubernetes GitLab cluster: ${cluster_url}"
827827 [ -n "${cluster_url}" ] && break || continue
@@ -849,8 +849,8 @@ addons:
849849 echo 'GITLAB_REGISTRY="${this.gitlab_domain}:${this.gitlab_reg_port}"' > /var/lib/kubelet/worker-data/gitlab-integration.conf
850850 wget -nv ${baseUrl}/addons/gitlab/gitlab-integration.sh -O /var/lib/kubelet/worker-data/gitlab-integration.sh
851851 chmod +x /var/lib/kubelet/worker-data/gitlab-integration.sh
852- - prepare -worker-integration
853- - apply-worker-integration : cp
852+ - apply -worker-integration:
853+ nodes : cp
854854
855855 addon-gitlab-remove:
856856 - cmd[${nodes.k8sm.master.id}]: kubectl get ns gitlab-managed-apps &>/dev/null && echo "true" || echo "false"
0 commit comments