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