Skip to content

Commit

Permalink
Label the DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
gburges committed May 17, 2023
1 parent 923bed2 commit 4947449
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func makeLocalFeatureFlags(o obj.ClowdObject, objMap providers.ObjectMap, _ bool

labels := o.GetLabels()
labels["env-app"] = nn.Name

labels["service"] = "featureflags"
labeler := utils.MakeLabeler(nn, labels, o)

labeler(dd)
Expand Down
4 changes: 2 additions & 2 deletions controllers/cloud.redhat.com/providers/inmemorydb/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

rc "github.com/RedHatInsights/rhc-osdk-utils/resourceCache"
Expand Down Expand Up @@ -94,11 +93,12 @@ func makeLocalRedis(o obj.ClowdObject, objMap providers.ObjectMap, _ bool, nodeP

labels := o.GetLabels()
labels["env-app"] = nn.Name
labels["service"] = "redis"
labeler := utils.MakeLabeler(nn, labels, o)

labeler(dd)

dd.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels}
// dd.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels}
dd.Spec.Template.ObjectMeta.Labels = labels
dd.Spec.Replicas = &oneReplica

Expand Down
40 changes: 40 additions & 0 deletions controllers/cloud.redhat.com/providers/kafka/strimzi.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ func (s *strimziProvider) configureKafkaCluster() error {
kafLimits = *s.Env.Spec.Providers.Kafka.Cluster.Resources.Limits
}

var klabels apiextensions.JSON

err = klabels.UnmarshalJSON([]byte(`{
"service" : "strimziKafka"
}`))
if err != nil {
return fmt.Errorf("could not unmarshal klabels: %w", err)
}

k.Spec = &strimzi.KafkaSpec{
Kafka: strimzi.KafkaSpecKafka{
Config: &kafConfig,
Expand All @@ -296,15 +305,46 @@ func (s *strimziProvider) configureKafkaCluster() error {
Requests: &kafRequests,
Limits: &kafLimits,
},
Template: &strimzi.KafkaSpecKafkaTemplate{
PerPodService: &strimzi.KafkaSpecKafkaTemplatePerPodService{
Metadata: &strimzi.KafkaSpecKafkaTemplatePerPodServiceMetadata{
Labels: &klabels,
},
},
Pod: &strimzi.KafkaSpecKafkaTemplatePod{
Metadata: &strimzi.KafkaSpecKafkaTemplatePodMetadata{
Labels: &klabels,
},
},
},
},
Zookeeper: strimzi.KafkaSpecZookeeper{
Replicas: replicas,
Resources: &strimzi.KafkaSpecZookeeperResources{
Requests: &zRequests,
Limits: &zLimits,
},
Template: &strimzi.KafkaSpecZookeeperTemplate{
NodesService: &strimzi.KafkaSpecZookeeperTemplateNodesService{
Metadata: &strimzi.KafkaSpecZookeeperTemplateNodesServiceMetadata{
Labels: &klabels,
},
},
Pod: &strimzi.KafkaSpecZookeeperTemplatePod{
Metadata: &strimzi.KafkaSpecZookeeperTemplatePodMetadata{
Labels: &klabels,
},
},
},
},
EntityOperator: &strimzi.KafkaSpecEntityOperator{
Template: &strimzi.KafkaSpecEntityOperatorTemplate{
Pod: &strimzi.KafkaSpecEntityOperatorTemplatePod{
Metadata: &strimzi.KafkaSpecEntityOperatorTemplatePodMetadata{
Labels: &klabels,
},
},
},
TopicOperator: &strimzi.KafkaSpecEntityOperatorTopicOperator{
Resources: &strimzi.KafkaSpecEntityOperatorTopicOperatorResources{
Requests: &entityTopicRequests,
Expand Down
3 changes: 2 additions & 1 deletion tests/kuttl/test-cyndi-local-db/01-pods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
objectStore:
mode: none
inMemoryDb:
mode: none
mode: redis
resourceDefaults:
limits:
cpu: 400m
Expand All @@ -49,3 +49,4 @@ spec:
database:
name: app-a-db
version: 12
inMemoryDb: true
2 changes: 2 additions & 0 deletions tests/kuttl/test-db-pvc-tee/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Deployment
metadata:
name: app-a-db
namespace: test-db-pvc-tee
labels:
service: db
spec:
template:
spec:
Expand Down
3 changes: 3 additions & 0 deletions tests/kuttl/test-db-resource-tee/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
spec:
template:
spec:
metadata:
labels:
service: db
containers:
- image: quay.io/cloudservices/postgresql-rds:12-9ee2984
resources:
Expand Down
2 changes: 2 additions & 0 deletions tests/kuttl/test-ff-local/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ kind: Deployment
metadata:
name: test-ff-local-featureflags
namespace: test-ff-local
labels:
service: featureflags
spec:
template:
spec:
Expand Down
23 changes: 23 additions & 0 deletions tests/kuttl/test-kafka-strimzi-ephemeral/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,34 @@ spec:
requests:
cpu: 250m
memory: 600Mi
template:
perPodService:
metadata:
labels:
service: strimziKafka
pod:
metadata:
labels:
service: strimziKafka
zookeeper:
replicas: 1
storage:
type: ephemeral
template:
nodesService:
metadata:
labels:
service: strimziKafka
pod:
metadata:
labels:
service: strimziKafka
entityOperator:
template:
pod:
metadata:
labels:
service: strimziKafka
topicOperator: {}
---
apiVersion: kafka.strimzi.io/v1beta2
Expand Down
7 changes: 7 additions & 0 deletions tests/kuttl/test-local-db-redis/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: test-local-db-redis
spec:
finalizers:
- kubernetes
21 changes: 21 additions & 0 deletions tests/kuttl/test-local-db-redis/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-a-db
namespace: test-local-db-redis
spec:
template:
spec:
metadata:
labels:
service: redis
containers:
- image: quay.io/cloudservices/redis-ephemeral:6
resources:
limits:
cpu: 1800m
memory: 2Gi
requests:
cpu: 1200m
memory: 1Gi
48 changes: 48 additions & 0 deletions tests/kuttl/test-local-db-redis/01-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-local-db-redis
spec:
targetNamespace: test-local-db-redis
providers:
web:
port: 8000
mode: operator
metrics:
port: 9000
mode: operator
path: "/metrics"
kafka:
mode: none
db:
mode: none
logging:
mode: none
objectStore:
mode: none
inMemoryDb:
mode: redis
pvc: false
featureFlags:
mode: none
resourceDefaults:
limits:
cpu: 400m
memory: 1024Mi
requests:
cpu: 30m
memory: 512Mi
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: app-a
namespace: test-local-db-redis
spec:
envName: test-local-db-redis
deployments:
- name: processor
podSpec:
image: quay.io/psav/clowder-hello
inMemoryDb: true
10 changes: 10 additions & 0 deletions tests/kuttl/test-local-db-redis/02-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: v1
kind: Namespace
name: test-local-db-redis
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
name: test-local-db-redis

0 comments on commit 4947449

Please sign in to comment.