Skip to content

Commit

Permalink
Issue 280 (#282)
Browse files Browse the repository at this point in the history
* Add ImagePullSecrets to K8sGPTSpec.

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* Add image pull secrets to service account

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* add spec to README

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* lint

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

* fix readme

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>

---------

Signed-off-by: JuHyung-Son <sonju0427@gmail.com>
  • Loading branch information
JuHyung-Son committed Dec 22, 2023
1 parent a9bc7bf commit f4673cc
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 13 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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
```
Expand All @@ -241,10 +241,43 @@ EOF
</details>
## K8sGPT Configuration Options
<details>
<summary>ImagePullSecrets</summary>
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
```
</details>
## Helm values
For details please see [here](chart/operator/values.yaml)
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgit.luolix.top%2Fk8sgpt-ai%2Fk8sgpt-operator.svg?type=large)](https://app.fossa.com/projects/git%2Bgit.luolix.top%2Fk8sgpt-ai%2Fk8sgpt-operator?ref=badge_large)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgit.luolix.top%2Fk8sgpt-ai%2Fk8sgpt-operator.svg?type=large)](https://app.fossa.com/projects/git%2Bgit.luolix.top%2Fk8sgpt-ai%2Fk8sgpt-operator?ref=badge_large)
23 changes: 14 additions & 9 deletions api/v1alpha1/k8sgpt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions chart/operator/templates/k8sgpt-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ spec:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
integrations:
properties:
trivy:
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ spec:
items:
type: string
type: array
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
integrations:
properties:
trivy:
Expand Down
7 changes: 7 additions & 0 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4673cc

Please sign in to comment.