Skip to content

Commit

Permalink
feat: create convert-related crds when join cluster
Browse files Browse the repository at this point in the history
Signed-off-by: ONE7live <[email protected]>
  • Loading branch information
ONE7live authored and qiuwei68 committed May 10, 2024
1 parent 241b578 commit f8fe6fa
Show file tree
Hide file tree
Showing 3 changed files with 2,843 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/crds/kosmos.io_clusterpodconvertpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
shortNames:
- pc
singular: clusterpodconvertpolicy
scope: Namespaced
scope: Cluster
versions:
- name: v1alpha1
schema:
Expand Down
24 changes: 24 additions & 0 deletions pkg/kosmosctl/join/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,30 @@ func (o *CommandJoinOptions) runCluster() error {
return err
}

clusterPodConvert, err := util.GenerateCustomResourceDefinition(manifest.ClusterPodConvert, nil)
if err != nil {
return err
}
_, err = o.K8sExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), clusterPodConvert, metav1.CreateOptions{})
if err != nil {
if !apierrors.IsAlreadyExists(err) {
return fmt.Errorf("kosmosctl join run error, crd options failed: %v", err)
}
}
klog.Info("Create CRD " + clusterPodConvert.Name + " successful.")

podConvert, err := util.GenerateCustomResourceDefinition(manifest.PodConvert, nil)
if err != nil {
return err
}
_, err = o.K8sExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), podConvert, metav1.CreateOptions{})
if err != nil {
if !apierrors.IsAlreadyExists(err) {
return fmt.Errorf("kosmosctl join run error, crd options failed: %v", err)
}
}
klog.Info("Create CRD " + podConvert.Name + " successful.")

if len(o.LeafModel) > 0 {
switch o.LeafModel {
case "one-to-one":
Expand Down
Loading

0 comments on commit f8fe6fa

Please sign in to comment.