Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove use of k8s serivce account #2544

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/pkg/cluster/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/fatih/color"
corev1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/defenseunicorns/pkg/helpers"
Expand Down Expand Up @@ -115,7 +116,28 @@ func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitO
// The default SA is required for pods to start properly.
saCtx, cancel := context.WithTimeout(ctx, 2*time.Minute)
defer cancel()
if _, err := c.WaitForServiceAccount(saCtx, ZarfNamespaceName, "default"); err != nil {
err = func(ctx context.Context, ns, name string) error {
timer := time.NewTimer(0)
defer timer.Stop()
for {
select {
case <-ctx.Done():
return fmt.Errorf("failed to get service account %s/%s: %w", ns, name, ctx.Err())
case <-timer.C:
_, err := c.Clientset.CoreV1().ServiceAccounts(ns).Get(ctx, name, metav1.GetOptions{})
if err != nil && !kerrors.IsNotFound(err) {
return err
}
if kerrors.IsNotFound(err) {
c.Log("Service account %s/%s not found, retrying...", ns, name)
timer.Reset(1 * time.Second)
continue
}
return nil
}
}
}(saCtx, ZarfNamespaceName, "default")
if err != nil {
return fmt.Errorf("unable get default Zarf service account: %w", err)
}

Expand Down
64 changes: 0 additions & 64 deletions src/pkg/k8s/sa.go

This file was deleted.

Loading