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

Commit

Permalink
Merge pull request #136 from christopherhein/feature/vc-capi-provisioner
Browse files Browse the repository at this point in the history
✨ Adding CAPI Provisioner to vc-manager
  • Loading branch information
k8s-ci-robot authored Jun 17, 2021
2 parents acdb025 + 3799f8b commit ce11f3e
Show file tree
Hide file tree
Showing 18 changed files with 732 additions and 232 deletions.
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
}
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

0 comments on commit ce11f3e

Please sign in to comment.