@@ -127,6 +127,7 @@ func main() {
127127 }
128128
129129 if createGrpc {
130+ // TODO: should this be one go routine or several?
130131 g , ctx := errgroup .WithContext (ctx )
131132 g .Go (func () error {
132133 k8sClient := mgr .GetClient ()
@@ -135,6 +136,7 @@ func main() {
135136 err := k8sClient .Get (ctx , types.NamespacedName {Name : controllers .GrpcDeployment .Name , Namespace : controllers .GrpcDeployment .Namespace }, deployment )
136137 if err != nil {
137138 if apierrors .IsNotFound (err ) {
139+ setupLog .Info ("creating grpc deployment" )
138140 return k8sClient .Create (ctx , controllers .GrpcDeployment , & client.CreateOptions {})
139141 }
140142 }
@@ -148,18 +150,34 @@ func main() {
148150 err := k8sClient .Get (ctx , types.NamespacedName {Name : controllers .GrpcService .Name , Namespace : controllers .GrpcService .Namespace }, service )
149151 if err != nil {
150152 if apierrors .IsNotFound (err ) {
153+ setupLog .Info ("creating grpc service" )
151154 return k8sClient .Create (ctx , controllers .GrpcService , & client.CreateOptions {})
152155 }
153156 }
154157 // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found
155158 return nil
156159 })
157160
161+ g .Go (func () error {
162+ k8sClient := mgr .GetClient ()
163+ cm := & corev1.ConfigMap {}
164+ err := k8sClient .Get (ctx , types.NamespacedName {Name : controllers .GrpcConfigMap .Name , Namespace : controllers .GrpcConfigMap .Namespace }, cm )
165+ if err != nil {
166+ if apierrors .IsNotFound (err ) {
167+ setupLog .Info ("creating grpc configmap" )
168+ return k8sClient .Create (ctx , controllers .GrpcConfigMap , & client.CreateOptions {})
169+ }
170+ }
171+ // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found
172+ return nil
173+ })
174+
158175 go func () {
159176 if err := g .Wait (); err != nil {
160177 setupLog .Error (err , "error with async operation of creating grpc deployment" )
161178 os .Exit (1 )
162179 }
180+ setupLog .Info ("grpc server has been created" )
163181 }()
164182 }
165183
0 commit comments