From 9492517a9909442466e9c3f7ccd198770e7932c7 Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Tue, 15 Oct 2024 23:53:07 +0300 Subject: [PATCH] Add k3k-kubelet image to the release workflow Signed-off-by: galal-hussein --- .github/workflows/release.yml | 11 ++++++- {virtual-kubelet => k3k-kubelet}/README.md | 0 {virtual-kubelet => k3k-kubelet}/main.go | 0 .../pkg/config/config.go | 0 .../pkg/kubelet/kubelet.go | 32 +++++++++++++------ .../pkg/provider/configure.go | 0 .../pkg/provider/node.go | 0 .../pkg/provider/provider.go | 0 .../pkg/provider/util.go | 0 pkg/controller/cluster/agent/shared.go | 2 +- 10 files changed, 34 insertions(+), 11 deletions(-) rename {virtual-kubelet => k3k-kubelet}/README.md (100%) rename {virtual-kubelet => k3k-kubelet}/main.go (100%) rename {virtual-kubelet => k3k-kubelet}/pkg/config/config.go (100%) rename {virtual-kubelet => k3k-kubelet}/pkg/kubelet/kubelet.go (91%) rename {virtual-kubelet => k3k-kubelet}/pkg/provider/configure.go (100%) rename {virtual-kubelet => k3k-kubelet}/pkg/provider/node.go (100%) rename {virtual-kubelet => k3k-kubelet}/pkg/provider/provider.go (100%) rename {virtual-kubelet => k3k-kubelet}/pkg/provider/util.go (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44c8c0e..ca3b8e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,7 @@ jobs: username: ${{ env.DOCKER_USERNAME }} password: ${{ env.DOCKER_PASSWORD }} - - name: Build container image + - name: Build controller image uses: docker/build-push-action@v5 with: context: . @@ -48,6 +48,15 @@ jobs: tags: rancher/k3k:${{ github.ref_name }} file: package/Dockerfile platforms: linux/amd64 + + - name: Build Virtual Kubelet image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: rancher/k3k:k3k-kubelet + file: package/Dockerfile + platforms: linux/amd64 \ No newline at end of file diff --git a/virtual-kubelet/README.md b/k3k-kubelet/README.md similarity index 100% rename from virtual-kubelet/README.md rename to k3k-kubelet/README.md diff --git a/virtual-kubelet/main.go b/k3k-kubelet/main.go similarity index 100% rename from virtual-kubelet/main.go rename to k3k-kubelet/main.go diff --git a/virtual-kubelet/pkg/config/config.go b/k3k-kubelet/pkg/config/config.go similarity index 100% rename from virtual-kubelet/pkg/config/config.go rename to k3k-kubelet/pkg/config/config.go diff --git a/virtual-kubelet/pkg/kubelet/kubelet.go b/k3k-kubelet/pkg/kubelet/kubelet.go similarity index 91% rename from virtual-kubelet/pkg/kubelet/kubelet.go rename to k3k-kubelet/pkg/kubelet/kubelet.go index f4d505f..82684a3 100644 --- a/virtual-kubelet/pkg/kubelet/kubelet.go +++ b/k3k-kubelet/pkg/kubelet/kubelet.go @@ -11,12 +11,12 @@ import ( "time" certutil "github.com/rancher/dynamiclistener/cert" + "github.com/rancher/k3k/k3k-kubelet/pkg/config" + "github.com/rancher/k3k/k3k-kubelet/pkg/provider" "github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1" "github.com/rancher/k3k/pkg/controller/cluster/server/bootstrap" "github.com/rancher/k3k/pkg/controller/kubeconfig" "github.com/rancher/k3k/pkg/controller/util" - "github.com/rancher/k3k/virtual-kubelet/pkg/config" - "github.com/rancher/k3k/virtual-kubelet/pkg/provider" "github.com/virtual-kubelet/virtual-kubelet/log" "github.com/virtual-kubelet/virtual-kubelet/node" "github.com/virtual-kubelet/virtual-kubelet/node/nodeutil" @@ -30,6 +30,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + "k8s.io/client-go/util/retry" ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -37,7 +38,7 @@ var ( Scheme = runtime.NewScheme() backoff = wait.Backoff{ Steps: 5, - Duration: 20 * time.Second, + Duration: 5 * time.Second, Factor: 2, Jitter: 0.1, } @@ -176,8 +177,14 @@ func virtRestConfig(ctx context.Context, virtualConfigPath string, hostClient ct return nil, err } endpoint := fmt.Sprintf("%s.%s", util.ServerSvcName(&cluster), util.ClusterNamespace(&cluster)) - b, err := bootstrap.DecodedBootstrap(cluster.Spec.Token, endpoint) - if err != nil { + var b *bootstrap.ControlRuntimeBootstrap + if err := retry.OnError(backoff, func(err error) bool { + return err == nil + }, func() error { + var err error + b, err = bootstrap.DecodedBootstrap(cluster.Spec.Token, endpoint) + return err + }); err != nil { return nil, fmt.Errorf("unable to decode bootstrap: %w", err) } adminCert, adminKey, err := kubeconfig.CreateClientCertKey( @@ -226,14 +233,21 @@ func kubeconfigBytes(url string, serverCA, clientCert, clientKey []byte) ([]byte } func loadTLSConfig(ctx context.Context, hostClient ctrlruntimeclient.Client, clusterName, clusterNamespace, nodeName, ipStr string) (*tls.Config, error) { - var cluster v1alpha1.Cluster + var ( + cluster v1alpha1.Cluster + b *bootstrap.ControlRuntimeBootstrap + ) if err := hostClient.Get(ctx, types.NamespacedName{Name: clusterName, Namespace: clusterNamespace}, &cluster); err != nil { return nil, err } - endpoint := fmt.Sprintf("%s.%s", util.ServerSvcName(&cluster), util.ClusterNamespace(&cluster)) - b, err := bootstrap.DecodedBootstrap(cluster.Spec.Token, endpoint) - if err != nil { + if err := retry.OnError(backoff, func(err error) bool { + return err != nil + }, func() error { + var err error + b, err = bootstrap.DecodedBootstrap(cluster.Spec.Token, endpoint) + return err + }); err != nil { return nil, fmt.Errorf("unable to decode bootstrap: %w", err) } altNames := certutil.AltNames{ diff --git a/virtual-kubelet/pkg/provider/configure.go b/k3k-kubelet/pkg/provider/configure.go similarity index 100% rename from virtual-kubelet/pkg/provider/configure.go rename to k3k-kubelet/pkg/provider/configure.go diff --git a/virtual-kubelet/pkg/provider/node.go b/k3k-kubelet/pkg/provider/node.go similarity index 100% rename from virtual-kubelet/pkg/provider/node.go rename to k3k-kubelet/pkg/provider/node.go diff --git a/virtual-kubelet/pkg/provider/provider.go b/k3k-kubelet/pkg/provider/provider.go similarity index 100% rename from virtual-kubelet/pkg/provider/provider.go rename to k3k-kubelet/pkg/provider/provider.go diff --git a/virtual-kubelet/pkg/provider/util.go b/k3k-kubelet/pkg/provider/util.go similarity index 100% rename from virtual-kubelet/pkg/provider/util.go rename to k3k-kubelet/pkg/provider/util.go diff --git a/pkg/controller/cluster/agent/shared.go b/pkg/controller/cluster/agent/shared.go index b2b5412..d693b05 100644 --- a/pkg/controller/cluster/agent/shared.go +++ b/pkg/controller/cluster/agent/shared.go @@ -13,7 +13,7 @@ import ( ) const ( - virtualKubeletImage = "husseingalal/k3k:k3k-kubelet" + virtualKubeletImage = "rancher/k3k:k3k-kubelet" ) type SharedAgent struct {