k8sgpt-ai / k8sgpt-operator

Automatic SRE Superpowers within your Kubernetes cluster
https://k8sgpt.ai
Apache License 2.0
320 stars 92 forks source link

an empty namespace may not be set during creation for k8sgpt operator controller manager #447

Closed g3david405 closed 6 months ago

g3david405 commented 6 months ago

Checklist

Affected Components

K8sGPT Version

v0.1.4

Kubernetes Version

v1.26.3

Host OS and its Version

Rocky 9

Steps to reproduce

I am facing same error with https://github.com/k8sgpt-ai/k8sgpt/issues/1107 This is what I create for k8sgpt CRD resource

apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
  name: k8sgpt-local-ai
  namespace: k8sgpt-operator-system
spec:
  ai:
    anonymized: true
    backend: localai
    baseUrl: {my local-ai url}
    enabled: true
    language: english
    model: gpt-4
  version: v0.3.8

However, If I don't specify targetNamespace, k8sGPT operator controller manager won't create result and will log an error:

Finished Reconciling k8sGPT with error: an empty namespace may not be set during creation                                                                                                                                                                                                                                  
2024-05-10T00:59:16Z    ERROR   Reconciler error        {"controller": "k8sgpt", "controllerGroup": "core.k8sgpt.ai", "controllerKind": "K8sGPT", "K8sGPT": {"name":"k8sgpt-local","namespace":"k8sgpt-operator-system"}, "namespace": "k8sgpt-operator-system", "name": "k8sgpt-local", "reconcileID": "4f9ace39-1e48-4211
-8a56-e7f78a37bebb", "error": "an empty namespace may not be set during creation"}                                                                                                                                                                                                                                         
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler                                                                        
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:324
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem            
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:265
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2                  
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:226
Creating new client for 10.233.1.108:8080                                                                                                                    
Connection established between 10.233.1.108:8080 and localhost with time out of 1 seconds.                                                                   
Remote Address : 10.233.1.108:8080                                                                                                                           
K8sGPT address: 10.233.1.108:8080                                                                                                                            
Finished Reconciling k8sGPT with error: an empty namespace may not be set during creation 

And If I specify targetNamespace, k8sgpt will only analyze for the namespace. So If I have multiple namespace, I will create k8sgpt for all namespace??

Expected behaviour

k8sGPT will analyze for all namespace if targetNamespace not specified

Actual behaviour

if targetNamespace not specified, k8sgpt will throw

Finished Reconciling k8sGPT with error: an empty namespace may not be set during creation

if targetNamespace specified, k8sgpt will only analyze for that namespace

Additional Information

no

thanks~~

JuHyung-Son commented 6 months ago

Thank you, it will be fixed soon