Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Introduce Newsletter Subs Deployment for Operator #1899

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"specversion": "1.0",
"id": "dad76364-1cf1-48ca-bf95-485a511f8707",
"source": "demo",
"type": "confirm.subscription",
"kogitoprocrefid": "378e64f6-dbff-4486-932c-390ade04f65b",
"datacontenttype": "application/json",
"time": "2024-03-20T15:35:29.967831-03:00",
"data": {
"id": "378e64f6-dbff-4486-932c-390ade04f65b",
"confirmed": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2024 Apache Software Foundation (ASF)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/name: postgres
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: postgres
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: postgres
template:
metadata:
labels:
app.kubernetes.io/name: postgres
spec:
containers:
- name: postgres
image: postgres
imagePullPolicy: 'IfNotPresent'
ports:
- containerPort: 5432
volumeMounts:
- name: storage
mountPath: /var/lib/pgsql/data
envFrom:
- secretRef:
name: postgres-secrets
readinessProbe:
exec:
command: ["pg_isready"]
initialDelaySeconds: 15
timeoutSeconds: 2
livenessProbe:
exec:
command: ["pg_isready"]
initialDelaySeconds: 15
timeoutSeconds: 2
resources:
limits:
memory: "256Mi"
cpu: "500m"
volumes:
- name: storage
persistentVolumeClaim:
claimName: postgres-pvc
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: postgres
name: postgres
spec:
selector:
app.kubernetes.io/name: postgres
ports:
- port: 5432
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 Apache Software Foundation (ASF)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
name: sonataflow-platform
spec:
services:
dataIndex:
enabled: true
persistence:
postgresql:
secretRef:
name: postgres-secrets
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=data-index-service
podTemplate:
initContainers:
- name: init-postgres
image: registry.access.redhat.com/ubi9/ubi-micro:latest
imagePullPolicy: IfNotPresent
command: [ 'sh', '-c', 'until (echo 1 > /dev/tcp/postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local/5432) >/dev/null 2>&1; do echo "Waiting for postgres server"; sleep 3; done;' ]
jobService:
enabled: true
persistence:
postgresql:
secretRef:
name: postgres-secrets
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=jobs-service
podTemplate:
initContainers:
- name: init-postgres
image: registry.access.redhat.com/ubi9/ubi-micro:latest
imagePullPolicy: IfNotPresent
command: [ 'sh', '-c', 'until (echo 1 > /dev/tcp/postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local/5432) >/dev/null 2>&1; do echo "Waiting for postgres server"; sleep 3; done;' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
annotations:
app.quarkus.io/commit-id: eeb187b96e1d3526959459ca0c9e0d618eeede46
app.quarkus.io/build-timestamp: 2024-03-20 - 17:25:36 +0000
labels:
app.kubernetes.io/version: "1.0"
app.kubernetes.io/name: subscription-service
name: subscription-service
spec:
template:
spec:
containers:
- env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRESQL_PASSWORD
name: postgres-secrets
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
key: POSTGRESQL_USER
name: postgres-secrets
- name: POSTGRES_HOST
value: postgres
image: newsletter-subs-service
imagePullPolicy: IfNotPresent
name: subscription-service
securityContext:
runAsNonRoot: true
ports:
- containerPort: 8080
name: http1
protocol: TCP
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- 01-postgres.yaml
- 02-sonataflow-platform.yaml
- 03-newsletter-subs-service.yaml

images:
- name: postgres
newName: postgres
newTag: 13.2-alpine
- name: newsletter-subs-service
newName: quay.io/ricardozanini/sonataflow-newsletter-subs-service
newTag: "2.0"

secretGenerator:
- name: postgres-secrets
options:
disableNameSuffixHash: true
literals:
- POSTGRESQL_USER=sonataflow
- POSTGRESQL_PASSWORD=sonataflow
- POSTGRESQL_DATABASE=sonataflow
- PGDATA=/var/lib/pgsql/data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- "../kubernetes"

images:
- name: postgres
newName: registry.redhat.io/rhel9/postgresql-13
newTag: 1-173
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Use the Kogito service discovery mechanism to get the current service url.
# For more information see: https://kiegroup.github.io/kogito-docs/serverlessworkflow/latest/cloud/kubernetes-service-discovery.html
kogito.service.url=${knative:services.v1.serving.knative.dev/newsletter-showcase/subscription-flow}

# When the application is generated with the knative profile, it'll require a PostgreSQL database.
# Kogito persistence configurations for enabling the serverless workflow persistence
quarkus.datasource.db-kind=postgresql
quarkus.flyway.migrate-at-start=true
kogito.persistence.type=jdbc
kogito.persistence.proto.marshaller=false
kogito.persistence.query.timeout.millis=10000

# The POSTGRES_HOST env var will be generated by quarkus-kubernetes plugin. See below.
quarkus.datasource.jdbc.url=jdbc:postgresql://${POSTGRES_HOST:localhost}:5432/postgres?currentSchema=runtimes
quarkus.datasource.username=postgres
# The POSTGRES_PASSWORD env var will be generated by the quarkus-kubernetes plugin. See below.
quarkus.datasource.password=${POSTGRES_PASSWORD:pass}

# Events produced by kogito-addons-quarkus-jobs-knative-eventing to program the timers on the jobs service.
mp.messaging.outgoing.kogito-job-service-job-request-events.connector=quarkus-http
mp.messaging.outgoing.kogito-job-service-job-request-events.url=${K_SINK:http://localhost:8280/v2/jobs/events}
mp.messaging.outgoing.kogito-job-service-job-request-events.method=POST

kogito.events.usertasks.enabled=false
kogito.events.variables.enabled=false
kogito.addon.messaging.outgoing.cloudEventMode=structured

## Knative integration:

# Use the Kogito service discovery mechanism to get the subscription-service url
# For more information see:
# https://kiegroup.github.io/kogito-docs/serverlessworkflow/latest/cloud/kubernetes-service-discovery.html
quarkus.rest-client.subscription_service_yaml.url=${knative:services.v1.serving.knative.dev/newsletter-showcase/subscription-service}

# Configure current deployment to set an env var with name POSTGRES_HOST
# For more information see: https://quarkus.io/guides/deploying-to-kubernetes#environment-variables-from-keyvalue-pairs
quarkus.knative.env.vars.postgres_host=newsletter-postgres

# Configure current deployment to be linked with the kubernetes secret newsletter-postgres, and to set an env
# var POSTGRES_PASSWORD that will get it's value form the secret entry with key postgrespass.
# For more information see: https://quarkus.io/guides/deploying-to-kubernetes#secret-mapping
#quarkus.knative.env.secrets=newsletter-postgres
#quarkus.knative.env.mapping.postgres_password.from-secret=newsletter-postgres
#quarkus.knative.env.mapping.postgres_password.with-key=postgrespass

# This configuration enables Knative to fetch the image information on Minikube.
# you can change this property with -Pknative -Dquarkus.container-image.group from the command line.
quarkus.container-image.group=dev.local
quarkus.kubernetes.deployment-target=knative
# The name of the application. This value will be used for naming Kubernetes resources like: Deployment, Service, etc.
quarkus.knative.name=subscription-flow
quarkus.container-image.name=${quarkus.knative.name}
quarkus.knative.image-pull-policy=IfNotPresent

# Kogito Knative integration
# We opt to use the Knative objects instead of the Kogito Source.
org.kie.kogito.addons.knative.eventing.generate-kogito-source=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

quarkus.native.native-image-xmx=8g
quarkus.swagger-ui.always-include=true

# Use the Kogito service discovery mechanism to get the current service url.
kogito.service.url=${knative:services.v1.serving.knative.dev/subscription-flow}

quarkus.log.category."org.kie.kogito.addon.quarkus.messaging".level=DEBUG
# Uncomment to use a broader log category.
#quarkus.log.category."org.kie.kogito".level=DEBUG

quarkus.rest-client.subscription_service_yaml.url=${knative:services.v1.serving.knative.dev/subscription-service}

mp.messaging.incoming.kogito_incoming_stream.connector=quarkus-http
mp.messaging.incoming.kogito_incoming_stream.path=/
kogito.addon.messaging.outgoing.cloudEventMode=structured

# The K_SINK variable is automatically injected by the Knative ecosystem. The default value http://localhost:8181
# is used for local testing, which correspond to the event-display local container.
mp.messaging.outgoing.kogito_outgoing_stream.connector=quarkus-http
mp.messaging.outgoing.kogito_outgoing_stream.url=${K_SINK:http://localhost:8181}


kogito.events.usertasks.enabled=false
kogito.events.variables.enabled=false

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
data:
subscription-schema.json: |-
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": [
"email"
]
}
kind: ConfigMap
metadata:
creationTimestamp: null
name: 01-subscription-flow-resources
namespace: newsletter-subscription
Loading
Loading