This is an automated email from the ASF dual-hosted git repository.

d4rkstar pushed a commit to branch 0.9.1
in repository https://gitbox.apache.org/repos/asf/openserverless-operator.git


The following commit(s) were added to refs/heads/0.9.1 by this push:
     new fd0f475  build: unify build-and-load task with kube type detection 
(#116)
fd0f475 is described below

commit fd0f475d70efcadf14182675a262a72b6c674f1d
Author: Bruno Salzano <[email protected]>
AuthorDate: Sun Aug 23 19:01:29 2026 +0200

    build: unify build-and-load task with kube type detection (#116)
    
    Merge the kind/k3s build-and-load tasks into a single task that detects
    the cluster type via `ops debug kube detect` and adds microk8s support.
    Rename microk8s.yml's KUBECONFIG var to MIK_KUBECONFIG to avoid clashing
    with the KUBECONFIG env var.
---
 TaskfileBuild.yml     | 32 ++++++++++++++++++++++----------
 clusters/microk8s.yml |  8 ++++----
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/TaskfileBuild.yml b/TaskfileBuild.yml
index 81e018b..4039dd3 100644
--- a/TaskfileBuild.yml
+++ b/TaskfileBuild.yml
@@ -47,16 +47,28 @@ tasks:
     - docker push ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}
 
   build-and-load:
-    - task: build
-    - > 
-      kind load docker-image 
-      ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}} 
-      --name=nuvolaris
-
-  k3s:build-and-load:
-    - task: build
-    - >
-      docker save ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}} 
| sudo k3s ctr images import -
+    silent: true
+    desc: Build the image and loads it to the local Kind, k3s, microk8s cluster
+    vars:
+      KUB_TYPE:
+        sh: "ops debug kube detect"
+    cmds:
+      - task: build
+      - |
+        IMG="${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}"
+        if [ "{{.KUB_TYPE}}" = "kind" ]; then
+          echo "Loading image to kind"
+          kind load docker-image $IMG --name=nuvolaris
+        elif [ "{{.KUB_TYPE}}" = "k3s" ]; then
+          echo "Loading image to k3s"
+          docker save $IMG | sudo k3s ctr images import -
+        elif [ "{{.KUB_TYPE}}" = "microk8s" ]; then
+          echo "Loading image to microk8s"
+          docker save $IMG | microk8s ctr images import -
+        else
+          echo "Error: unsupported KUB_TYPE '{{.KUB_TYPE}}' for loading images"
+          exit 1
+        fi
 
   buildx-and-push:
     - > 
diff --git a/clusters/microk8s.yml b/clusters/microk8s.yml
index bbc5b6f..8c7f9f5 100644
--- a/clusters/microk8s.yml
+++ b/clusters/microk8s.yml
@@ -32,7 +32,7 @@ vars:
         else echo unknown
         fi
   STACK: "{{.GITHUB_USER}}-nuvolaris-dev"
-  KUBECONFIG: "microk8s-{{.GITHUB_USER}}.kubeconfig"
+  MIK_KUBECONFIG: "microk8s-{{.GITHUB_USER}}.kubeconfig"
   
 tasks:
 
@@ -73,8 +73,8 @@ tasks:
         ssh -i id_rsa -o "StrictHostKeyChecking=no" \
         "ubuntu@$(cat {{.APIHOST}})" sudo cloud-init status --wait
         scp -i id_rsa -o "StrictHostKeyChecking=no" \
-        "ubuntu@$(cat {{.APIHOST}}):/etc/kubeconfig" {{.KUBECONFIG}}
-      - cp -v {{.KUBECONFIG}} ~/.kube/config
+        "ubuntu@$(cat {{.APIHOST}}):/etc/kubeconfig" {{.MIK_KUBECONFIG}}
+      - cp -v {{.MIK_KUBECONFIG}} ~/.kube/config
       - kubectl get nodes
 
   import-key: 
@@ -90,6 +90,6 @@ tasks:
     cmds:
     - echo user  {{.GITHUB_USER}}
     - echo stack {{.STACK}}
-    - echo kubeconfig {{.KUBECONFIG}}
+    - echo kubeconfig {{.MIK_KUBECONFIG}}
     silent: true
     

Reply via email to