···33# To re-generate a bundle for another specific version without changing the standard setup, you can:
44# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66-VERSION ?= 0.6.0
66+VERSION ?= 0.6.1
7788# CHANNELS define the bundle channels used in the bundle.
99# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
+2-2
helm/hsm-secrets-operator/Chart.yaml
···22name: hsm-secrets-operator
33description: A Kubernetes operator that bridges Pico HSM binary data storage with Kubernetes Secrets
44type: application
55-version: 0.6.0
66-appVersion: v0.6.0
55+version: 0.6.1
66+appVersion: v0.6.1
77icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/kubernetes/icon/color/kubernetes-icon-color.svg
88home: https://github.com/evanjarrett/hsm-secrets-operator
99sources:
+62
internal/config/service_account.go
···11+/*
22+Copyright 2025.
33+44+Licensed under the Apache License, Version 2.0 (the "License");
55+you may not use this file except in compliance with the License.
66+You may obtain a copy of the License at
77+88+ http://www.apache.org/licenses/LICENSE-2.0
99+1010+Unless required by applicable law or agreed to in writing, software
1111+distributed under the License is distributed on an "AS IS" BASIS,
1212+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313+See the License for the specific language governing permissions and
1414+limitations under the License.
1515+*/
1616+1717+package config
1818+1919+import (
2020+ "context"
2121+ "fmt"
2222+ "os"
2323+2424+ corev1 "k8s.io/api/core/v1"
2525+ "k8s.io/apimachinery/pkg/types"
2626+ "sigs.k8s.io/controller-runtime/pkg/client"
2727+)
2828+2929+// GetCurrentServiceAccount returns the service account name the current pod is running under.
3030+// It first gets the current namespace and pod name, then fetches the pod spec from the Kubernetes API
3131+// to get the ServiceAccountName. Returns an error if it cannot be determined.
3232+func GetCurrentServiceAccount(ctx context.Context, k8sClient client.Client) (string, error) {
3333+ // Get current namespace
3434+ namespace, err := GetCurrentNamespace()
3535+ if err != nil {
3636+ return "", fmt.Errorf("unable to get current namespace: %w", err)
3737+ }
3838+3939+ // Get pod name from hostname
4040+ podName, err := os.Hostname()
4141+ if err != nil {
4242+ return "", fmt.Errorf("unable to get pod name from hostname: %w", err)
4343+ }
4444+4545+ // Fetch the pod spec from Kubernetes API
4646+ pod := &corev1.Pod{}
4747+ podKey := types.NamespacedName{
4848+ Name: podName,
4949+ Namespace: namespace,
5050+ }
5151+5252+ if err := k8sClient.Get(ctx, podKey, pod); err != nil {
5353+ return "", fmt.Errorf("unable to get pod %s/%s: %w", namespace, podName, err)
5454+ }
5555+5656+ // Get the service account name from pod spec
5757+ if pod.Spec.ServiceAccountName == "" {
5858+ return "", fmt.Errorf("pod %s/%s has no service account specified in its spec", namespace, podName)
5959+ }
6060+6161+ return pod.Spec.ServiceAccountName, nil
6262+}
+22-8
internal/modes/manager/manager.go
···1717package manager
18181919import (
2020+ "context"
2021 "crypto/tls"
2122 "flag"
2223 "os"
2324 "path/filepath"
2525+ "time"
24262527 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2628 // to ensure that exec-entrypoint and run can make use of them.
···243245}
244246245247// setupBaseControllers sets up controllers that don't depend on the agent manager
246246-func setupBaseControllers(mgr ctrl.Manager, cfg *managerConfig) error {
248248+func setupBaseControllers(mgr ctrl.Manager, cfg *managerConfig, serviceAccountName string) error {
247249 // Create image resolver
248250 imageResolver := config.NewImageResolver(mgr.GetClient())
249251···258260259261 // Set up discovery DaemonSet controller (manager-owned)
260262 if err := (&controller.DiscoveryDaemonSetReconciler{
261261- Client: mgr.GetClient(),
262262- Scheme: mgr.GetScheme(),
263263- ImageResolver: imageResolver,
264264- DiscoveryImage: cfg.discoveryImage,
263263+ Client: mgr.GetClient(),
264264+ Scheme: mgr.GetScheme(),
265265+ ImageResolver: imageResolver,
266266+ DiscoveryImage: cfg.discoveryImage,
267267+ ServiceAccountName: serviceAccountName,
265268 }).SetupWithManager(mgr); err != nil {
266269 setupLog.Error(err, "unable to create controller", "controller", "DiscoveryDaemonSet")
267270 return err
···326329 return err
327330 }
328331332332+ // Get the service account name that this pod is running under
333333+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
334334+ defer cancel()
335335+336336+ serviceAccountName, err := config.GetCurrentServiceAccount(ctx, mgr.GetClient())
337337+ if err != nil {
338338+ setupLog.Error(err, "unable to get current service account - agent and discovery pods will fail without proper RBAC")
339339+ return err
340340+ }
341341+ setupLog.Info("Detected service account", "serviceAccount", serviceAccountName)
342342+329343 // Create agent manager runnable that will create the agent manager after TLS is ready
330330- agentManagerRunnable := NewAgentManagerRunnable(mgr.GetClient(), cfg.agentImage, operatorNamespace, setupLog)
344344+ agentManagerRunnable := NewAgentManagerRunnable(mgr.GetClient(), cfg.agentImage, operatorNamespace, serviceAccountName, setupLog)
331345332346 // Add agent manager as a runnable to start after TLS is ready
333347 setupLog.Info("Adding agent manager to manager")
···337351 }
338352339353 // Setup controllers that don't need the agent manager immediately
340340- if err := setupBaseControllers(mgr, cfg); err != nil {
354354+ if err := setupBaseControllers(mgr, cfg, serviceAccountName); err != nil {
341355 return err
342356 }
343357344358 // Create a runnable to setup agent-dependent controllers after agent manager is ready
345345- agentControllerSetup := NewAgentControllerSetupRunnable(agentManagerRunnable, mgr, operatorNamespace, operatorName, setupLog)
359359+ agentControllerSetup := NewAgentControllerSetupRunnable(agentManagerRunnable, mgr, operatorNamespace, operatorName, serviceAccountName, setupLog)
346360 setupLog.Info("Adding agent controller setup to manager")
347361 if err := mgr.Add(agentControllerSetup); err != nil {
348362 setupLog.Error(err, "unable to add agent controller setup to manager")