From e50958481ec82e80a8aa4c0996846c7b790a74f8 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Thu, 24 Jan 2019 15:24:50 +0100 Subject: [PATCH] Create bootstrap-success event before tear down --- pkg/start/start.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/start/start.go b/pkg/start/start.go index 9f1029f9a..12f2231d9 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -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" ) @@ -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 } @@ -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 +}