-
Notifications
You must be signed in to change notification settings - Fork 87
/
rewrite.go
557 lines (482 loc) · 20.4 KB
/
rewrite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
package rewrite
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/pkg/errors"
kotsv1beta1 "github.com/replicatedhq/kots/kotskinds/apis/kots/v1beta1"
reportingtypes "github.com/replicatedhq/kots/pkg/api/reporting/types"
"github.com/replicatedhq/kots/pkg/base"
"github.com/replicatedhq/kots/pkg/crypto"
"github.com/replicatedhq/kots/pkg/docker/registry"
"github.com/replicatedhq/kots/pkg/downstream"
"github.com/replicatedhq/kots/pkg/k8sdoc"
"github.com/replicatedhq/kots/pkg/k8sutil"
"github.com/replicatedhq/kots/pkg/kotsutil"
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/midstream"
"github.com/replicatedhq/kots/pkg/store"
"github.com/replicatedhq/kots/pkg/upstream"
upstreamtypes "github.com/replicatedhq/kots/pkg/upstream/types"
kustomizetypes "sigs.k8s.io/kustomize/api/types"
)
type RewriteOptions struct {
RootDir string
UpstreamURI string
UpstreamPath string
Downstreams []string
K8sNamespace string
Silent bool
CreateAppDir bool
ExcludeKotsKinds bool
Installation *kotsv1beta1.Installation
License *kotsv1beta1.License
ConfigValues *kotsv1beta1.ConfigValues
ReportWriter io.Writer
CopyImages bool // can be false even if registry is not read-only
IsAirgap bool
RegistryEndpoint string
RegistryUsername string
RegistryPassword string
RegistryNamespace string
RegistryIsReadOnly bool
AppID string
AppSlug string
IsGitOps bool
AppSequence int64
ReportingInfo *reportingtypes.ReportingInfo
HTTPProxyEnvValue string
HTTPSProxyEnvValue string
NoProxyEnvValue string
}
func Rewrite(rewriteOptions RewriteOptions) error {
log := logger.NewCLILogger()
if rewriteOptions.Silent {
log.Silence()
}
log.Initialize()
if rewriteOptions.ReportWriter == nil {
rewriteOptions.ReportWriter = ioutil.Discard
}
fetchOptions := &upstreamtypes.FetchOptions{
RootDir: rewriteOptions.RootDir,
LocalPath: rewriteOptions.UpstreamPath,
CurrentCursor: rewriteOptions.Installation.Spec.UpdateCursor,
CurrentVersionLabel: rewriteOptions.Installation.Spec.VersionLabel,
EncryptionKey: rewriteOptions.Installation.Spec.EncryptionKey,
License: rewriteOptions.License,
AppSequence: rewriteOptions.AppSequence,
AppSlug: rewriteOptions.AppSlug,
LocalRegistry: upstreamtypes.LocalRegistry{
Host: rewriteOptions.RegistryEndpoint,
Namespace: rewriteOptions.RegistryNamespace,
Username: rewriteOptions.RegistryUsername,
Password: rewriteOptions.RegistryPassword,
ReadOnly: rewriteOptions.RegistryIsReadOnly,
},
ReportingInfo: rewriteOptions.ReportingInfo,
}
log.ActionWithSpinner("Pulling upstream")
io.WriteString(rewriteOptions.ReportWriter, "Pulling upstream\n")
u, err := upstream.FetchUpstream(rewriteOptions.UpstreamURI, fetchOptions)
if err != nil {
log.FinishSpinnerWithError()
return errors.Wrap(err, "failed to load upstream")
}
clientset, err := k8sutil.GetClientset()
if err != nil {
return errors.Wrap(err, "failed to get k8s clientset")
}
writeUpstreamOptions := upstreamtypes.WriteOptions{
RootDir: rewriteOptions.RootDir,
CreateAppDir: rewriteOptions.CreateAppDir,
IncludeAdminConsole: false,
PreserveInstallation: true,
IsOpenShift: k8sutil.IsOpenShift(clientset),
}
if err := upstream.WriteUpstream(u, writeUpstreamOptions); err != nil {
log.FinishSpinnerWithError()
return errors.Wrap(err, "failed to write upstream")
}
log.FinishSpinner()
renderOptions := base.RenderOptions{
SplitMultiDocYAML: true,
Namespace: rewriteOptions.K8sNamespace,
LocalRegistryHost: rewriteOptions.RegistryEndpoint,
LocalRegistryNamespace: rewriteOptions.RegistryNamespace,
LocalRegistryUsername: rewriteOptions.RegistryUsername,
LocalRegistryPassword: rewriteOptions.RegistryPassword,
LocalRegistryIsReadOnly: rewriteOptions.RegistryIsReadOnly,
ExcludeKotsKinds: rewriteOptions.ExcludeKotsKinds,
Log: log,
AppSlug: rewriteOptions.AppSlug,
Sequence: rewriteOptions.AppSequence,
IsAirgap: rewriteOptions.IsAirgap,
}
log.ActionWithSpinner("Creating base")
io.WriteString(rewriteOptions.ReportWriter, "Creating base\n")
commonBase, helmBases, err := base.RenderUpstream(u, &renderOptions)
if err != nil {
return errors.Wrap(err, "failed to render upstream")
}
errorFiles := []base.BaseFile{}
errorFiles = append(errorFiles, base.PrependBaseFilesPath(commonBase.ListErrorFiles(), commonBase.Path)...)
for _, helmBase := range helmBases {
errorFiles = append(errorFiles, base.PrependBaseFilesPath(helmBase.ListErrorFiles(), helmBase.Path)...)
}
if ff := errorFiles; len(ff) > 0 {
files := make([]kotsv1beta1.InstallationYAMLError, 0, len(ff))
for _, f := range ff {
file := kotsv1beta1.InstallationYAMLError{
Path: f.Path,
}
if f.Error != nil {
file.Error = f.Error.Error()
}
files = append(files, file)
}
newKotsKinds, err := kotsutil.LoadKotsKindsFromPath(u.GetUpstreamDir(writeUpstreamOptions))
if err != nil {
return errors.Wrap(err, "failed to load installation")
}
newKotsKinds.Installation.Spec.YAMLErrors = files
err = upstream.SaveInstallation(&newKotsKinds.Installation, u.GetUpstreamDir(writeUpstreamOptions))
if err != nil {
return errors.Wrap(err, "failed to save installation")
}
}
writeBaseOptions := base.WriteOptions{
BaseDir: u.GetBaseDir(writeUpstreamOptions),
SkippedDir: u.GetSkippedDir(writeUpstreamOptions),
Overwrite: true,
ExcludeKotsKinds: rewriteOptions.ExcludeKotsKinds,
IsHelmBase: false,
}
if err := commonBase.WriteBase(writeBaseOptions); err != nil {
return errors.Wrap(err, "failed to write common base")
}
for _, helmBase := range helmBases {
helmBaseCopy := helmBase.DeepCopy()
// strip namespace. helm render takes care of injecting the namespace
helmBaseCopy.SetNamespace("")
writeBaseOptions := base.WriteOptions{
BaseDir: u.GetBaseDir(writeUpstreamOptions),
SkippedDir: u.GetSkippedDir(writeUpstreamOptions),
Overwrite: true,
ExcludeKotsKinds: rewriteOptions.ExcludeKotsKinds,
IsHelmBase: true,
}
if err := helmBaseCopy.WriteBase(writeBaseOptions); err != nil {
return errors.Wrapf(err, "failed to write helm base %s", helmBaseCopy.Path)
}
}
log.FinishSpinner()
log.ActionWithSpinner("Creating midstreams")
io.WriteString(rewriteOptions.ReportWriter, "Creating midstreams\n")
builder, _, err := base.NewConfigContextTemplateBuilder(u, &renderOptions)
if err != nil {
return errors.Wrap(err, "failed to create new config context template builder")
}
err = crypto.InitFromString(rewriteOptions.Installation.Spec.EncryptionKey)
if err != nil {
return errors.Wrap(err, "failed to create cipher from installation spec")
}
var newHelmCharts []*kotsv1beta1.HelmChart
newHelmCharts, err = kotsutil.LoadHelmChartsFromPath(rewriteOptions.UpstreamPath)
if err != nil {
return errors.Wrap(err, "failed to load new helm charts")
}
commonWriteMidstreamOptions := midstream.WriteOptions{
AppSlug: rewriteOptions.AppSlug,
IsGitOps: rewriteOptions.IsGitOps,
IsOpenShift: k8sutil.IsOpenShift(clientset),
Builder: *builder,
HTTPProxyEnvValue: rewriteOptions.HTTPProxyEnvValue,
HTTPSProxyEnvValue: rewriteOptions.HTTPSProxyEnvValue,
NoProxyEnvValue: rewriteOptions.NoProxyEnvValue,
NewHelmCharts: newHelmCharts,
}
// the UseHelmInstall map blocks visibility into charts and subcharts when searching for private images
// any chart name listed here will be skipped when writing midstream kustomization.yaml and pullsecret.yaml
// when using Helm Install, each chart gets it's own kustomization and pullsecret yaml and MUST be skipped when processing higher level directories!
// for writing Common Midstream, every chart and subchart is in this map as Helm Midstreams will be processed later in the code
commonWriteMidstreamOptions.UseHelmInstall = map[string]bool{}
for _, v := range newHelmCharts {
chartBaseName := v.Spec.Chart.Name
// the helmBase may have a chart name prefix removed - we must find the base name instead of the original chart name
for _, helmBase := range helmBases {
chartName := strings.Split(helmBase.Path, "/")[len(strings.Split(helmBase.Path, "/"))-1]
if strings.HasSuffix(chartBaseName, chartName) {
chartBaseName = chartName
}
}
commonWriteMidstreamOptions.UseHelmInstall[chartBaseName] = v.Spec.UseHelmInstall
if v.Spec.UseHelmInstall {
subcharts, err := base.FindHelmSubChartsFromBase(writeBaseOptions.BaseDir, chartBaseName)
if err != nil {
return errors.Wrapf(err, "failed to find subcharts for parent chart %s", chartBaseName)
}
for _, subchart := range subcharts.SubCharts {
commonWriteMidstreamOptions.UseHelmInstall[subchart] = v.Spec.UseHelmInstall
}
}
}
writeMidstreamOptions := commonWriteMidstreamOptions
writeMidstreamOptions.MidstreamDir = filepath.Join(commonBase.GetOverlaysDir(writeBaseOptions), "midstream")
writeMidstreamOptions.BaseDir = filepath.Join(u.GetBaseDir(writeUpstreamOptions), commonBase.Path)
m, err := writeMidstream(writeMidstreamOptions, rewriteOptions, commonBase, fetchOptions.License, u.GetUpstreamDir(writeUpstreamOptions), log)
if err != nil {
return errors.Wrap(err, "failed to write common midstream")
}
helmMidstreams := []midstream.Midstream{}
for _, helmBase := range helmBases {
// we must look at the current chart for private images, but must ignore subcharts
// to do this, we remove only the current helmBase name from the UseHelmInstall map to unblock visibility into the chart directory
// this ensures only the current chart resources are added to kustomization.yaml and pullsecret.yaml
chartName := strings.Split(helmBase.Path, "/")[len(strings.Split(helmBase.Path, "/"))-1]
// copy the bool setting in the map to restore it after this process loop
useHelmSetting := writeMidstreamOptions.UseHelmInstall[chartName]
delete(writeMidstreamOptions.UseHelmInstall, chartName)
writeMidstreamOptions.MidstreamDir = filepath.Join(helmBase.GetOverlaysDir(writeBaseOptions), "midstream", helmBase.Path)
writeMidstreamOptions.BaseDir = filepath.Join(u.GetBaseDir(writeUpstreamOptions), helmBase.Path)
helmBaseCopy := helmBase.DeepCopy()
rewriteOptionsCopy := rewriteOptions
rewriteOptionsCopy.K8sNamespace = helmBaseCopy.Namespace
helmMidstream, err := writeMidstream(writeMidstreamOptions, rewriteOptionsCopy, helmBaseCopy, fetchOptions.License, u.GetUpstreamDir(writeUpstreamOptions), log)
if err != nil {
return errors.Wrapf(err, "failed to write helm midstream %s", helmBase.Path)
}
// add this chart back into UseHelmInstall to make sure it's not processed again
writeMidstreamOptions.UseHelmInstall[chartName] = useHelmSetting
helmMidstreams = append(helmMidstreams, *helmMidstream)
}
if err := writeDownstreams(rewriteOptions, commonBase.GetOverlaysDir(writeBaseOptions), m, helmMidstreams, log); err != nil {
return errors.Wrap(err, "failed to write downstreams")
}
kotsKinds, err := kotsutil.LoadKotsKindsFromPath(rewriteOptions.RootDir)
if err != nil {
return errors.Wrap(err, "failed to load kotskinds")
}
err = store.GetStore().UpdateAppVersionInstallationSpec(rewriteOptions.AppID, rewriteOptions.AppSequence, kotsKinds.Installation)
if err != nil {
return errors.Wrap(err, "failed to updates installation spec")
}
log.FinishSpinner()
return nil
}
func writeMidstream(writeMidstreamOptions midstream.WriteOptions, options RewriteOptions, b *base.Base, license *kotsv1beta1.License, upstreamDir string, log *logger.CLILogger) (*midstream.Midstream, error) {
var pullSecrets *registry.ImagePullSecrets
var images []kustomizetypes.Image
var objects []k8sdoc.K8sDoc
clientset, err := k8sutil.GetClientset()
if err != nil {
return nil, errors.Wrap(err, "failed to get k8s clientset")
}
replicatedRegistryInfo := registry.ProxyEndpointFromLicense(options.License)
identitySpec, err := upstream.LoadIdentity(upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load identity")
}
identityConfig, err := upstream.LoadIdentityConfig(upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load identity config")
}
// do not fail on being unable to get dockerhub credentials, since they're just used to increase the rate limit
dockerHubRegistryCreds, _ := registry.GetDockerHubCredentials(clientset, options.K8sNamespace)
// TODO (ethan): rewrite dex image?
if options.CopyImages || options.RegistryEndpoint != "" {
// When CopyImages is set, we copy images, rewrite all images, and use registry
// settings to create secrets for all objects that have images.
// When only registry endpoint is set, we don't need to copy images, but still
// need to rewrite them and create secrets.
newKotsKinds, err := kotsutil.LoadKotsKindsFromPath(upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load kotskinds from new upstream")
}
writeUpstreamImageOptions := base.WriteUpstreamImageOptions{
BaseDir: writeMidstreamOptions.BaseDir,
ReportWriter: options.ReportWriter,
Log: log,
SourceRegistry: registry.RegistryOptions{
Endpoint: replicatedRegistryInfo.Registry,
ProxyEndpoint: replicatedRegistryInfo.Proxy,
},
DestRegistry: registry.RegistryOptions{
Endpoint: options.RegistryEndpoint,
Namespace: options.RegistryNamespace,
Username: options.RegistryUsername,
Password: options.RegistryPassword,
},
DockerHubRegistry: registry.RegistryOptions{
Username: dockerHubRegistryCreds.Username,
Password: dockerHubRegistryCreds.Password,
},
KotsKinds: newKotsKinds,
IsAirgap: options.IsAirgap,
CopyImages: options.CopyImages,
}
if license != nil {
writeUpstreamImageOptions.AppSlug = license.Spec.AppSlug
writeUpstreamImageOptions.SourceRegistry.Username = license.Spec.LicenseID
writeUpstreamImageOptions.SourceRegistry.Password = license.Spec.LicenseID
}
copyResult, err := base.ProcessUpstreamImages(writeUpstreamImageOptions)
if err != nil {
return nil, errors.Wrap(err, "failed to write upstream images")
}
newKotsKinds.Installation.Spec.KnownImages = copyResult.CheckedImages
err = upstream.SaveInstallation(&newKotsKinds.Installation, upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to save installation")
}
affectedObjects := base.FindObjectsWithImages(b)
registryUser := options.RegistryUsername
registryPass := options.RegistryPassword
if registryUser == "" {
// this will only work when envoked from CLI where `docker login` command has been executed
registryUser, registryPass, err = registry.LoadAuthForRegistry(options.RegistryEndpoint)
if err != nil {
return nil, errors.Wrapf(err, "failed to load registry auth for %q", options.RegistryEndpoint)
}
}
namePrefix := options.AppSlug
// For the newer style charts, create a new secret per chart as helm adds chart specific
// details to annotations and labels to it.
for _, v := range writeMidstreamOptions.NewHelmCharts {
if filepath.Base(b.Path) == v.Spec.Chart.Name && v.Spec.UseHelmInstall == true {
namePrefix = fmt.Sprintf("%s-%s", options.AppSlug, filepath.Base(b.Path))
break
}
}
pullSecrets, err = registry.PullSecretForRegistries(
[]string{options.RegistryEndpoint},
registryUser,
registryPass,
options.K8sNamespace,
namePrefix,
)
if err != nil {
return nil, errors.Wrap(err, "failed to create private registry pull secrets")
}
images = copyResult.Images
objects = affectedObjects
} else {
kotsKinds, err := kotsutil.LoadKotsKindsFromPath(upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load kotskonds")
}
allPrivate := kotsKinds.KotsApplication.Spec.ProxyPublicImages
// When CopyImages is not set, we only rewrite private images and use license to create secrets
// for all objects that have private images
findPrivateImagesOptions := base.FindPrivateImagesOptions{
BaseDir: writeMidstreamOptions.BaseDir,
AppSlug: license.Spec.AppSlug,
ReplicatedRegistry: registry.RegistryOptions{
Endpoint: replicatedRegistryInfo.Registry,
ProxyEndpoint: replicatedRegistryInfo.Proxy,
},
DockerHubRegistry: registry.RegistryOptions{
Username: dockerHubRegistryCreds.Username,
Password: dockerHubRegistryCreds.Password,
},
Installation: options.Installation,
AllImagesPrivate: allPrivate,
UseHelmInstall: writeMidstreamOptions.UseHelmInstall,
}
findResult, err := base.FindPrivateImages(findPrivateImagesOptions)
if err != nil {
return nil, errors.Wrap(err, "failed to find private images")
}
kotsKinds.Installation.Spec.KnownImages = findResult.CheckedImages
err = upstream.SaveInstallation(&kotsKinds.Installation, upstreamDir)
if err != nil {
return nil, errors.Wrap(err, "failed to save installation")
}
if len(findResult.Docs) > 0 {
namePrefix := options.AppSlug
// For the newer style charts, create a new secret per chart as helm adds chart specific
// details to annotations and labels to it.
for _, v := range writeMidstreamOptions.NewHelmCharts {
if filepath.Base(b.Path) == v.Spec.Chart.Name && v.Spec.UseHelmInstall == true {
namePrefix = fmt.Sprintf("%s-%s", options.AppSlug, filepath.Base(b.Path))
break
}
}
replicatedRegistryInfo := registry.ProxyEndpointFromLicense(options.License)
pullSecrets, err = registry.PullSecretForRegistries(
replicatedRegistryInfo.ToSlice(),
options.License.Spec.LicenseID,
options.License.Spec.LicenseID,
options.K8sNamespace,
namePrefix,
)
if err != nil {
return nil, errors.Wrap(err, "failed to create Replicated registry pull secret")
}
}
images = findResult.Images
objects = findResult.Docs
}
m, err := midstream.CreateMidstream(b, images, objects, pullSecrets, identitySpec, identityConfig)
if err != nil {
return nil, errors.Wrap(err, "failed to create midstream")
}
if err := m.WriteMidstream(writeMidstreamOptions); err != nil {
return nil, errors.Wrap(err, "failed to write common midstream")
}
return m, nil
}
func writeDownstreams(options RewriteOptions, overlaysDir string, m *midstream.Midstream, helmMidstreams []midstream.Midstream, log *logger.CLILogger) error {
for _, downstreamName := range options.Downstreams {
log.ActionWithSpinner("Creating downstream %q", downstreamName)
io.WriteString(options.ReportWriter, fmt.Sprintf("Creating downstream %q\n", downstreamName))
d, err := downstream.CreateDownstream(m)
if err != nil {
return errors.Wrapf(err, "failed to create downstream %s", downstreamName)
}
writeDownstreamOptions := downstream.WriteOptions{
DownstreamDir: filepath.Join(overlaysDir, "downstreams", downstreamName),
MidstreamDir: filepath.Join(overlaysDir, "midstream"),
}
if err := d.WriteDownstream(writeDownstreamOptions); err != nil {
return errors.Wrapf(err, "failed to write downstream %s", downstreamName)
}
for _, mid := range helmMidstreams {
helmMidstream := mid
d, err := downstream.CreateDownstream(&helmMidstream)
if err != nil {
return errors.Wrapf(err, "failed to create downstream %s for midstream %s", downstreamName, mid.Base.Path)
}
writeDownstreamOptions := downstream.WriteOptions{
DownstreamDir: filepath.Join(overlaysDir, "downstreams", downstreamName, mid.Base.Path),
MidstreamDir: filepath.Join(overlaysDir, "midstream", mid.Base.Path),
}
if err := d.WriteDownstream(writeDownstreamOptions); err != nil {
return errors.Wrapf(err, "failed to write downstream %s for midstream %s", downstreamName, mid.Base.Path)
}
}
log.FinishSpinner()
}
return nil
}
func writeCombinedDownstreamBase(downstreamName string, bases []string, renderDir string) error {
if _, err := os.Stat(renderDir); os.IsNotExist(err) {
if err := os.MkdirAll(renderDir, 0744); err != nil {
return errors.Wrap(err, "failed to mkdir")
}
}
kustomization := kustomizetypes.Kustomization{
TypeMeta: kustomizetypes.TypeMeta{
APIVersion: "kustomize.config.k8s.io/v1beta1",
Kind: "Kustomization",
},
Bases: bases,
}
if err := k8sutil.WriteKustomizationToFile(kustomization, filepath.Join(renderDir, "kustomization.yaml")); err != nil {
return errors.Wrap(err, "failed to write kustomization to file")
}
return nil
}