@@ -19,6 +19,7 @@ import (
19
19
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20
20
21
21
"github.com/openshift/installer/installer/pkg/config"
22
+ "github.com/openshift/installer/pkg/types"
22
23
)
23
24
24
25
const (
@@ -71,11 +72,16 @@ func (c *ConfigGenerator) KubeSystem() (string, error) {
71
72
if err != nil {
72
73
return "" , err
73
74
}
75
+ installConfig , err := c .installConfig ()
76
+ if err != nil {
77
+ return "" , err
78
+ }
74
79
75
80
return configMap ("kube-system" , genericData {
76
81
"kco-config" : coreConfig ,
77
82
"network-config" : c .networkConfig (),
78
83
"tnco-config" : tncoConfig ,
84
+ "install-config" : installConfig ,
79
85
})
80
86
}
81
87
@@ -95,6 +101,106 @@ func (c *ConfigGenerator) TectonicSystem() (string, error) {
95
101
})
96
102
}
97
103
104
+ // InstallConfig returns a YAML-rendered Kubernetes object with the user-supplied cluster configuration.
105
+ func (c * ConfigGenerator ) InstallConfig () (string , error ) {
106
+ ic , err := c .installConfig ()
107
+ if err != nil {
108
+ return "" , err
109
+ }
110
+ return marshalYAML (ic )
111
+ }
112
+
113
+ func (c * ConfigGenerator ) installConfig () (* types.InstallConfig , error ) {
114
+ _ , podCIDR , err := net .ParseCIDR (c .Networking .PodCIDR )
115
+ if err != nil {
116
+ return nil , err
117
+ }
118
+ _ , serviceCIDR , err := net .ParseCIDR (c .Networking .ServiceCIDR )
119
+ if err != nil {
120
+ return nil , err
121
+ }
122
+
123
+ var (
124
+ platform types.Platform
125
+ masterPlatformConfig types.MachinePoolPlatformConfig
126
+ workerPlatformConfig types.MachinePoolPlatformConfig
127
+ )
128
+ switch c .Platform {
129
+ case config .PlatformAWS :
130
+ platform .AWS = & types.AWSPlatform {
131
+ Region : c .Region ,
132
+ VPCID : c .VPCID ,
133
+ VPCCIDRBlock : c .VPCCIDRBlock ,
134
+ }
135
+ masterPlatformConfig .AWS = & types.AWSMachinePoolPlatformConfig {
136
+ InstanceType : c .AWS .Master .EC2Type ,
137
+ IAMRoleName : c .AWS .Master .IAMRoleName ,
138
+ EC2RootVolume : types.EC2RootVolume {
139
+ IOPS : c .AWS .Master .MasterRootVolume .IOPS ,
140
+ Size : c .AWS .Master .MasterRootVolume .Size ,
141
+ Type : c .AWS .Master .MasterRootVolume .Type ,
142
+ },
143
+ }
144
+ workerPlatformConfig .AWS = & types.AWSMachinePoolPlatformConfig {
145
+ InstanceType : c .AWS .Worker .EC2Type ,
146
+ IAMRoleName : c .AWS .Worker .IAMRoleName ,
147
+ EC2RootVolume : types.EC2RootVolume {
148
+ IOPS : c .AWS .Worker .WorkerRootVolume .IOPS ,
149
+ Size : c .AWS .Worker .WorkerRootVolume .Size ,
150
+ Type : c .AWS .Worker .WorkerRootVolume .Type ,
151
+ },
152
+ }
153
+ case config .PlatformLibvirt :
154
+ platform .Libvirt = & types.LibvirtPlatform {
155
+ URI : c .URI ,
156
+ Network : types.LibvirtNetwork {
157
+ Name : c .Network .Name ,
158
+ IfName : c .Network .IfName ,
159
+ IPRange : c .Network .IPRange ,
160
+ },
161
+ }
162
+ masterPlatformConfig .Libvirt = & types.LibvirtMachinePoolPlatformConfig {
163
+ QCOWImagePath : c .Libvirt .QCOWImagePath ,
164
+ }
165
+ workerPlatformConfig .Libvirt = & types.LibvirtMachinePoolPlatformConfig {
166
+ QCOWImagePath : c .Libvirt .QCOWImagePath ,
167
+ }
168
+ default :
169
+ return nil , fmt .Errorf ("installconfig: invalid platform %s" , c .Platform )
170
+ }
171
+ masterCount := int64 (c .NodeCount (c .Master .NodePools ))
172
+ workerCount := int64 (c .NodeCount (c .Worker .NodePools ))
173
+
174
+ return & types.InstallConfig {
175
+ ObjectMeta : metav1.ObjectMeta {
176
+ Name : c .Name ,
177
+ },
178
+ ClusterID : c .ClusterID ,
179
+ Admin : types.Admin {
180
+ Email : c .Admin .Email ,
181
+ Password : c .Admin .Password ,
182
+ SSHKey : c .Admin .SSHKey ,
183
+ },
184
+ BaseDomain : c .BaseDomain ,
185
+ PullSecret : c .PullSecret ,
186
+ Networking : types.Networking {
187
+ Type : types .NetworkType (string (c .Networking .Type )),
188
+ ServiceCIDR : * serviceCIDR ,
189
+ PodCIDR : * podCIDR ,
190
+ },
191
+ Platform : platform ,
192
+ Machines : []types.MachinePool {{
193
+ Name : "master" ,
194
+ Replicas : & masterCount ,
195
+ PlatformConfig : masterPlatformConfig ,
196
+ }, {
197
+ Name : "worker" ,
198
+ Replicas : & workerCount ,
199
+ PlatformConfig : workerPlatformConfig ,
200
+ }},
201
+ }, nil
202
+ }
203
+
98
204
// CoreConfig returns, if successful, a yaml string for the on-disk kco-config.
99
205
func (c * ConfigGenerator ) CoreConfig () (string , error ) {
100
206
coreConfig , err := c .coreConfig ()
0 commit comments