Skip to content

Commit

Permalink
Create bootstrap-success event before tear down
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Jan 26, 2019
1 parent 8aaa514 commit e509584
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"path/filepath"
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
Expand Down Expand Up @@ -72,6 +74,12 @@ func (b *startCommand) Run() error {
return err
}

// notify installer that we are ready to tear down the temporary bootstrap control plane
UserOutput("Sending bootstrap-success event.")
if _, err := client.CoreV1().Events("kube-system").Create(makeBootstrapSuccessEvent("kube-system", "bootstrap-success")); err != nil && !apierrors.IsAlreadyExists(err) {
return err
}

return nil
}

Expand All @@ -82,3 +90,21 @@ func (b *startCommand) Run() error {
func UserOutput(format string, a ...interface{}) {
fmt.Printf(format, a...)
}

func makeBootstrapSuccessEvent(ns, name string) *corev1.Event {
currentTime := metav1.Time{Time: time.Now()}
event := &corev1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
},
InvolvedObject: corev1.ObjectReference{
Namespace: ns,
},
Message: "Required control plane pods have been created",
Count: 1,
FirstTimestamp: currentTime,
LastTimestamp: currentTime,
}
return event
}

0 comments on commit e509584

Please sign in to comment.