3838 bootstrap :
3939 name : Bootstrap cluster
4040 runs-on : ubuntu-latest
41+ outputs :
42+ kubeconfig-content : ${{ steps.generate-kubeconfig.outputs.config }}
4143 steps :
4244 - uses : actions/checkout@v4
4345 # with:
@@ -157,7 +159,8 @@ jobs:
157159 - name : Get info about nested master VM
158160 run : |
159161 cd test/dvp-over-dvp
160- nested_master=$(kubectl -n nightly-e2e-${{ steps.vars.outputs.sha_short }} get vm -l dvp.deckhouse.io/node-group=master -o jsonpath="{.items[0].metadata.name}")
162+ namespace=nightly-e2e-${{ steps.vars.outputs.sha_short }}
163+ nested_master=$(kubectl -n $namespace get vm -l dvp.deckhouse.io/node-group=master -o jsonpath="{.items[0].metadata.name}")
161164
162165 d8 k get vm -n "nightly-e2e-${{ steps.vars.outputs.sha_short }}"
163166 echo ""
@@ -180,9 +183,13 @@ jobs:
180183 ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }} \
181184 -c 'hostname'
182185
183- - name : Copy script for gen nested kubeconfig
186+ - name : Generate nested kubeconfig
187+ id : generate-kubeconfig
188+ env :
189+ kubeConfigPath : tmp/kube.config
184190 run : |
185- nested_master=$(kubectl -n nightly-e2e-${{ steps.vars.outputs.sha_short }} get vm -l dvp.deckhouse.io/node-group=master -o jsonpath="{.items[0].metadata.name}")
191+ namespace=nightly-e2e-${{ steps.vars.outputs.sha_short }}
192+ nested_master=$(kubectl -n $namespace get vm -l dvp.deckhouse.io/node-group=master -o jsonpath="{.items[0].metadata.name}")
186193
187194 d8vssh() {
188195 echo "$1 - 1 arg"
@@ -192,20 +199,23 @@ jobs:
192199 --local-ssh-opts="-o StrictHostKeyChecking=no" \
193200 --local-ssh-opts="-o UserKnownHostsFile=/dev/null" \
194201 ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }} \
195- $1
202+ $1 $2
196203 }
197204
198205 d8vscp() {
206+ local source=$1
207+ local dest=$2
199208 d8 v scp -i ./tmp/ssh/cloud \
200209 --local-ssh=true \
201210 --local-ssh-opts="-o StrictHostKeyChecking=no" \
202211 --local-ssh-opts="-o UserKnownHostsFile=/dev/null" \
203- $@
212+ $source $dest
204213 }
205214
206215 cd test/dvp-over-dvp
207216 # task configure:cluster:sa
208-
217+
218+ echo "Copy script for generating kubeconfig in nested cluster"
209219 echo "copy nested-sa-config/gen-sa.sh to master"
210220 d8vscp ./nested-sa-config/gen-sa.sh ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }}:/tmp/gen-sa.sh
211221 echo ""
@@ -221,30 +231,162 @@ jobs:
221231 echo "d8vssh -c 'chmod +x /tmp/gen-sa.sh' - done"
222232 echo ""
223233
234+ echo "Generate kube conf in nested cluster"
224235 echo "run nested-sa-config/gen-sa.sh"
225236 # d8vssh "-c 'sudo /tmp/gen-sa.sh'"
226- d8 v ssh -i ./tmp/ssh/cloud \
237+
238+ # "Usage: gen-sa.sh <SA_NAME> <CLUSTER_PREFIX> <CLUSTER_NAME> [FILE_NAME]"
239+
240+ d8 v ssh -i ./tmp/ssh/cloud \
227241 --local-ssh=true \
228242 --local-ssh-opts="-o StrictHostKeyChecking=no" \
229243 --local-ssh-opts="-o UserKnownHostsFile=/dev/null" \
230244 ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }} \
231- -c 'sudo /tmp/gen-sa.sh nested-sa nested nested-e2e'
232- echo "d8vssh -c 'sudo /tmp/gen-sa.sh nested-sa nested nested-e2e /tmp/kube.config' - done"
245+ -c 'sudo /tmp/gen-sa.sh nested-sa nested nested-e2e /${{ env.kubeConfigPath }}'
246+
247+ echo "d8vssh -c 'sudo /tmp/gen-sa.sh nested-sa nested nested-e2e /${{ env.kubeConfigPath }}' - done"
233248 echo ""
234249
235250 echo "copy kubeconfig to runner"
236- d8vscp ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }}:/tmp/kube.config tmp/kube.config
251+ d8vscp ${{ env.DEFAULT_USER }}@${nested_master}.nightly-e2e-${{ steps.vars.outputs.sha_short }}:/${{ env.kubeConfigPath }} ${{ env.kubeConfigPath }}
237252
238- echo "=== nestedt cluster via api get nodes ==="
239- sudo chown 1001:1001 tmp/kube.config
240- sudo chmod 600 tmp/kube.config
241- kubectl --kubeconfig=tmp/kube.config get nodes
253+ echo "=== nested cluster via api get nodes ==="
254+ echo "sudo chown 1001:1001 ${{ env.kubeConfigPath }}"
255+ sudo chown 1001:1001 ${{ env.kubeConfigPath }}
256+ echo "sudo chmod 600 ${{ env.kubeConfigPath }}"
257+ sudo chmod 600 ${{ env.kubeConfigPath }}
258+ echo "rights - done"
259+
260+ echo "-----"
261+ echo "cat ${{ env.kubeConfigPath }}"
262+ cat ${{ env.kubeConfigPath }}
263+ echo "-----"
242264 echo ""
243265
244- d8vssh "-c 'cat /etc/os-release'"
266+ echo "-----"
267+ CONFIG=$(cat ${{ env.kubeConfigPath }} | base64 -w 0)
268+ echo "$CONFIG"
269+ echo "-----"
270+ echo "config=$CONFIG" >> $GITHUB_OUTPUT
271+
272+ echo "cat ${{ env.kubeConfigPath }} - done"
273+
274+ echo "try d8 k"
275+ d8 k --kubeconfig=tmp/kube.config get nodes
276+
277+ # echo "kubectl --kubeconfig=tmp/kube.config get nodes"
278+ # export KUBECONFIG=$(pwd)/tmp/kube.config:$KUBECONFIG
279+ # kubectl config get-contexts
280+ # kubectl config use-context nested-e2e-nested-sa
281+ # kubectl get nodes
282+ # echo "kubectl get nodes, with nested cluster config- done"
283+ # echo ""
284+
285+ # echo "Test [ d8vssh -c 'cat /etc/os-release' ]"
286+ # d8vssh "-c 'cat /etc/os-release'"
287+
288+ - uses : actions/upload-artifact@v4
289+ id : artifact-upload
290+ if : always()
291+ with :
292+ name : generated-files
293+ path : |
294+ test/dvp-over-dvp/tmp
295+ test/dvp-over-dvp/values.yaml
296+
297+ overwrite : true
298+ include-hidden-files : true
299+ retention-days : 1
300+ # - name: Add annotation with the URL
301+ # run: |
302+ # ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload.outputs.artifact-id }}"
303+ # echo "::notice title=Artifact Uploaded::Artifact available at: $ARTIFACT_URL"
304+
305+ configure-storage :
306+ name : Configure storage
307+ runs-on : ubuntu-latest
308+ needs : bootstrap
309+ steps :
310+ - uses : actions/checkout@v4
311+
312+ - name : Install Task
313+ uses : arduino/setup-task@v2
314+ with :
315+ version : 3.x
316+ repo-token : ${{ secrets.GITHUB_TOKEN }}
317+ - name : Install kubectl CLI
318+ uses : azure/setup-kubectl@v4
319+
320+
321+ - name : Restore kubeconfig from output
322+ run : |
323+ mkdir -p ~/.kube
324+ echo "get kubeconfig-content"
325+ echo "${{ needs.bootstrap.outputs.kubeconfig-content }}"
326+ echo "${{ needs.bootstrap.outputs.kubeconfig-content }}" | base64 -d > ~/.kube/config
327+ echo "---"
328+ echo "Show paths and files content"
329+ ls -la ~/.kube
330+ cat ~/.kube/config
331+ chmod 600 ~/.kube/config
332+ echo "-- end Show paths and files content --"
333+ kubectl config get-contexts
334+ kubectl config view
335+ # ----------
336+ PING_HOST=$(yq e '.clusters[0].cluster.server' ~/.kube/config)
337+ echo "ping $PING_HOST"
338+ ping -c 1 $PING_HOST
339+ # ----------
340+ echo "curl -v $PING_HOST"
341+ curl -v $PING_HOST
342+ # ----------
343+ echo "kubectl get nodes"
344+ kubectl get nodes
345+
346+ undeploy-infra :
347+ name : Undeploy infra
348+ runs-on : ubuntu-latest
349+ needs :
350+ - bootstrap
351+ - configure-storage
352+ if : ${{ always() }}
353+ steps :
354+ - uses : actions/checkout@v4
355+
356+ - name : Install htpasswd utility
357+ run : |
358+ sudo apt-get update
359+ sudo apt-get install -y apache2-utils
360+
361+ - name : Setup d8
362+ uses : ./.github/actions/install-d8
363+
364+ - name : Install Task
365+ uses : arduino/setup-task@v2
366+ with :
367+ version : 3.x
368+ repo-token : ${{ secrets.GITHUB_TOKEN }}
245369
370+ - name : Download artifacts
371+ uses : actions/download-artifact@v5
372+ with :
373+ name : generated-files
374+ path : test/dvp-over-dvp/
375+
376+ - name : Show paths and files content
377+ run : |
378+ ls -la test/dvp-over-dvp/tmp
379+ ls -la test/dvp-over-dvp/tmp/
380+ cat test/dvp-over-dvp/values.yaml | tail -n +8
381+
382+ - name : Configure kubectl via azure/k8s-set-context@v4
383+ uses : azure/k8s-set-context@v4
384+ with :
385+ method : kubeconfig
386+ context : e2e-cluster-nightly-e2e-virt-sa
387+ kubeconfig : ${{ secrets.VIRT_E2E_NIGHTLY_SA_TOKEN }}
388+
246389 - name : infra-undeploy
247- if : ${{ always() }}
248390 run : |
249391 cd test/dvp-over-dvp
250392 task infra-undeploy
0 commit comments