diff --git a/README.md b/README.md index a8916240..be8e15dd 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ spec: name: k8sgpt-sample-secret key: openai-api-key noCache: false - repository: ghcr.io/k8sgpt-ai/k8gpt + repository: ghcr.io/k8sgpt-ai/k8sgpt version: v0.3.8 remoteCache: credentials: @@ -200,7 +200,7 @@ spec: baseUrl: https://k8sgpt.openai.azure.com/ engine: llm noCache: false - repository: ghcr.io/k8sgpt-ai/k8gpt + repository: ghcr.io/k8sgpt-ai/k8sgpt version: v0.3.8 EOF ``` @@ -231,7 +231,7 @@ spec: backend: localai baseUrl: http://local-ai.local-ai.svc.cluster.local:8080/v1 noCache: false - repository: ghcr.io/k8sgpt-ai/k8gpt + repository: ghcr.io/k8sgpt-ai/k8sgpt version: v0.3.8 EOF ``` @@ -241,10 +241,43 @@ EOF +## K8sGPT Configuration Options + +
+ +ImagePullSecrets +You can use custom k8sgpt image by modifying `repository`, `version`, `imagePullSecrets`. +`version` actually works as image tag. + +```sh +kubectl apply -f - << EOF +apiVersion: core.k8sgpt.ai/v1alpha1 +kind: K8sGPT +metadata: + name: k8sgpt-sample + namespace: k8sgpt-operator-system +spec: + ai: + enabled: true + model: gpt-3.5-turbo + backend: openai + secret: + name: k8sgpt-sample-secret + key: openai-api-key + noCache: false + repository: sample.repository/k8sgpt + version: sample-tag + imagePullSecrets: + - name: sample-secret +EOF +``` + +
+ ## Helm values For details please see [here](chart/operator/values.yaml) ## License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt-operator.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt-operator?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt-operator.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fk8sgpt-ai%2Fk8sgpt-operator?ref=badge_large) diff --git a/api/v1alpha1/k8sgpt_types.go b/api/v1alpha1/k8sgpt_types.go index a32e5d73..3c4a1ba0 100644 --- a/api/v1alpha1/k8sgpt_types.go +++ b/api/v1alpha1/k8sgpt_types.go @@ -94,19 +94,24 @@ type Integrations struct { Trivy *Trivy `json:"trivy,omitempty"` } +type ImagePullSecrets struct { + Name string `json:"name,omitempty"` +} + // K8sGPTSpec defines the desired state of K8sGPT type K8sGPTSpec struct { Version string `json:"version,omitempty"` // +kubebuilder:default:=ghcr.io/k8sgpt-ai/k8sgpt - Repository string `json:"repository,omitempty"` - NoCache bool `json:"noCache,omitempty"` - Filters []string `json:"filters,omitempty"` - ExtraOptions *ExtraOptionsRef `json:"extraOptions,omitempty"` - Sink *WebhookRef `json:"sink,omitempty"` - AI *AISpec `json:"ai,omitempty"` - RemoteCache *RemoteCacheRef `json:"remoteCache,omitempty"` - Integrations *Integrations `json:"integrations,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Repository string `json:"repository,omitempty"` + ImagePullSecrets []ImagePullSecrets `json:"imagePullSecrets,omitempty"` + NoCache bool `json:"noCache,omitempty"` + Filters []string `json:"filters,omitempty"` + ExtraOptions *ExtraOptionsRef `json:"extraOptions,omitempty"` + Sink *WebhookRef `json:"sink,omitempty"` + AI *AISpec `json:"ai,omitempty"` + RemoteCache *RemoteCacheRef `json:"remoteCache,omitempty"` + Integrations *Integrations `json:"integrations,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` } const ( diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index a4da0fa4..cb332441 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -145,6 +145,21 @@ func (in *GCSBackend) DeepCopy() *GCSBackend { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePullSecrets) DeepCopyInto(out *ImagePullSecrets) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePullSecrets. +func (in *ImagePullSecrets) DeepCopy() *ImagePullSecrets { + if in == nil { + return nil + } + out := new(ImagePullSecrets) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Integrations) DeepCopyInto(out *Integrations) { *out = *in @@ -227,6 +242,11 @@ func (in *K8sGPTList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *K8sGPTSpec) DeepCopyInto(out *K8sGPTSpec) { *out = *in + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]ImagePullSecrets, len(*in)) + copy(*out, *in) + } if in.Filters != nil { in, out := &in.Filters, &out.Filters *out = make([]string, len(*in)) diff --git a/chart/operator/templates/k8sgpt-crd.yaml b/chart/operator/templates/k8sgpt-crd.yaml index 5346832f..673f660b 100644 --- a/chart/operator/templates/k8sgpt-crd.yaml +++ b/chart/operator/templates/k8sgpt-crd.yaml @@ -84,6 +84,13 @@ spec: items: type: string type: array + imagePullSecrets: + items: + properties: + name: + type: string + type: object + type: array integrations: properties: trivy: diff --git a/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml b/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml index d4ac6eaa..3af7f828 100644 --- a/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml +++ b/config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml @@ -84,6 +84,13 @@ spec: items: type: string type: array + imagePullSecrets: + items: + properties: + name: + type: string + type: object + type: array integrations: properties: trivy: diff --git a/pkg/resources/k8sgpt.go b/pkg/resources/k8sgpt.go index fb7bbe3e..f08c5124 100644 --- a/pkg/resources/k8sgpt.go +++ b/pkg/resources/k8sgpt.go @@ -93,6 +93,13 @@ func GetServiceAccount(config v1alpha1.K8sGPT) (*corev1.ServiceAccount, error) { }, }, }, + ImagePullSecrets: []corev1.LocalObjectReference{}, + } + //Add image pull secrets to service account + for _, secret := range config.Spec.ImagePullSecrets { + serviceAccount.ImagePullSecrets = append(serviceAccount.ImagePullSecrets, corev1.LocalObjectReference{ + Name: secret.Name, + }) } return &serviceAccount, nil