Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=infrastructure.cluster.x-k8s.io
// +kubebuilder:object:generate=true
// +groupName=infrastructure.cluster.x-k8s.io
package v1alpha1

import (
Expand Down
22 changes: 11 additions & 11 deletions controllers/vcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"strings"
"time"

"github.com/go-logr/logr"
vclusterhelm "github.com/loft-sh/utils/pkg/helm"
"github.com/loft-sh/vcluster/pkg/util"
"github.com/loft-sh/vcluster/pkg/util/kubeconfig"
"github.com/loft-sh/vcluster/pkg/util/loghelper"
corev1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -59,7 +59,7 @@ type VClusterReconciler struct {
client.Client
HelmClient helm.Client
HelmSecrets *helm.Secrets
Log loghelper.Logger
Log logr.Logger
Scheme *runtime.Scheme
clusterKindExists bool
}
Expand All @@ -80,7 +80,7 @@ const (
)

func (r *VClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) {
r.Log.Debugf("Reconcile %s", req.NamespacedName)
r.Log.Info("Reconcile %s", req.NamespacedName)

// get virtual cluster object
vCluster := &v1alpha1.VCluster{}
Expand Down Expand Up @@ -166,22 +166,22 @@ func (r *VClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_
// check if we have to redeploy
err = r.redeployIfNeeded(ctx, vCluster)
if err != nil {
r.Log.Infof("error during virtual cluster deploy %s/%s: %v", vCluster.Namespace, vCluster.Name, err)
r.Log.Info("error during virtual cluster deploy %s/%s: %v", vCluster.Namespace, vCluster.Name, err)
conditions.MarkFalse(vCluster, v1alpha1.HelmChartDeployedCondition, "HelmDeployFailed", v1alpha1.ConditionSeverityError, "%v", err)
return ctrl.Result{RequeueAfter: time.Second * 5}, err
}

// check if vcluster is initialized and sync the kubeconfig Secret
restConfig, err := r.syncVClusterKubeconfig(ctx, vCluster)
if err != nil {
r.Log.Debugf("vcluster %s/%s is not ready: %v", vCluster.Namespace, vCluster.Name, err)
r.Log.Info("vcluster %s/%s is not ready: %v", vCluster.Namespace, vCluster.Name, err)
conditions.MarkFalse(vCluster, v1alpha1.KubeconfigReadyCondition, "CheckFailed", v1alpha1.ConditionSeverityWarning, "%v", err)
return ctrl.Result{RequeueAfter: time.Second * 5}, nil
}

vCluster.Status.Ready, err = r.checkReadyz(vCluster, restConfig)
if err != nil || !vCluster.Status.Ready {
r.Log.Debugf("readiness check failed: %v", err)
r.Log.Info("readiness check failed: %v", err)
return ctrl.Result{RequeueAfter: time.Second * 5}, nil
}

Expand Down Expand Up @@ -216,7 +216,7 @@ func (r *VClusterReconciler) redeployIfNeeded(ctx context.Context, vCluster *v1a
return nil
}

r.Log.Debugf("upgrade virtual cluster helm chart %s/%s", vCluster.Namespace, vCluster.Name)
r.Log.Info("upgrade virtual cluster helm chart %s/%s", vCluster.Namespace, vCluster.Name)

var chartRepo string
if vCluster.Spec.HelmRelease != nil {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (r *VClusterReconciler) redeployIfNeeded(ctx context.Context, vCluster *v1a
} else if len(v) == 3 {
kVersion.Major = v[0]
kVersion.Minor = v[1]
r.Log.Infof("vclusters %s/%s patch version defined in .spec.kubernetesVersion field will be ignored, latest supported patch version will be used", vCluster.Namespace, vCluster.Name)
r.Log.Info("vclusters %s/%s patch version defined in .spec.kubernetesVersion field will be ignored, latest supported patch version will be used", vCluster.Namespace, vCluster.Name)
} else {
return fmt.Errorf("invalid value of the .spec.kubernetesVersion field: %s", *vCluster.Spec.KubernetesVersion)
}
Expand All @@ -286,7 +286,7 @@ func (r *VClusterReconciler) redeployIfNeeded(ctx context.Context, vCluster *v1a
return fmt.Errorf("merge values: %v", err)
}

r.Log.Infof("Deploy virtual cluster %s/%s with values: %s", vCluster.Namespace, vCluster.Name, values)
r.Log.Info("Deploy virtual cluster %s/%s with values: %s", vCluster.Namespace, vCluster.Name, values)

chartPath := "./" + chartName + "-" + chartVersion + ".tgz"
_, err = os.Stat(chartPath)
Expand Down Expand Up @@ -421,7 +421,7 @@ func (r *VClusterReconciler) checkReadyz(vCluster *v1alpha1.VCluster, restConfig
Transport: transport,
}
resp, err := client.Get(fmt.Sprintf("https://%s:%d/readyz", vCluster.Spec.ControlPlaneEndpoint.Host, vCluster.Spec.ControlPlaneEndpoint.Port))
r.Log.Debugf("%s/%s: ready check took: %v", vCluster.Namespace, vCluster.Name, time.Since(t))
r.Log.Info("%s/%s: ready check took: %v", vCluster.Namespace, vCluster.Name, time.Since(t))
if err != nil {
return false, err
}
Expand Down Expand Up @@ -535,7 +535,7 @@ func (r *VClusterReconciler) deleteHelmChart(ctx context.Context, namespace, nam
return nil
}

r.Log.Debugf("delete vcluster %s/%s helm release", namespace, name)
r.Log.Info("delete vcluster %s/%s helm release", namespace, name)
return r.HelmClient.Delete(name, namespace)
}

Expand Down
21 changes: 8 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/loft-sh/cluster-api-provider-vcluster
go 1.18

require (
github.com/loft-sh/utils v0.0.18
github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac
github.com/loft-sh/utils v0.0.29
k8s.io/apimachinery v0.26.1
k8s.io/apiserver v0.26.1
k8s.io/client-go v0.26.1
Expand Down Expand Up @@ -32,8 +33,8 @@ require (
)

require (
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Sytten/logrus-zap-hook v0.1.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
Expand All @@ -44,22 +45,16 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
github.com/moby/term v0.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/stretchr/testify v1.8.1 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/kubectl v0.26.1 // indirect
)

Expand All @@ -70,7 +65,7 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -95,7 +90,7 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
Expand All @@ -108,7 +103,7 @@ require (
k8s.io/api v0.26.1
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1
k8s.io/klog/v2 v2.100.1
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
Expand Down
Loading