diff --git a/.github/workflows/build_container.yaml b/.github/workflows/build_container.yaml index 777368c6..2d9fbfdc 100644 --- a/.github/workflows/build_container.yaml +++ b/.github/workflows/build_container.yaml @@ -118,7 +118,7 @@ jobs: uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 - name: Login to GitHub Container Registry - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 with: registry: "ghcr.io" username: ${{ github.actor }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 717182a7..a54dbff1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -80,7 +80,7 @@ jobs: uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3 - name: Login to GitHub Container Registry - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 with: registry: "ghcr.io" username: ${{ github.actor }} diff --git a/api/v1alpha1/k8sgpt_types.go b/api/v1alpha1/k8sgpt_types.go index 3fc6bd8c..e758d7fd 100644 --- a/api/v1alpha1/k8sgpt_types.go +++ b/api/v1alpha1/k8sgpt_types.go @@ -82,7 +82,7 @@ type BackOff struct { type AISpec struct { // +kubebuilder:default:=openai - // +kubebuilder:validation:Enum=openai;localai;azureopenai;amazonbedrock;cohere;amazonsagemaker;google;googlevertexai + // +kubebuilder:validation:Enum=watsonxai;openai;localai;azureopenai;amazonbedrock;cohere;amazonsagemaker;google;googlevertexai Backend string `json:"backend"` BackOff *BackOff `json:"backOff,omitempty"` BaseUrl string `json:"baseUrl,omitempty"` @@ -140,6 +140,7 @@ const ( Cohere = "cohere" Google = "google" GoogleVertexAI = "googlevertexai" + WatsonXAI = "watsonxai" ) // K8sGPTStatus defines the observed state of K8sGPT diff --git a/api/v1alpha1/result_types.go b/api/v1alpha1/result_types.go index 3201c94b..76d46e79 100644 --- a/api/v1alpha1/result_types.go +++ b/api/v1alpha1/result_types.go @@ -50,6 +50,7 @@ type ResultStatus struct { //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="Kind",type="string",JSONPath=".spec.kind",description="Kind" //+kubebuilder:printcolumn:name="Backend",type="string",JSONPath=".spec.backend",description="Backend" +//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age" // Result is the Schema for the results API type Result struct { diff --git a/chart/operator/templates/k8sgpt-crd.yaml b/chart/operator/templates/k8sgpt-crd.yaml index 252c0ea6..9704f734 100644 --- a/chart/operator/templates/k8sgpt-crd.yaml +++ b/chart/operator/templates/k8sgpt-crd.yaml @@ -56,6 +56,7 @@ spec: backend: default: openai enum: + - watsonxai - openai - localai - azureopenai diff --git a/chart/operator/templates/result-crd.yaml b/chart/operator/templates/result-crd.yaml index b66d4b00..0f799b86 100644 --- a/chart/operator/templates/result-crd.yaml +++ b/chart/operator/templates/result-crd.yaml @@ -24,6 +24,10 @@ spec: jsonPath: .spec.backend name: Backend type: string + - description: Age + jsonPath: .metadata.creationTimestamp + name: Age + type: date name: v1alpha1 schema: openAPIV3Schema: diff --git a/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml b/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml index 4a26a524..6edaaafa 100644 --- a/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml +++ b/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml @@ -59,6 +59,7 @@ spec: backend: default: openai enum: + - watsonxai - openai - localai - azureopenai diff --git a/config/crd/bases/core.k8sgpt.ai_results.yaml b/config/crd/bases/core.k8sgpt.ai_results.yaml index 6b9adf2f..77db50f5 100644 --- a/config/crd/bases/core.k8sgpt.ai_results.yaml +++ b/config/crd/bases/core.k8sgpt.ai_results.yaml @@ -23,6 +23,10 @@ spec: jsonPath: .spec.backend name: Backend type: string + - description: Age + jsonPath: .metadata.creationTimestamp + name: Age + type: date name: v1alpha1 schema: openAPIV3Schema: diff --git a/go.mod b/go.mod index e1e2d42e..4d1b3f9d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.4.0-20240406062209-1cc152efbf5c.1 - buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240406062209-1cc152efbf5c.2 + buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240720172138-1b9bcd834f17.2 github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 github.com/prometheus/client_golang v1.19.1 diff --git a/go.sum b/go.sum index 2ccd5013..4e686be6 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.4.0-20240406062209-1cc152efbf5c.1 h1:LgzSBB4q8qpgOqpTJoUKEbsDMddSuMK/ccdCuyQkOV8= buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.4.0-20240406062209-1cc152efbf5c.1/go.mod h1:8O5QQzJX72VEsoGtQvjBYwA25KrvIN7unx+ahHfxPpc= buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.1-20240406062209-1cc152efbf5c.1/go.mod h1:qEarbrHjaZEQ5GeUH6XqSqqJMvtPwAGFpAc0nkSBzrQ= -buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240406062209-1cc152efbf5c.2 h1:9lke4oMvLFuSb+tR1gU2FVBXVZJy84JLafjPdBxnK+E= -buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240406062209-1cc152efbf5c.2/go.mod h1:1wq1qVxvJkTEUQsF5/XjmhQYXYhbVoLSGhKnzS3ie54= +buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240720172138-1b9bcd834f17.2 h1:IGBeVvzzeoEl0Ck0uxWXIUn8/my/ZeBvQEIaXCLteOc= +buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.34.2-20240720172138-1b9bcd834f17.2/go.mod h1:1wq1qVxvJkTEUQsF5/XjmhQYXYhbVoLSGhKnzS3ie54= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= diff --git a/pkg/resources/k8sgpt.go b/pkg/resources/k8sgpt.go index 89cabf2c..5abc8c72 100644 --- a/pkg/resources/k8sgpt.go +++ b/pkg/resources/k8sgpt.go @@ -227,7 +227,7 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien }) } // This check is necessary for the simple OpenAI journey, let's keep it here and guard from breaking other types of backend - if config.Spec.AI.Secret != nil && config.Spec.AI.Backend != v1alpha1.AmazonBedrock { + if config.Spec.AI.Secret != nil && config.Spec.AI.Backend != v1alpha1.AmazonBedrock && config.Spec.AI.Backend != v1alpha1.WatsonXAI { password := corev1.EnvVar{ Name: "K8SGPT_PASSWORD", ValueFrom: &corev1.EnvVarSource{ @@ -313,6 +313,17 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien }, ) } + // Add checks for watsonxai + if config.Spec.AI.Backend == v1alpha1.WatsonXAI { + if config.Spec.AI.Secret != nil { + if err := addSecretAsEnvToDeployment(config.Spec.AI.Secret.Name, "WATSONX_API_KEY", config, c, &deployment); err != nil { + return &appsv1.Deployment{}, err + } + if err := addSecretAsEnvToDeployment(config.Spec.AI.Secret.Name, "WATSONX_PROJECT_ID", config, c, &deployment); err != nil { + return &appsv1.Deployment{}, err + } + } + } return &deployment, nil }