Skip to content

Commit

Permalink
Merge pull request #970 from RedHatInsights/psav/move_to_configurable…
Browse files Browse the repository at this point in the history
…_images

feat: moved to configurable images
  • Loading branch information
psav authored Apr 12, 2024
2 parents 35675fc + 021d503 commit be1dfe1
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 24 deletions.
14 changes: 14 additions & 0 deletions apis/cloud.redhat.com/v1alpha1/clowdenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ type ServiceMeshConfig struct {
Mode ServiceMeshMode `json:"mode,omitempty"`
}

type ObjectStoreImages struct {
Minio string `json:"minio,omitempty"`
}

// ObjectStoreMode details the mode of operation of the Clowder ObjectStore
// Provider
// +kubebuilder:validation:Enum=minio;app-interface;none
Expand All @@ -349,6 +353,13 @@ type ObjectStoreConfig 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"`

// Override the object store images
Images ObjectStoreImages `json:"images,omitempty"`
}

type FeatureFlagsImages struct {
Unleash string `json:"unleash,omitempty"`
}

// FeatureFlagsMode details the mode of operation of the Clowder FeatureFlags
Expand Down Expand Up @@ -379,6 +390,9 @@ type FeatureFlagsConfig struct {

// Defineds the port for (*_app-interface_*) mode
Port int32 `json:"port,omitempty"`

// Defines images used for the feature flags provider
Images FeatureFlagsImages `json:"images,omitempty"`
}

// InMemoryMode details the mode of operation of the Clowder InMemoryDB
Expand Down
32 changes: 32 additions & 0 deletions apis/cloud.redhat.com/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 12 additions & 0 deletions config/crd/bases/cloud.redhat.com_clowdenvironments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ spec:
description: Defines the hostname for (*_app-interface_*)
mode
type: string
images:
description: Defines images used for the feature flags provider
properties:
unleash:
type: string
type: object
mode:
description: 'The mode of operation of the Clowder FeatureFlag
Provider. Valid options are: (*_app-interface_*) where the
Expand Down Expand Up @@ -438,6 +444,12 @@ spec:
description: Defines the Configuration for the Clowder ObjectStore
Provider.
properties:
images:
description: Override the object store images
properties:
minio:
type: string
type: object
mode:
description: 'The mode of operation of the Clowder ObjectStore
Provider. Valid options are: (*_app-interface_*) where the
Expand Down
4 changes: 4 additions & 0 deletions config/deployment-template/clowder_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ data:
},
"settings": {
"managedKafkaEphemDeleteRegex": "${MANAGED_EPHEM_DELETE_REGEX}"
},
"images": {
"objectStoreMinio": "${OBJECTSTORE_IMAGE}",
"featureFlagsUnleash": "${FEATUREFLAGS_IMAGE}"
}
}
14 changes: 8 additions & 6 deletions controllers/cloud.redhat.com/clowderconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (

type ClowderConfig struct {
Images struct {
MBOP string `json:"mbop"`
Caddy string `json:"caddy"`
CaddyGateway string `json:"caddyGateway"`
Keycloak string `json:"Keycloak"`
Mocktitlements string `json:"mocktitlements"`
CaddyReverseProxy string `json:"caddyReverseProxy"`
MBOP string `json:"mbop"`
Caddy string `json:"caddy"`
CaddyGateway string `json:"caddyGateway"`
Keycloak string `json:"Keycloak"`
Mocktitlements string `json:"mocktitlements"`
CaddyReverseProxy string `json:"caddyReverseProxy"`
ObjectStoreMinio string `json:"objectStoreMinio"`
FeatureFlagsUnleash string `json:"featureFlagsUnleash"`
} `json:"images"`
DebugOptions struct {
Logging struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (ff *localFeatureFlagsProvider) Provide(_ *crd.ClowdApp) error {
return nil
}

func makeLocalFeatureFlags(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) {
func makeLocalFeatureFlags(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) error {
nn := providers.GetNamespacedName(o, "featureflags")

dd := objMap[LocalFFDeployment].(*apps.Deployment)
Expand Down Expand Up @@ -279,9 +279,14 @@ func makeLocalFeatureFlags(o obj.ClowdObject, objMap providers.ObjectMap, _ bool
FailureThreshold: 3,
}

env, ok := o.(*crd.ClowdEnvironment)
if !ok {
return fmt.Errorf("could not get env")
}

c := core.Container{
Name: nn.Name,
Image: DefaultImageFeatureFlagsUnleash,
Image: GetFeatureFlagsUnleashImage(env),
Env: envVars,
Ports: ports,
LivenessProbe: &livenessProbe,
Expand Down Expand Up @@ -312,4 +317,5 @@ func makeLocalFeatureFlags(o obj.ClowdObject, objMap providers.ObjectMap, _ bool
}}

utils.MakeService(svc, nn, labels, servicePorts, o, nodePort)
return nil
}
14 changes: 13 additions & 1 deletion controllers/cloud.redhat.com/providers/featureflags/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ package featureflags
import (
"fmt"

crd "github.com/RedHatInsights/clowder/apis/cloud.redhat.com/v1alpha1"
"github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/clowderconfig"
"github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/errors"
p "github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/providers"
)

var DefaultImageFeatureFlagsUnleash = "quay.io/cloudservices/unleash-docker:5.6.9"
var DefaultImageFeatureFlagsUnleash = "unleashorg/unleash-server:5.6.9"

func GetFeatureFlagsUnleashImage(env *crd.ClowdEnvironment) string {
if env.Spec.Providers.FeatureFlags.Images.Unleash != "" {
return env.Spec.Providers.FeatureFlags.Images.Unleash
}
if clowderconfig.LoadedConfig.Images.FeatureFlagsUnleash != "" {
return clowderconfig.LoadedConfig.Images.FeatureFlagsUnleash
}
return DefaultImageFeatureFlagsUnleash
}

// ProvName identifies the featureflags provider.
var ProvName = "featureflags"
Expand Down
3 changes: 2 additions & 1 deletion controllers/cloud.redhat.com/providers/inmemorydb/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (r *localRedis) Provide(app *crd.ClowdApp) error {
return providers.CachedMakeComponent(r.Provider.Cache, objList, app, "redis", makeLocalRedis, false, r.Env.IsNodePort())
}

func makeLocalRedis(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) {
func makeLocalRedis(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) error {
nn := providers.GetNamespacedName(o, "redis")

dd := objMap[RedisDeployment].(*apps.Deployment)
Expand Down Expand Up @@ -175,4 +175,5 @@ func makeLocalRedis(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodeP
}}

utils.MakeService(svc, nn, labels, servicePorts, o, nodePort)
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestLocalRedis(t *testing.T) {
RedisDeployment: &dd,
RedisService: &svc,
}
makeLocalRedis(&env, objMap, true, false)
_ = 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")
Expand Down
10 changes: 8 additions & 2 deletions controllers/cloud.redhat.com/providers/objectstore/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func createNetworkPolicy(p *providers.Provider) error {
return p.Cache.Update(MinioNetworkPolicy, np)
}

func makeLocalMinIO(o obj.ClowdObject, objMap providers.ObjectMap, usePVC bool, nodePort bool) {
func makeLocalMinIO(o obj.ClowdObject, objMap providers.ObjectMap, usePVC bool, nodePort bool) error {
nn := providers.GetNamespacedName(o, "minio")

dd := objMap[MinioDeployment].(*apps.Deployment)
Expand Down Expand Up @@ -359,9 +359,14 @@ func makeLocalMinIO(o obj.ClowdObject, objMap providers.ObjectMap, usePVC bool,
FailureThreshold: 3,
}

env, ok := o.(*crd.ClowdEnvironment)
if !ok {
return fmt.Errorf("could not get env from object")
}

c := core.Container{
Name: nn.Name,
Image: DefaultImageObjectStoreMinio,
Image: GetObjectStoreMinioImage(env),
Env: envVars,
Ports: ports,
VolumeMounts: []core.VolumeMount{{
Expand Down Expand Up @@ -394,4 +399,5 @@ func makeLocalMinIO(o obj.ClowdObject, objMap providers.ObjectMap, usePVC bool,
pvc := objMap[MinioPVC].(*core.PersistentVolumeClaim)
utils.MakePVC(pvc, nn, labels, "1Gi", o)
}
return nil
}
14 changes: 13 additions & 1 deletion controllers/cloud.redhat.com/providers/objectstore/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ package objectstore
import (
"fmt"

crd "github.com/RedHatInsights/clowder/apis/cloud.redhat.com/v1alpha1"
"github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/clowderconfig"
"github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/errors"
"github.com/RedHatInsights/clowder/controllers/cloud.redhat.com/providers"
)

var DefaultImageObjectStoreMinio = "quay.io/cloudservices/minio:RELEASE.2020-11-19T23-48-16Z-amd64"
var DefaultImageObjectStoreMinio = "minio/minio:RELEASE.2020-11-19T23-48-16Z-amd64"

func GetObjectStoreMinioImage(env *crd.ClowdEnvironment) string {
if env.Spec.Providers.ObjectStore.Images.Minio != "" {
return env.Spec.Providers.ObjectStore.Images.Minio
}
if clowderconfig.LoadedConfig.Images.ObjectStoreMinio != "" {
return clowderconfig.LoadedConfig.Images.ObjectStoreMinio
}
return DefaultImageObjectStoreMinio
}

// ProvName is the providers ident.
var ProvName = "objectstore"
Expand Down
7 changes: 5 additions & 2 deletions controllers/cloud.redhat.com/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ type ClowderProvider interface {
GetConfig() *config.AppConfig
}

type makeFnCache func(o obj.ClowdObject, objMap ObjectMap, usePVC bool, nodePort bool)
type makeFnCache func(o obj.ClowdObject, objMap ObjectMap, usePVC bool, nodePort bool) error

func createResource(cache *rc.ObjectCache, resourceIdent rc.ResourceIdent, nn types.NamespacedName) (client.Object, error) {
gvks, nok, err := cache.GetScheme().ObjectKinds(resourceIdent.GetType())
Expand Down Expand Up @@ -200,7 +200,10 @@ func CachedMakeComponent(cache *rc.ObjectCache, objList []rc.ResourceIdent, o ob

}

fn(o, makeFnMap, usePVC, nodePort)
err := fn(o, makeFnMap, usePVC, nodePort)
if err != nil {
return fmt.Errorf("could not make component: %w", err)
}

for k, v := range makeFnMap {
err := updateResource(cache, k, v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func makeWebGatewayConfigMap(p *providers.Provider) (string, error) {
return hash, p.Cache.Update(CoreCaddyConfigMap, cm)
}

func makeWebGatewayDeployment(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, _ bool) {
func makeWebGatewayDeployment(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, _ bool) error {
nn := providers.GetNamespacedName(o, "caddy-gateway")

dd := objMap[WebGatewayDeployment].(*apps.Deployment)
Expand Down Expand Up @@ -433,6 +433,7 @@ func makeWebGatewayDeployment(o obj.ClowdObject, objMap providers.ObjectMap, _ b
}}

utils.MakeService(svc, nn, labels, servicePorts, o, false)
return nil
}

func makeWebGatewayIngress(p *providers.Provider) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func baseProbeHandler(port int32, path string) core.ProbeHandler {
}
}

func makeKeycloak(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) {
func makeKeycloak(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) error {
nn := providers.GetNamespacedName(o, "keycloak")

dd := objMap[WebKeycloakDeployment].(*apps.Deployment)
Expand Down Expand Up @@ -391,7 +391,7 @@ func makeKeycloak(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePor
}}

utils.MakeService(svc, nn, labels, servicePorts, o, nodePort)

return nil
}

func makeAuthIngress(p *providers.Provider) error {
Expand Down
4 changes: 2 additions & 2 deletions controllers/cloud.redhat.com/providers/web/resources_mbop.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func makeBOPIngress(p *providers.Provider) error {
return p.Cache.Update(WebBOPIngress, netobj)
}

func makeBOP(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) {
func makeBOP(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) error {
snn := providers.GetNamespacedName(o, "keycloak")
nn := providers.GetNamespacedName(o, "mbop")

Expand Down Expand Up @@ -289,5 +289,5 @@ func makeBOP(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort boo
}

utils.MakeService(svc, nn, labels, servicePorts, o, nodePort)

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func makeMocktitlementsIngress(p *providers.Provider) error {
return p.Cache.Update(WebMocktitlementsIngress, netobj)
}

func makeMocktitlements(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) {
func makeMocktitlements(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodePort bool) error {
snn := providers.GetNamespacedName(o, "keycloak")
nn := providers.GetNamespacedName(o, "mocktitlements")

Expand Down Expand Up @@ -277,4 +277,5 @@ func makeMocktitlements(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, n

utils.MakeService(svc, nn, labels, servicePorts, o, nodePort)

return nil
}
Loading

0 comments on commit be1dfe1

Please sign in to comment.