Skip to content

Commit

Permalink
add kafka app interface cacert to the cache at the start of reconcili…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
nesty156 committed Jan 16, 2025
1 parent d4c749e commit e58d0e0
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 0 deletions.
9 changes: 9 additions & 0 deletions controllers/cloud.redhat.com/providers/kafka/appinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func (a *appInterface) setKafkaCA(broker *config.BrokerConfig) error {
return err
}

_, err := a.HashCache.CreateOrUpdateObject(&kafkaCASecret, true)
if err != nil {
return err
}

if err = a.HashCache.AddClowdObjectToObject(a.Env, &kafkaCASecret); err != nil {
return err
}

broker.Cacert = utils.StringPtr(string(kafkaCASecret.Data["ca.crt"]))
broker.Port = utils.IntPtr(9093)
broker.SecurityProtocol = utils.StringPtr("SSL")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
spec:
finalizers:
- kubernetes
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
apiVersion: v1
kind: Secret
metadata:
name: puptoo
namespace: test-clowdapp-watcher-kafka-app-interface-ca
labels:
app: puptoo
ownerReferences:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
name: puptoo
type: Opaque
data:
cdappconfig.json: eyJlbmRwb2ludHMiOlt7ImFwaVBhdGgiOiIvYXBpL3B1cHRvby1wcm9jZXNzb3IvIiwiYXBpUGF0aHMiOlsiL2FwaS9wdXB0b28tcHJvY2Vzc29yLyJdLCJhcHAiOiJwdXB0b28iLCJob3N0bmFtZSI6InB1cHRvby1wcm9jZXNzb3IudGVzdC1jbG93ZGFwcC13YXRjaGVyLWthZmthLWFwcC1pbnRlcmZhY2UtY2Euc3ZjIiwibmFtZSI6InByb2Nlc3NvciIsInBvcnQiOjgwMDAsInRsc1BvcnQiOjB9XSwiaGFzaENhY2hlIjoiZTNi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WNlLWNhLnN2YyIsIm5hbWUiOiJwcm9jZXNzb3IiLCJwb3J0IjoxMDAwMCwidGxzUG9ydCI6MH1dLCJwcml2YXRlUG9ydCI6MTAwMDAsInB1YmxpY1BvcnQiOjgwMDAsIndlYlBvcnQiOjgwMDB9
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: puptoo-processor
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
strategy:
type: RollingUpdate
template:
spec:
serviceAccountName: puptoo-processor
containers:
- env:
- name: ENV_VAR_1
value: "env_var_1"
- name: ENV_VAR_2
value: "env_var_2"
- name: ACG_CONFIG
value: /cdapp/cdappconfig.json
initContainers:
- env:
- name: ACG_CONFIG
value: /cdapp/cdappconfig.json
- name: ENV_VAR_1
value: "override_1"
- name: ENV_VAR_3
value: "env_var_3"
---
apiVersion: v1
kind: Service
metadata:
name: puptoo-processor
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
selector:
pod: puptoo-processor
ports:
- port: 8000
targetPort: 8000
name: public
appProtocol: http
- port: 10000
targetPort: 10000
name: private
appProtocol: http
- port: 9000
targetPort: 9000
name: metrics
appProtocol: http
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
status:
apps:
- name: puptoo
deployments:
- hostname: puptoo-processor.test-clowdapp-watcher-kafka-app-interface-ca.svc
name: puptoo-processor
port: 8000
---
apiVersion: v1
kind: Namespace
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
labels:
kubernetes.io/metadata.name: test-clowdapp-watcher-kafka-app-interface-ca
101 changes: 101 additions & 0 deletions tests/kuttl/test-clowdapp-watcher-kafka-app-interface-ca/01-pods.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
spec:
targetNamespace: test-clowdapp-watcher-kafka-app-interface-ca
providers:
web:
port: 8000
mode: operator
metrics:
port: 9000
mode: operator
path: "/metrics"
kafka:
forceTLS: true
mode: app-interface
cluster:
name: test-clowdapp-watcher-kafka-app-interface-ca
namespace: test-clowdapp-watcher-kafka-app-interface-ca
forceTLS: true
connect:
namespace: test-clowdapp-watcher-kafka-app-interface-ca
name: test-clowdapp-watcher-kafka-app-interface-ca
db:
mode: none
logging:
mode: none
objectStore:
mode: none
inMemoryDb:
mode: none
resourceDefaults:
limits:
cpu: 400m
memory: 1024Mi
requests:
cpu: 30m
memory: 512Mi
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: puptoo
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
envName: test-clowdapp-watcher-kafka-app-interface-ca
deployments:
- name: processor
podSpec:
image: quay.io/psav/clowder-hello
env:
- name: ENV_VAR_1
value: env_var_1
- name: ENV_VAR_2
value: env_var_2
initContainers:
- env:
- name: ENV_VAR_1
value: override_1
- name: ENV_VAR_3
value: env_var_3
webServices:
public:
enabled: true
private:
enabled: true
kafkaTopics:
- topicName: bob
---
apiVersion: v1
kind: Service
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca-kafka-bootstrap
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
selector:
app: myapp
ports:
- port: 9003
targetPort: 9003
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: bob
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
config: {}
partitions: 3
replicas: 1
---
apiVersion: v1
kind: Secret
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca-cluster-ca-cert
namespace: test-clowdapp-watcher-kafka-app-interface-ca
type: Opaque
stringData:
ca.crt: cacert
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: kubectl get secret --namespace=test-clowdapp-watcher-kafka-app-interface-ca puptoo -o json > /tmp/test-clowdapp-watcher-kafka-app-interface-ca
- script: jq -r '.data["cdappconfig.json"]' < /tmp/test-clowdapp-watcher-kafka-app-interface-ca | base64 -d > /tmp/test-clowdapp-watcher-kafka-app-interface-ca-json

- script: jq -r '.kafka.brokers[0].cacert == "cacert"' -e < /tmp/test-clowdapp-watcher-kafka-app-interface-ca-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
apiVersion: v1
kind: Secret
metadata:
name: puptoo
namespace: test-clowdapp-watcher-kafka-app-interface-ca
labels:
app: puptoo
ownerReferences:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
name: puptoo
type: Opaque
data:
cdappconfig.json: eyJlbmRwb2ludHMiOlt7ImFwaVBhdGgiOiIvYXBpL3B1cHRvby1wcm9jZXNzb3IvIiwiYXBpUGF0aHMiOlsiL2FwaS9wdXB0b28tcHJvY2Vzc29yLyJdLCJhcHAiOiJwdXB0b28iLCJob3N0bmFtZSI6InB1cHRvby1wcm9jZXNzb3IudGVzdC1jbG93ZGFwcC13YXRjaGVyLWthZmthLWFwcC1pbnRlcmZhY2UtY2Euc3ZjIiwibmFtZSI6InByb2Nlc3NvciIsInBvcnQiOjgwMDAsInRsc1BvcnQiOjB9XSwiaGFzaENhY2hlIjoiZTNiMGM0NDI5OGZjMWMxNDlhZmJmNGM4OTk2ZmI5MjQyN2FlNDFlNDY0OWI5MzRjYTQ5NTk5MWI3ODUyYjg1NTIzNzMxNTZkYzU2OWUxMDVkNmZkY2MzZDZkMThjZTI1NzU5ODI1ZGM3M2E5ZWVmZTU1NGIyYmI4OTkyNTNlYmEiLCJrYWZrYSI6eyJicm9rZXJzIjpbeyJjYWNlcnQiOiJuZXctY2FjZXJ0IiwiaG9zdG5hbWUiOiJ0ZXN0LWNsb3dkYXBwLXdhdGNoZXIta2Fma2EtYXBwLWludGVyZmFjZS1jYS1rYWZrYS1ib290c3RyYXAudGVzdC1jbG93ZGFwcC13YXRjaGVyLWthZmthLWFwcC1pbnRlcmZhY2UtY2Euc3ZjIiwicG9ydCI6OTA5Mywic2VjdXJpdHlQcm90b2NvbCI6IlNTTCJ9XSwidG9waWNzIjpbeyJuYW1lIjoiYm9iIiwicmVxdWVzdGVkTmFtZSI6ImJvYiJ9XX0sImxvZ2dpbmciOnsiY2xvdWR3YXRjaCI6eyJhY2Nlc3NLZXlJZCI6IiIsImxvZ0dyb3VwIjoiIiwicmVnaW9uIjoiIiwic2VjcmV0QWNjZXNzS2V5IjoiIn0sInR5cGUiOiJudWxsIn0sIm1ldGFkYXRhIjp7ImRlcGxveW1lbnRzIjpbeyJpbWFnZSI6InF1YXkuaW8vcHNhdi9jbG93ZGVyLWhlbGxvIiwibmFtZSI6InByb2Nlc3NvciJ9XSwiZW52TmFtZSI6InRlc3QtY2xvd2RhcHAtd2F0Y2hlci1rYWZrYS1hcHAtaW50ZXJmYWNlLWNhIiwibmFtZSI6InB1cHRvbyJ9LCJtZXRyaWNzUGF0aCI6Ii9tZXRyaWNzIiwibWV0cmljc1BvcnQiOjkwMDAsInByaXZhdGVFbmRwb2ludHMiOlt7ImFwcCI6InB1cHRvbyIsImhvc3RuYW1lIjoicHVwdG9vLXByb2Nlc3Nvci50ZXN0LWNsb3dkYXBwLXdhdGNoZXIta2Fma2EtYXBwLWludGVyZmFjZS1jYS5zdmMiLCJuYW1lIjoicHJvY2Vzc29yIiwicG9ydCI6MTAwMDAsInRsc1BvcnQiOjB9XSwicHJpdmF0ZVBvcnQiOjEwMDAwLCJwdWJsaWNQb3J0Ijo4MDAwLCJ3ZWJQb3J0Ijo4MDAwfQ==
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: puptoo-processor
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
strategy:
type: RollingUpdate
template:
spec:
serviceAccountName: puptoo-processor
containers:
- env:
- name: ENV_VAR_1
value: "env_var_1"
- name: ENV_VAR_2
value: "env_var_2"
- name: ACG_CONFIG
value: /cdapp/cdappconfig.json
initContainers:
- env:
- name: ACG_CONFIG
value: /cdapp/cdappconfig.json
- name: ENV_VAR_1
value: "override_1"
- name: ENV_VAR_3
value: "env_var_3"
---
apiVersion: v1
kind: Service
metadata:
name: puptoo-processor
namespace: test-clowdapp-watcher-kafka-app-interface-ca
spec:
selector:
pod: puptoo-processor
ports:
- port: 8000
targetPort: 8000
name: public
appProtocol: http
- port: 10000
targetPort: 10000
name: private
appProtocol: http
- port: 9000
targetPort: 9000
name: metrics
appProtocol: http
---
apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdEnvironment
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
status:
apps:
- name: puptoo
deployments:
- hostname: puptoo-processor.test-clowdapp-watcher-kafka-app-interface-ca.svc
name: puptoo-processor
port: 8000
---
apiVersion: v1
kind: Namespace
metadata:
name: test-clowdapp-watcher-kafka-app-interface-ca
labels:
kubernetes.io/metadata.name: test-clowdapp-watcher-kafka-app-interface-ca
Loading

0 comments on commit e58d0e0

Please sign in to comment.