Skip to content

Commit

Permalink
feat: add minio cache k8sgpt-ai#464
Browse files Browse the repository at this point in the history
Signed-off-by: Shahrooz Aghili <[email protected]>
  • Loading branch information
aghilish committed Sep 30, 2024
1 parent bf65ff4 commit 8f39c51
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,47 @@ EOF
</details>
<details>
<summary>Minio</summary>
1. Install the operator from the [Installation](#installation) section.
2. Create secret:
```sh
kubectl create secret generic k8sgpt-sample-cache-secret --from-literal=minio_access_key=<MINIO_ACCESS_KEY> --from-literal=minio_secret_key=<MINIO_SECRET_KEY> -n k8sgpt-operator-system
```
3. Apply the K8sGPT configuration object:
```
kubectl apply -f - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-sample
namespace: k8sgpt-operator-system
spec:
ai:
enabled: true
secret:
name: bedrock-sample-secret
model: anthropic.claude-v2
region: eu-central-1
backend: amazonbedrock
noCache: false
version: v0.3.41
remoteCache:
credentials:
name: k8sgpt-sample-cache-secret
s3:
bucketName: k8sgpt-cache-123456789
endpoint: http://minio.k8sgpt-operator-system.svc.cluster.local:9000
insecure: true
EOF
```
</details>
## Other AI Backend Examples
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/k8sgpt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type RemoteCacheRef struct {
type S3Backend struct {
BucketName string `json:"bucketName,omitempty"`
Region string `json:"region,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
// +kubebuilder:default:=false
Insecure bool `json:"insecure,omitempty"`
}

type AzureBackend struct {
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ spec:
properties:
bucketName:
type: string
endpoint:
type: string
insecure:
default: false
type: boolean
region:
type: string
type: object
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func (c *Client) AddConfig(config *v1alpha1.K8sGPT) error {
S3Cache: &schemav1.S3Cache{
BucketName: config.Spec.RemoteCache.S3.BucketName,
Region: config.Spec.RemoteCache.S3.Region,
Endpoint: config.Spec.RemoteCache.S3.Endpoint,
Insecure: config.Spec.RemoteCache.S3.Insecure,
},
},
}
Expand Down
19 changes: 9 additions & 10 deletions pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,15 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien
addRemoteCacheEnvVar("AZURE_TENANT_ID", "azure_tenant_id")
addRemoteCacheEnvVar("AZURE_CLIENT_SECRET", "azure_client_secret")
} else if config.Spec.RemoteCache.S3 != nil {
addRemoteCacheEnvVar("AWS_ACCESS_KEY_ID", "aws_access_key_id")
addRemoteCacheEnvVar("AWS_SECRET_ACCESS_KEY", "aws_secret_access_key")
if config.Spec.RemoteCache.S3.Endpoint != "" {
// MinIO
addRemoteCacheEnvVar("MINIO_ACCESS_KEY", "minio_access_key")
addRemoteCacheEnvVar("MINIO_SECRET_KEY", "minio_secret_key")
} else {
// AWS S3
addRemoteCacheEnvVar("AWS_ACCESS_KEY_ID", "aws_access_key_id")
addRemoteCacheEnvVar("AWS_SECRET_ACCESS_KEY", "aws_secret_access_key")
}
}
}

Expand Down Expand Up @@ -327,14 +334,6 @@ func GetDeployment(config v1alpha1.K8sGPT, outOfClusterMode bool, c client.Clien
},
)
}
// Add checks for ibmwatsonxai
if config.Spec.AI.Backend == v1alpha1.IBMWatsonxAI {
if config.Spec.AI.Secret != nil {
if err := addSecretAsEnvToDeployment(config.Spec.AI.Secret.Name, "K8SGPT_PROVIDER_ID", config, c, &deployment); err != nil {
return &appsv1.Deployment{}, err
}
}
}
return &deployment, nil
}

Expand Down

0 comments on commit 8f39c51

Please sign in to comment.