Skip to content

Commit

Permalink
Label the DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
gburges committed Sep 12, 2023
1 parent c1066bc commit a4d1e95
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 2 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
1 change: 1 addition & 0 deletions controllers/cloud.redhat.com/providers/inmemorydb/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ 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)
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 @@ -6,6 +6,9 @@ metadata:
namespace: test-db-resource-tee
spec:
template:
metadata:
labels:
service: db
spec:
containers:
- image: quay.io/cloudservices/postgresql-rds:12-9ee2984
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
15 changes: 15 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,15 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-a-redis
namespace: test-local-db-redis
spec:
template:
metadata:
labels:
service: redis
spec:
containers:
- image: quay.io/cloudservices/redis-ephemeral:6
resources: {}
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 a4d1e95

Please sign in to comment.