Skip to content

Commit

Permalink
fix: ensure that Cluster CR reports control plane as ready
Browse files Browse the repository at this point in the history
This is done by adding the controlPlaneRef to the Cluster CR
and by adding .status.initialized field to vcluster CRD
  • Loading branch information
matskiv committed Jun 30, 2022
1 parent d925164 commit eb30feb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/vcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type VClusterStatus struct {
// +optional
Ready bool `json:"ready"`

// Initialized defines if the virtual cluster control plane was initialized.
// +optional
Initialized bool `json:"initialized"`

// Phase describes the current phase the virtual cluster is in
// +optional
Phase VirtualClusterPhase `json:"phase,omitempty"`
Expand Down
16 changes: 0 additions & 16 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ spec:
- type
type: object
type: array
initialized:
description: Initialized defines if the virtual cluster control plane
was initialized.
type: boolean
message:
description: Message describes the reason in human readable form why
the cluster is in the currrent phase
Expand Down
3 changes: 3 additions & 0 deletions controllers/vcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ func (r *VClusterReconciler) syncVClusterKubeconfig(ctx context.Context, vCluste

conditions.MarkTrue(vCluster, v1alpha1.ControlPlaneInitializedCondition)
}
// setting .Status.Initialized outside of the condition above to ensure
// that it is set on old CRs, which were missing this field, as well
vCluster.Status.Initialized = true

// write kubeconfig to the vcluster.Name+"-kubeconfig" Secret as expected by CAPI convention
kubeConfig, err := GetVClusterKubeConfig(ctx, r.Client, vCluster)
Expand Down
4 changes: 4 additions & 0 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: VCluster
name: ${CLUSTER_NAME}
controlPlaneRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: VCluster
name: ${CLUSTER_NAME}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: VCluster
Expand Down

0 comments on commit eb30feb

Please sign in to comment.