Skip to content

Commit

Permalink
feat: fixes breaking change with missing service account (#561)
Browse files Browse the repository at this point in the history
Signed-off-by: AlexsJones <[email protected]>
  • Loading branch information
AlexsJones authored Dec 3, 2024
1 parent c5b780b commit 63dfa38
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 63dfa38

Please sign in to comment.