diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index cee796dd..6a5a4bbe 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: tibbar/k8sgpt-operator - newTag: tmp-010 + newName: ghcr.io/k8sgpt-ai/k8sgpt-operator + newTag: latest diff --git a/pkg/resources/k8sgpt.go b/pkg/resources/k8sgpt.go index 52f36d93..0aae1b36 100644 --- a/pkg/resources/k8sgpt.go +++ b/pkg/resources/k8sgpt.go @@ -67,6 +67,27 @@ func addSecretAsEnvToDeployment(secretName string, secretKey string, return nil } +// GetServiceAccount Create ServiceAccount for K8sGPT +func GetServiceAccount(config v1alpha1.K8sGPT) (*corev1.ServiceAccount, error) { + serviceAccount := &corev1.ServiceAccount{ + ObjectMeta: metav1.ObjectMeta{ + Name: "k8sgpt", // Name of the ServiceAccount + Namespace: config.Namespace, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: config.Kind, + Name: config.Name, + UID: config.UID, + APIVersion: config.APIVersion, + BlockOwnerDeletion: utils.PtrBool(true), + Controller: utils.PtrBool(true), + }, + }, + }, + } + return serviceAccount, nil +} + // GetService Create service for K8sGPT func GetService(config v1alpha1.K8sGPT) (*corev1.Service, error) { // Create service @@ -364,6 +385,13 @@ func Sync(ctx context.Context, c client.Client, outOfClusterMode := config.Spec.Kubeconfig != nil + sa, er := GetServiceAccount(config) + if er != nil { + return er + } + + objs = append(objs, sa) + svc, er := GetService(config) if er != nil { return er