Skip to content

Commit 32f8ec8

Browse files
✨ Add changes to clusteradm accept to disable csr update based on annotation on ManagedCluster (#468)
* Add changes to clusteradm accept to disable csr update based on annotation on ManagedCluster Signed-off-by: “Jeffrey <[email protected]> Signed-off-by: Gaurav Jaswal <[email protected]> * Adding comment to describe support for awsira auth Signed-off-by: Gaurav Jaswal <[email protected]> --------- Signed-off-by: “Jeffrey <[email protected]> Signed-off-by: Gaurav Jaswal <[email protected]> Co-authored-by: jaswalkiranavtar <[email protected]>
1 parent a756dd6 commit 32f8ec8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Diff for: pkg/cmd/accept/exec.go

+19-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,27 @@ func (o *Options) runWithClient(kubeClient *kubernetes.Clientset, clusterClient
9494
}
9595

9696
func (o *Options) accept(kubeClient *kubernetes.Clientset, clusterClient *clusterclientset.Clientset, clusterName string, waitMode bool) (bool, error) {
97-
approved, err := o.approveCSR(kubeClient, clusterName, waitMode)
97+
managedCluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.TODO(),
98+
clusterName,
99+
metav1.GetOptions{})
98100
if err != nil {
99-
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
101+
return false, fmt.Errorf("fail to get managedcluster %s: %v", clusterName, err)
102+
}
103+
// when a managed cluster registers with hub using awsirsa registration-auth, it will add this annotation
104+
// to ManagedCluster resource, presense of which is used to decide the requested authentication type.
105+
// awrirsa authentication doesn't create CSR on hub, hence there is nothing to approve
106+
_, hasEksArn := managedCluster.Annotations["agent.open-cluster-management.io/managed-cluster-arn"]
107+
108+
var approved bool
109+
if !hasEksArn {
110+
approved, err = o.approveCSR(kubeClient, clusterName, waitMode)
111+
if err != nil {
112+
return approved, fmt.Errorf("fail to approve the csr for cluster %s: %v", clusterName, err)
113+
}
114+
} else {
115+
approved = true
100116
}
117+
101118
err = o.updateManagedCluster(clusterClient, clusterName)
102119
if err != nil {
103120
return approved, err

0 commit comments

Comments
 (0)