|
7 | 7 | "strings" |
8 | 8 |
|
9 | 9 | "github.com/pkg/errors" |
| 10 | + "github.com/sirupsen/logrus" |
10 | 11 | corev1 "k8s.io/api/core/v1" |
11 | 12 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
12 | 13 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" |
@@ -87,20 +88,6 @@ func (c *Cluster) Generate(_ context.Context, dependencies asset.Parents) error |
87 | 88 | namespace.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Namespace")) |
88 | 89 | c.FileList = append(c.FileList, &asset.RuntimeFile{Object: namespace, File: asset.File{Filename: "000_capi-namespace.yaml"}}) |
89 | 90 |
|
90 | | - cluster := &clusterv1.Cluster{ |
91 | | - ObjectMeta: metav1.ObjectMeta{ |
92 | | - Name: clusterID.InfraID, |
93 | | - Namespace: capiutils.Namespace, |
94 | | - }, |
95 | | - Spec: clusterv1.ClusterSpec{ |
96 | | - ClusterNetwork: &clusterv1.ClusterNetwork{ |
97 | | - APIServerPort: ptr.To[int32](6443), |
98 | | - }, |
99 | | - }, |
100 | | - } |
101 | | - cluster.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("Cluster")) |
102 | | - c.FileList = append(c.FileList, &asset.RuntimeFile{Object: cluster, File: asset.File{Filename: "01_capi-cluster.yaml"}}) |
103 | | - |
104 | 91 | var out *capiutils.GenerateClusterAssetsOutput |
105 | 92 | switch platform := installConfig.Config.Platform.Name(); platform { |
106 | 93 | case awstypes.Name: |
@@ -150,12 +137,28 @@ func (c *Cluster) Generate(_ context.Context, dependencies asset.Parents) error |
150 | 137 | return fmt.Errorf("unsupported platform %q", platform) |
151 | 138 | } |
152 | 139 |
|
153 | | - // Set the infrastructure reference in the Cluster object. |
154 | | - cluster.Spec.InfrastructureRef = out.InfrastructureRef |
155 | | - if cluster.Spec.InfrastructureRef == nil { |
| 140 | + if len(out.InfrastructureRefs) == 0 { |
156 | 141 | return fmt.Errorf("failed to generate manifests: cluster.Spec.InfrastructureRef was never set") |
157 | 142 | } |
158 | 143 |
|
| 144 | + logrus.Infof("Adding clusters...") |
| 145 | + for index, infra := range out.InfrastructureRefs { |
| 146 | + cluster := &clusterv1.Cluster{ |
| 147 | + ObjectMeta: metav1.ObjectMeta{ |
| 148 | + Name: infra.Name, |
| 149 | + Namespace: capiutils.Namespace, |
| 150 | + }, |
| 151 | + Spec: clusterv1.ClusterSpec{ |
| 152 | + ClusterNetwork: &clusterv1.ClusterNetwork{ |
| 153 | + APIServerPort: ptr.To[int32](6443), |
| 154 | + }, |
| 155 | + }, |
| 156 | + } |
| 157 | + cluster.Spec.InfrastructureRef = infra |
| 158 | + cluster.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("Cluster")) |
| 159 | + c.FileList = append(c.FileList, &asset.RuntimeFile{Object: cluster, File: asset.File{Filename: fmt.Sprintf("01_capi-cluster-%d.yaml", index)}}) |
| 160 | + } |
| 161 | + |
159 | 162 | // Append the infrastructure manifests. |
160 | 163 | c.FileList = append(c.FileList, out.Manifests...) |
161 | 164 |
|
|
0 commit comments