Skip to content
Open
3 changes: 3 additions & 0 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type ClusterSpec struct {
// this feature is highly experimental, and parts of it might still be not implemented.
// +optional
Topology *Topology `json:"topology,omitempty"`

// TakeOverCluster represents the cluster launch is for taking over existing pre-provisioned cluster
TakeOverCluster bool `json:"takeOverCluster,omitempty"`
}

// Topology encapsulates the information of the managed resources.
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:20220805
- image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:dev
name: manager
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,11 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, nil
}

// TODO: PCP-22 check (annotation to skip handleClusterNotInitialized and go for join )
// how to make this condition true for new cluster as kubeadm cluster is already initialized
// Note: can't use IsFalse here because we need to handle the absence of the condition as well as false.
if !conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedCondition) {
log.Info("TESTING... skip handleClusterNotInitialized and push cluster for join")
if !cluster.Spec.TakeOverCluster && !conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedCondition) {
return r.handleClusterNotInitialized(ctx, scope)
}

Expand All @@ -281,10 +284,12 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// it's a control plane join
if configOwner.IsControlPlaneMachine() {
log.Info("TESTING.... joinControlplane")
return r.joinControlplane(ctx, scope)
}

// It's a worker join
log.Info("TESTING.... It's a worker join")
return r.joinWorker(ctx, scope)
}

Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,11 @@ spec:
description: Paused can be used to prevent controllers from processing
the Cluster and all its associated objects.
type: boolean
takeOverCluster:
description: 'TODO: PCP-22, create/set cluster object for imported/takeover
cluster TakeOverCluster represents the cluster launch is for taking
over existing pre-provisioned cluster'
type: boolean
topology:
description: 'This encapsulates the topology for the cluster. NOTE:
It is required to enable the ClusterTopology feature gate flag to
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:20220805
- image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:dev
name: manager
30 changes: 15 additions & 15 deletions controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ func (in *KubeadmControlPlane) ValidateCreate() error {
const (
spec = "spec"
kubeadmConfigSpec = "kubeadmConfigSpec"
clusterConfiguration = "clusterConfiguration"
initConfiguration = "initConfiguration"
joinConfiguration = "joinConfiguration"
nodeRegistration = "nodeRegistration"
patches = "patches"
directory = "directory"
preKubeadmCommands = "preKubeadmCommands"
postKubeadmCommands = "postKubeadmCommands"
files = "files"
users = "users"
apiServer = "apiServer"
controllerManager = "controllerManager"
scheduler = "scheduler"
ntp = "ntp"
ignition = "ignition"
//clusterConfiguration = "clusterConfiguration"
//initConfiguration = "initConfiguration"
//joinConfiguration = "joinConfiguration"
//nodeRegistration = "nodeRegistration"
//patches = "patches"
//directory = "directory"
//preKubeadmCommands = "preKubeadmCommands"
//postKubeadmCommands = "postKubeadmCommands"
//files = "files"
//users = "users"
//apiServer = "apiServer"
//controllerManager = "controllerManager"
//scheduler = "scheduler"
//ntp = "ntp"
//ignition = "ignition"
)

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:20220805
- image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:dev
name: manager
2 changes: 1 addition & 1 deletion controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileEtcdMembers(ctx context.Context
log := ctrl.LoggerFrom(ctx, "cluster", controlPlane.Cluster.Name)

// If etcd is not managed by KCP this is a no-op.
if !controlPlane.IsEtcdManaged() {
if controlPlane.Cluster.Spec.TakeOverCluster || !controlPlane.IsEtcdManaged() {
return ctrl.Result{}, nil
}

Expand Down
5 changes: 4 additions & 1 deletion internal/controllers/cluster/cluster_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ func (r *Reconciler) reconcileControlPlane(ctx context.Context, cluster *cluster
if err != nil {
return ctrl.Result{}, err
}
if initialized {

// TODO: PCP-22 set controlPlaneInitializedCondition to true for takeOver cluster
// as CP are already initialized in existing cluster
if cluster.Spec.TakeOverCluster || initialized {
conditions.MarkTrue(cluster, clusterv1.ControlPlaneInitializedCondition)
} else {
conditions.MarkFalse(cluster, clusterv1.ControlPlaneInitializedCondition, clusterv1.WaitingForControlPlaneProviderInitializedReason, clusterv1.ConditionSeverityInfo, "Waiting for control plane provider to indicate the control plane has been initialized")
Expand Down
2 changes: 1 addition & 1 deletion spectro/generated/bootstrap-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- --bootstrap-token-ttl=${KUBEADM_BOOTSTRAP_TOKEN_TTL:=15m}
command:
- /manager
image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:dev
imagePullPolicy: Always
name: manager
terminationGracePeriodSeconds: 10
Expand Down
2 changes: 1 addition & 1 deletion spectro/generated/bootstrap-global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6241,7 +6241,7 @@ spec:
- --bootstrap-token-ttl=${KUBEADM_BOOTSTRAP_TOKEN_TTL:=15m}
command:
- /manager
image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/kubeadm-bootstrap-controller-amd64:dev
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion spectro/generated/controlplane-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- --feature-gates=ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}
command:
- /manager
image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:dev
imagePullPolicy: Always
name: manager
terminationGracePeriodSeconds: 10
Expand Down
2 changes: 1 addition & 1 deletion spectro/generated/controlplane-global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6209,7 +6209,7 @@ spec:
- --feature-gates=ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}
command:
- /manager
image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/kubeadm-control-plane-controller-amd64:dev
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion spectro/generated/core-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- --feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false}
command:
- /manager
image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:dev
imagePullPolicy: Always
name: manager
terminationGracePeriodSeconds: 10
Expand Down
7 changes: 6 additions & 1 deletion spectro/generated/core-global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,11 @@ spec:
description: Paused can be used to prevent controllers from processing
the Cluster and all its associated objects.
type: boolean
takeOverCluster:
description: 'TODO: PCP-22, create/set cluster object for imported/takeover
cluster TakeOverCluster represents the cluster launch is for taking
over existing pre-provisioned cluster'
type: boolean
topology:
description: 'This encapsulates the topology for the cluster. NOTE:
It is required to enable the ClusterTopology feature gate flag to
Expand Down Expand Up @@ -9646,7 +9651,7 @@ spec:
- --feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false}
command:
- /manager
image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:20220805
image: gcr.io/spectro-dev-public/release/cluster-api-controller-amd64:dev
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down
3 changes: 3 additions & 0 deletions util/secret/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/hex"
"fmt"
"math/big"
"path/filepath"
"strings"
Expand Down Expand Up @@ -238,6 +239,7 @@ func (c Certificates) EnsureAllExist() error {
func (c Certificates) Generate() error {
for _, certificate := range c {
if certificate.KeyPair == nil {
fmt.Println("TESTING.... Generate new certificates")
err := certificate.Generate()
if err != nil {
return err
Expand Down Expand Up @@ -268,6 +270,7 @@ func (c Certificates) LookupOrGenerate(ctx context.Context, ctrlclient client.Cl
return err
}

fmt.Println("TESTING.... Generate new certificates if that don't exist")
// Generate the certificates that don't exist
if err := c.Generate(); err != nil {
return err
Expand Down