Skip to content

Commit c9f1290

Browse files
feat: rework cache & add gcs cache option (#262)
* feat: rework cache & add gcs cache option Signed-off-by: Matthis Holleville <[email protected]> * feat: update dependencies Signed-off-by: Matthis Holleville <[email protected]> * feat: update cache sample Signed-off-by: Matthis Holleville <[email protected]> * feat: update crd Signed-off-by: Matthis Holleville <[email protected]> --------- Signed-off-by: Matthis Holleville <[email protected]> Co-authored-by: Alex Jones <[email protected]>
1 parent 1ca833b commit c9f1290

File tree

8 files changed

+79
-16
lines changed

8 files changed

+79
-16
lines changed

api/v1alpha1/k8sgpt_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type CredentialsRef struct {
4242

4343
type RemoteCacheRef struct {
4444
Credentials *CredentialsRef `json:"credentials,omitempty"`
45+
GCS *GCSBackend `json:"gcs,omitempty"`
4546
S3 *S3Backend `json:"s3,omitempty"`
4647
Azure *AzureBackend `json:"azure,omitempty"`
4748
}
@@ -56,6 +57,12 @@ type AzureBackend struct {
5657
ContainerName string `json:"containerName,omitempty"`
5758
}
5859

60+
type GCSBackend struct {
61+
BucketName string `json:"bucketName,omitempty"`
62+
Region string `json:"region,omitempty"`
63+
ProjectId string `json:"projectId,omitempty"`
64+
}
65+
5966
type WebhookRef struct {
6067
// +kubebuilder:validation:Enum=slack
6168
Type string `json:"type,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/operator/templates/k8sgpt-crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ spec:
9797
name:
9898
type: string
9999
type: object
100+
gcs:
101+
properties:
102+
bucketName:
103+
type: string
104+
projectId:
105+
type: string
106+
region:
107+
type: string
108+
type: object
100109
s3:
101110
properties:
102111
bucketName:

config/crd/bases/core.k8sgpt.ai_k8sgpts.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ spec:
109109
name:
110110
type: string
111111
type: object
112+
gcs:
113+
properties:
114+
bucketName:
115+
type: string
116+
projectId:
117+
type: string
118+
region:
119+
type: string
120+
type: object
112121
s3:
113122
properties:
114123
bucketName:

config/samples/core_v1alpha1_k8sgpt.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ spec:
1313
key: openai-api-key
1414
noCache: false
1515
version: v0.3.17
16-
# remoteCache:
17-
# credentials:
18-
# name: k8sgpt-sample-cache-secret
19-
# bucketName: k8sgpt-debug-test
20-
# region: eu-west-2
16+
# remoteCache:
17+
# credentials:
18+
# name: k8sgpt-sample-cache-secret
19+
# s3:
20+
# bucketName: foo
21+
# region: us-west-1
2122
integrations:
2223
trivy:
2324
enabled: false

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/k8sgpt-ai/k8sgpt-operator
33
go 1.19
44

55
require (
6-
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231002095256-194bc640518b.1
7-
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20231002095256-194bc640518b.1
6+
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231116211251-9f5041346631.2
7+
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20231116211251-9f5041346631.4
88
github.com/onsi/ginkgo/v2 v2.13.1
99
github.com/onsi/gomega v1.30.0
1010
github.com/prometheus/client_golang v1.17.0

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231002095256-194bc640518b.1 h1:xYEAhcdWh89HNtbM5Uv4b2xu+4/MkNffR9JNrnnEjXU=
2-
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231002095256-194bc640518b.1/go.mod h1:j2QJ3L7VTtI+VeK6t03h9X934FolVTb3FwXUc76bQMQ=
3-
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20231002095256-194bc640518b.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE=
4-
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20231002095256-194bc640518b.1 h1:Bt8mnCodD/BqChxt/r3xYayGLoOAn334qC1tN7VqUTE=
5-
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20231002095256-194bc640518b.1/go.mod h1:gtnk2yAUexdY5nTuUg0SH5WCCGvpKzr7pd3Xbi7MWjE=
1+
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231116211251-9f5041346631.2 h1:lr4kHFzPIzoWIHF6s/B+0Wb/WknraHrbqNguavOzP70=
2+
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20231116211251-9f5041346631.2/go.mod h1:g/UdFu0wAAS44ncCfX3zjna7WC1gp6BENVL6LPJ9tow=
3+
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20231116211251-9f5041346631.4 h1:f7e94G/tYVs+QDTvjU9sFolC5tuJxlOjzUBJ84XMwkg=
4+
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20231116211251-9f5041346631.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE=
65
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
76
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
87
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=

pkg/client/config.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,31 @@ func (c *Client) AddConfig(config *v1alpha1.K8sGPT) error {
1616
// which emulates the behaviour of K8sGPT cli
1717
if config.Spec.RemoteCache.S3 != nil {
1818
req.Cache = &schemav1.Cache{
19-
BucketName: config.Spec.RemoteCache.S3.BucketName,
20-
Region: config.Spec.RemoteCache.S3.Region,
19+
CacheType: &schemav1.Cache_S3Cache{
20+
S3Cache: &schemav1.S3Cache{
21+
BucketName: config.Spec.RemoteCache.S3.BucketName,
22+
Region: config.Spec.RemoteCache.S3.Region,
23+
},
24+
},
2125
}
2226
} else if config.Spec.RemoteCache.Azure != nil {
2327
req.Cache = &schemav1.Cache{
24-
StorageAccount: config.Spec.RemoteCache.Azure.StorageAccount,
25-
ContainerName: config.Spec.RemoteCache.Azure.ContainerName,
28+
CacheType: &schemav1.Cache_AzureCache{
29+
AzureCache: &schemav1.AzureCache{
30+
StorageAccount: config.Spec.RemoteCache.Azure.StorageAccount,
31+
ContainerName: config.Spec.RemoteCache.Azure.ContainerName,
32+
},
33+
},
34+
}
35+
} else if config.Spec.RemoteCache.GCS != nil {
36+
req.Cache = &schemav1.Cache{
37+
CacheType: &schemav1.Cache_GcsCache{
38+
GcsCache: &schemav1.GCSCache{
39+
BucketName: config.Spec.RemoteCache.GCS.BucketName,
40+
Region: config.Spec.RemoteCache.GCS.Region,
41+
ProjectId: config.Spec.RemoteCache.GCS.ProjectId,
42+
},
43+
},
2644
}
2745
}
2846

0 commit comments

Comments
 (0)