Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

✨ Adding CAPI Provisioner to vc-manager #136

Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 1 deletion controllers/nestedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package controllers

import (
"context"
"time"

"github.com/go-logr/logr"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -97,7 +98,8 @@ func (r *NestedClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques
if err := r.Status().Update(ctx, nc); err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{}, nil
}

return ctrl.Result{}, nil
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this will just constant poll for changes until status provisioned, this should in the long run be triggered by the NCP status updating instead.

}
84 changes: 84 additions & 0 deletions templates/cluster-template-virtualcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
apiVersion: cluster.x-k8s.io/v1alpha4
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
spec:
controlPlaneEndpoint:
# currently this has to be the in-cluster endpoint, the in-cluster
# kubeconfig is used by controller-manager w/ ClusterIP services
# we can `port-forward` this service and be able to test, this includes
# NAMESPACE so we can connect to the VC syncer.
host: "${CLUSTER_NAME}-apiserver.${NAMESPACE}"
port: 6443
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: NestedCluster
name: "${CLUSTER_NAME}"
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedControlPlane
name: "${CLUSTER_NAME}-control-plane"

---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4
kind: NestedCluster
metadata:
name: "${CLUSTER_NAME}"
spec:
controlPlaneEndpoint:
host: "localhost"
port: 6443
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedControlPlane
metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
etcd:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedEtcd
name: "${CLUSTER_NAME}-nestedetcd"
apiserver:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedAPIServer
name: "${CLUSTER_NAME}-nestedapiserver"
controllerManager:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedControllerManager
name: "${CLUSTER_NAME}-nestedcontrollermanager"
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedEtcd
metadata:
name: "${CLUSTER_NAME}-nestedetcd"
spec:
replicas: 1
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedAPIServer
metadata:
name: "${CLUSTER_NAME}-nestedapiserver"
spec:
replicas: 1
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
kind: NestedControllerManager
metadata:
name: "${CLUSTER_NAME}-nestedcontrollermanager"
spec:
replicas: 1
---
apiVersion: tenancy.x-k8s.io/v1alpha1
kind: VirtualCluster
metadata:
name: ${CLUSTER_NAME}
annotations:
cluster.x-k8s.io/name: ${CLUSTER_NAME}
tenancy.x-k8s.io/secret.admin-kubeconfig: "${CLUSTER_NAME}-kubeconfig"
spec:
clusterVersionName: "capi"
opaqueMetaPrefixes:
- "tenancy.x-k8s.io"
transparentMetaPrefixes:
- "k8s.net.status"
6 changes: 6 additions & 0 deletions virtualcluster/cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/apis"
"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller"
"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/webhook"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
Expand Down Expand Up @@ -121,6 +122,11 @@ func main() {
os.Exit(1)
}

if err := clusterv1.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "unable add APIs to scheme")
os.Exit(1)
}

// Setup all Controllers
log.Info("Setting up controller")
if err := (&controller.Controllers{
Expand Down
163 changes: 0 additions & 163 deletions virtualcluster/config/crd/cluster.x-k8s.io_clusters.yaml

This file was deleted.

Loading