Skip to content

Commit 5c70fc1

Browse files
committed
Run kustomizer standalone
1 parent 0480098 commit 5c70fc1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/cmd/run.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ func RunMicroshift(cfg *config.Config) error {
209209
util.Must(m.AddService(controllers.NewInfrastructureServices(cfg)))
210210
util.Must(m.AddService(controllers.NewClusterPolicyController(cfg)))
211211
util.Must(m.AddService(controllers.NewVersionManager(cfg)))
212-
util.Must(m.AddService(kustomize.NewKustomizer(cfg)))
213212
util.Must(m.AddService(node.NewKubeletServer(cfg)))
214213
util.Must(m.AddService(loadbalancerservice.NewLoadbalancerServiceController(cfg)))
215214
util.Must(m.AddService(controllers.NewKubeStorageVersionMigrator(cfg)))
@@ -273,6 +272,9 @@ func RunMicroshift(cfg *config.Config) error {
273272
klog.Info("service does not support sd_notify readiness messages")
274273
}
275274

275+
// After MicroShift's core becomes ready, run the kustomizer (delete and/or apply manifests).
276+
kustomize.NewKustomizer(cfg).RunStandalone(runCtx)
277+
276278
// Watch for SIGTERM to exit, now that we are ready.
277279
<-sigTerm
278280
klog.Info("Interrupt received")

pkg/kustomize/kustomize.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package kustomize
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"os"
78
"time"
@@ -21,7 +22,7 @@ import (
2122

2223
const (
2324
retryInterval = 10 * time.Second
24-
retryTimeout = 1 * time.Minute
25+
retryTimeout = 10 * time.Minute
2526
)
2627

2728
type Kustomizer struct {
@@ -39,6 +40,15 @@ func NewKustomizer(cfg *config.Config) *Kustomizer {
3940
func (s *Kustomizer) Name() string { return "kustomizer" }
4041
func (s *Kustomizer) Dependencies() []string { return []string{"kube-apiserver"} }
4142

43+
func (s *Kustomizer) RunStandalone(ctx context.Context) {
44+
ready, stopped := make(chan struct{}), make(chan struct{})
45+
go func() {
46+
if err := s.Run(ctx, ready, stopped); err != nil && !errors.Is(err, context.Canceled) {
47+
klog.Errorf("Kustomizer failed: %v", err)
48+
}
49+
}()
50+
}
51+
4252
func (s *Kustomizer) Run(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error {
4353
defer close(stopped)
4454
defer close(ready)

0 commit comments

Comments
 (0)