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

KOGITO-9971: Adding Data-index with operator use cases #1839

Merged
merged 3 commits into from
Dec 12, 2023
Merged
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
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:13.2-alpine
imagePullPolicy: 'IfNotPresent'
ports:
- containerPort: 5432
volumeMounts:
- name: storage
mountPath: /var/lib/postgresql/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,92 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: data-index-service-postgresql
name: data-index-service-postgresql
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: data-index-service-postgresql
template:
metadata:
labels:
app.kubernetes.io/name: data-index-service-postgresql
spec:
containers:
- name: data-index-service-postgresql
image: quay.io/kiegroup/kogito-data-index-postgresql:latest
imagePullPolicy: Always
resources:
limits:
memory: "256Mi"
cpu: "500m"
ports:
- containerPort: 8080
name: http
protocol: TCP
env:
- name: KOGITO_DATA_INDEX_QUARKUS_PROFILE
value: http-events-support
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: QUARKUS_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgres-secrets
- name: QUARKUS_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgres-secrets
volumeMounts:
- name: application-config
mountPath: "/home/kogito/config"
livenessProbe:
failureThreshold: 3
httpGet:
path: /q/health/live
port: 8080
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 10
readinessProbe:
failureThreshold: 3
httpGet:
path: /q/health/ready
port: 8080
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 10
volumes:
- name: application-config
configMap:
name: dataindex-properties
initContainers:
- name: init-postgres
image: registry.access.redhat.com/ubi9/ubi-minimal: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;']
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: data-index-service-postgresql
name: data-index-service-postgresql
spec:
ports:
- name: http
port: 80
targetPort: 8080
selector:
app.kubernetes.io/name: data-index-service-postgresql
type: NodePort
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
quarkus.http.port=8080
quarkus.http.cors=true
quarkus.http.cors.origins=/.*/

quarkus.datasource.jdbc.url=jdbc:postgresql://postgres:5432/sonataflow?currentSchema=data-index-service
quarkus.hibernate-orm.database.generation=update
quarkus.flyway.migrate-at-start=true

# Disable kafka client health check since the quarkus-http connector is being used instead.
quarkus.smallrye-health.check."io.quarkus.kafka.client.health.KafkaHealthCheck".enabled=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resources:
- 01-postgres.yaml
- 02-dataindex.yaml

secretGenerator:
- name: postgres-secrets
literals:
- POSTGRES_USER=sonataflow
- POSTGRES_PASSWORD=sonataflow
- POSTGRES_DB=sonataflow
- PGDATA=/var/lib/postgresql/data/mydata

configMapGenerator:
- name: dataindex-properties
files:
- application.properties

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: service-discovery-role
rules:
- apiGroups:
- ""
resources:
- pods
- services
verbs:
- get
- list
- apiGroups:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
# Knative
- apiGroups:
- serving.knative.dev
resources:
- services
verbs:
- get
- list
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: service-discovery-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: service-discovery-role
subjects:
- kind: ServiceAccount
name: default
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- 01-service-discovery-role.yaml
- 02-service-discovery-rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- ../../infra/service_discovery
- ../../workflows/sonataflow-greeting
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- ../../infra/service_discovery
- ../../workflows/sonataflow-greeting
- ../../workflows/sonataflow-helloworld
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
data:
application.properties: |
# Data Index configuration
mp.messaging.outgoing.kogito-processinstances-events.url=http://data-index-service-postgresql/processes

mp.messaging.outgoing.kogito-usertaskinstances-events.url=http://data-index-service-postgresql/tasks

mp.messaging.outgoing.kogito-variables-events.url=http://data-index-service-postgresql/variables

# Skip user tasks and variables events sending.
kogito.events.usertasks.enabled=false
kogito.events.variables.enabled=false

quarkus.log.category."io.smallrye.reactive.messaging".level = DEBUG
quarkus.log.category."org.kie".level = DEBUG
quarkus.log.category."io.quarkus.reactivemessaging".level = DEBUG
quarkus.log.category."io.vertx".level = DEBUG
kind: ConfigMap
metadata:
labels:
app: greeting
name: greeting-props
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
name: greeting
annotations:
sonataflow.org/description: Greeting example on k8s!
sonataflow.org/version: 0.0.1
spec:
flow:
start: ChooseOnLanguage
functions:
- name: greetFunction
type: custom
operation: sysout
states:
- name: ChooseOnLanguage
type: switch
dataConditions:
- condition: "${ .language == \"English\" }"
transition: GreetInEnglish
- condition: "${ .language == \"Spanish\" }"
transition: GreetInSpanish
defaultCondition: GreetInEnglish
- name: GreetInEnglish
type: inject
data:
greeting: "Hello from JSON Workflow, "
transition: GreetPerson
- name: GreetInSpanish
type: inject
data:
greeting: "Saludos desde JSON Workflow, "
transition: GreetPerson
- name: GreetPerson
type: operation
actions:
- name: greetAction
functionRef:
refName: greetFunction
arguments:
message: ".greeting+.name"
end: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- 02-configmap_greeting-props.yaml
- 03-sonataflow_greeting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
data:
application.properties: |
# Data Index configuration
mp.messaging.outgoing.kogito-processinstances-events.url=http://data-index-service-postgresql/processes

mp.messaging.outgoing.kogito-usertaskinstances-events.url=http://data-index-service-postgresql/tasks

mp.messaging.outgoing.kogito-variables-events.url=http://data-index-service-postgresql/variables

# Skip user tasks and variables events sending.
kogito.events.usertasks.enabled=false
kogito.events.variables.enabled=false

quarkus.log.category."io.smallrye.reactive.messaging".level = DEBUG
quarkus.log.category."org.kie".level = DEBUG
quarkus.log.category."io.quarkus.reactivemessaging".level = DEBUG
quarkus.log.category."io.vertx".level = DEBUG
kind: ConfigMap
metadata:
labels:
app: helloworld
name: helloworld-props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
name: helloworld
annotations:
sonataflow.org/description: Hello World Workflow
sonataflow.org/version: 0.0.1
spec:
flow:
start: Inject Hello World
states:
- name: Inject Hello World
type: inject
data:
greeting: Hello World
transition: Inject Mantra
- name: Inject Mantra
type: inject
data:
mantra: Serverless Workflow is awesome!
end: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- 02-configmap_helloworld-props.yaml
- 03-sonataflow_helloworld.yaml