Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat: add minio cache #521

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need different env variables although we are using the same aws client, in theory this shouldn't matter if it's s3 native or minio?

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the aws s3 client on the k8sgpt side so those secret names won't get picked, up I think

} 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
Loading