Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions apis/cloud.redhat.com/v1alpha1/clowdenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ type InMemoryDBConfig struct {
// If using the (*_local_*) mode and PVC is set to true, this instructs the local
// Database instance to use a PVC instead of emptyDir for its volumes.
PVC bool `json:"pvc,omitempty"`

// This image is only used in the (*_redis_*) mode, as elsewhere it will try to
// inspect for a secret for a hostname and credentials.
Image string `json:"image,omitempty"`
}

// AutoScaler mode enabled or disabled the autoscaler. The key "keda" is deprecated but preserved for backwards compatibility
Expand Down
1 change: 1 addition & 0 deletions controllers/cloud.redhat.com/clowderconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ClowderConfig struct {
FeatureFlagsUnleashEdge string `json:"featureFlagsUnleashEdge"`
TokenRefresher string `json:"tokenRefresher"`
OtelCollector string `json:"otelCollector"`
InMemoryDB string `json:"inMemoryDB"`
} `json:"images"`
DebugOptions struct {
Logging struct {
Expand Down
2 changes: 1 addition & 1 deletion controllers/cloud.redhat.com/providers/inmemorydb/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func makeLocalRedis(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodeP

dd.Spec.Template.Spec.Containers = []core.Container{{
Name: nn.Name,
Image: providerUtils.DefaultImageInMemoryDB,
Image: providerUtils.GetInMemoryDBImage(o),
Env: []core.EnvVar{},
Ports: []core.ContainerPort{{
Name: "redis",
Expand Down
17 changes: 17 additions & 0 deletions controllers/cloud.redhat.com/providers/inmemorydb/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,20 @@ func TestLocalRedis(t *testing.T) {
assert.Len(t, svc.Spec.Ports, 1, "number of ports specified is wrong")
assert.Equal(t, int32(6379), svc.Spec.Ports[0].Port, "port number is incorrect")
}

func TestLocalRedisImageOverride(t *testing.T) {
env := getRedisTestEnv()
env.Spec.Providers.InMemoryDB.Image = "testing.com/test/image"

dd, svc := apps.Deployment{}, core.Service{}
objMap := providers.ObjectMap{
RedisDeployment: &dd,
RedisService: &svc,
}
_ = makeLocalRedis(&env, objMap, true, false)

assert.Equal(t, "env-redis", dd.GetName(), "name was not set correctly")
assert.Len(t, svc.Spec.Ports, 1, "number of ports specified is wrong")
assert.Equal(t, int32(6379), svc.Spec.Ports[0].Port, "port number is incorrect")
assert.Equal(t, "testing.com/test/image", dd.Spec.Template.Spec.Containers[0].Image)
}
12 changes: 12 additions & 0 deletions controllers/cloud.redhat.com/providers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ func MakeLocalDBPVC(pvc *core.PersistentVolumeClaim, nn types.NamespacedName, ba
utils.MakePVC(pvc, nn, providers.Labels{"service": "db", "app": baseResource.GetClowdName()}, capacity, baseResource)
}

func GetInMemoryDBImage(o obj.ClowdObject) string {
if env, ok := o.(*crd.ClowdEnvironment); ok {
if env.Spec.Providers.InMemoryDB.Image != "" {
return env.Spec.Providers.InMemoryDB.Image
}
}
if clowderconfig.LoadedConfig.Images.InMemoryDB != "" {
return clowderconfig.LoadedConfig.Images.InMemoryDB
}
return DefaultImageInMemoryDB
}

// GetCaddyImage returns the caddy image to use in a given environment
func GetCaddyGatewayImage(env *crd.ClowdEnvironment) string {
if env.Spec.Providers.Web.Images.CaddyGateway != "" {
Expand Down
2 changes: 2 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `unleash` _string_ | | | |
| `unleashEdge` _string_ | | | |


#### FeatureFlagsMode
Expand Down Expand Up @@ -640,6 +641,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `mode` _[InMemoryMode](#inmemorymode)_ | The mode of operation of the Clowder InMemory Provider. Valid options are:<br />(*_redis_*) where a local Minio instance will be created, and (*_elasticache_*)<br />which will search the namespace of the ClowdApp for a secret called 'elasticache' | | Enum: [redis app-interface elasticache none] <br /> |
| `pvc` _boolean_ | If using the (*_local_*) mode and PVC is set to true, this instructs the local<br />Database instance to use a PVC instead of emptyDir for its volumes. | | |
| `image` _string_ | This image is only used in the (*_redis_*) mode, as elsewhere it will try to<br />inspect for a secret for a hostname and credentials. | | |


#### InMemoryMode
Expand Down
Loading