Skip to content

Commit

Permalink
fix dev-run-gcp (#196)
Browse files Browse the repository at this point in the history
Previously this would fail due to trying to annotate the SCI K8s Service
Account which doesn't exist when you run outside of cluster.
  • Loading branch information
samos123 committed Aug 17, 2023
1 parent 549c7d2 commit 0341db9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmd/controllermanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ func main() {
// Create a client using the connection
sciClient := sci.NewControllerClient(conn)

kubernetesClient, err := kubernetes.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "error creating K8s client-go client")
}
err = controller.AssociatePrincipalSCIServiceAccount(context.Background(), kubernetesClient, cld)
if err != nil {
setupLog.Error(err, "error associating principal to SCI K8s ServiceAccount")
os.Exit(1)
// this environment is only set within a container running on K8s
if os.Getenv("KUBERNETES_SERVICE_HOST") != "" {
kubernetesClient, err := kubernetes.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "error creating K8s client-go client")
}
err = controller.AssociatePrincipalSCIServiceAccount(context.Background(), kubernetesClient, cld)
if err != nil {
setupLog.Error(err, "error associating principal to SCI K8s ServiceAccount")
os.Exit(1)
}
}

if err = (&controller.ModelReconciler{
Expand Down

0 comments on commit 0341db9

Please sign in to comment.