-
Notifications
You must be signed in to change notification settings - Fork 4
KOGITO-9800: [operator use case] Singleton Jobs Service per Namespace #3
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
Merged
ricardozanini
merged 2 commits into
flows-examples:main
from
wmedvede:singleton-jobs-service-per-namespace
Sep 15, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: jobs-service-postgresql | ||
name: jobs-service-postgresql | ||
spec: | ||
replicas: 1 | ||
# remove after https://issues.redhat.com/browse/KOGITO-8311 is done | ||
strategy: | ||
type: Recreate | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: jobs-service-postgresql | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: jobs-service-postgresql | ||
spec: | ||
containers: | ||
- name: jobs-service-postgresql | ||
image: quay.io/kiegroup/kogito-jobs-service-allinone:latest | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
env: | ||
- name: JOBS_SERVICE_PERSISTENCE | ||
value: postgresql | ||
- 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: jobs-service-properties | ||
initContainers: | ||
- name: init-postgres | ||
image: busybox:1.36 | ||
imagePullPolicy: IfNotPresent | ||
command: ['sh', '-c', 'until nc -vz postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local 5432; do echo "Waiting for postgres server"; sleep 3; done;'] | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: jobs-service-postgresql | ||
name: jobs-service-postgresql | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: 8080 | ||
selector: | ||
app.kubernetes.io/name: jobs-service-postgresql | ||
type: NodePort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
kogito.service.url=http://jobs-service-postgresql | ||
|
||
quarkus.datasource.jdbc.url=jdbc:postgresql://postgres:5432/sonataflow?currentSchema=jobs-service | ||
quarkus.datasource.reactive.url=postgresql://postgres:5432/sonataflow?search_path=jobs-service | ||
|
||
# Enable the job status change events notification. | ||
kogito.jobs-service.http.job-status-change-events=true | ||
# Deliver the job status change events directly to the data-index-service-postgresql. | ||
mp.messaging.outgoing.kogito-job-service-job-status-events-http.url=http://data-index-service-postgresql/jobs | ||
# Disable the K_SINK injection health check since we knative eventing is not being used. | ||
quarkus.smallrye-health.check."org.kie.kogito.jobs.service.messaging.http.health.knative.KSinkInjectionHealthCheck".enabled=false | ||
# if you use env variables you must use this env var instead. | ||
#QUARKUS_SMALLRYE_HEALTH_CHECK__ORG_KIE_KOGITO_JOBS_SERVICE_MESSAGING_HTTP_HEALTH_KNATIVE_KSINKINJECTIONHEALTHCHECK__ENABLED=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resources: | ||
- ../dataindex | ||
- 03-jobservice.yml | ||
|
||
configMapGenerator: | ||
- name: jobs-service-properties | ||
ricardozanini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
files: | ||
- application.properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
11 changes: 11 additions & 0 deletions
11
infra/service_discovery/02-service-discovery-rolebinding.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
13 changes: 13 additions & 0 deletions
13
platforms/dataindex_and_jobservice_platform/01-sonataflow_platform.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: sonataflow.org/v1alpha08 | ||
kind: SonataFlowPlatform | ||
metadata: | ||
name: sonataflow-platform | ||
spec: | ||
build: | ||
template: | ||
buildArgs: | ||
- name: QUARKUS_EXTENSIONS | ||
value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:2.0.0-SNAPSHOT | ||
config: | ||
strategyOptions: | ||
KanikoBuildCacheEnabled: "true" |
2 changes: 2 additions & 0 deletions
2
platforms/dataindex_and_jobservice_platform/kustomization.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- 01-sonataflow_platform.yaml |
13 changes: 13 additions & 0 deletions
13
platforms/dataindex_and_jobservice_platform_persistence/01-sonataflow_platform.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: sonataflow.org/v1alpha08 | ||
kind: SonataFlowPlatform | ||
metadata: | ||
name: sonataflow-platform | ||
spec: | ||
build: | ||
template: | ||
buildArgs: | ||
- name: QUARKUS_EXTENSIONS | ||
value: org.kie.kogito:kogito-addons-quarkus-jobs-knative-eventing:2.0.0-SNAPSHOT,org.kie.kogito:kogito-addons-quarkus-persistence-jdbc:2.0.0-SNAPSHOT,io.quarkus:quarkus-jdbc-postgresql:2.16.10.Final,io.quarkus:quarkus-agroal:2.16.10.Final | ||
config: | ||
strategyOptions: | ||
KanikoBuildCacheEnabled: "true" |
2 changes: 2 additions & 0 deletions
2
platforms/dataindex_and_jobservice_platform_persistence/kustomization.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- 01-sonataflow_platform.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: sonataflow.org/v1alpha08 | ||
kind: SonataFlowPlatform | ||
metadata: | ||
name: sonataflow-platform | ||
spec: | ||
build: | ||
# kogito-swf-builder and kogito-swf-builder-nightly images already adds: | ||
# kogito-addons-quarkus-events-process and kogito-addons-quarkus-process-management | ||
# we shouldn't need to add them again, unless we want to protect from future changes on these images. | ||
# template: | ||
# buildArgs: | ||
# - name: QUARKUS_EXTENSIONS | ||
# value: org.kie.kogito:kogito-addons-quarkus-events-process:2.0.0-SNAPSHOT,org.kie.kogito:kogito-addons-quarkus-process-management:2.0.0-SNAPSHOT | ||
config: | ||
strategyOptions: | ||
KanikoBuildCacheEnabled: "true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
resources: | ||
- 01-sonataflow_platform.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources: | ||
- ../../platforms/dataindex_platform | ||
- ../../infra/service_discovery | ||
- ../../workflows/sonataflow-greeting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resources: | ||
- ../../platforms/dataindex_platform | ||
- ../../infra/service_discovery | ||
- ../../workflows/sonataflow-greeting | ||
- ../../workflows/sonataflow-helloworld |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources: | ||
- ../../platforms/dataindex_and_jobservice_platform_persistence | ||
- ../../infra/service_discovery | ||
- ../../workflows/sonataflow-callbackstatetimeouts-persistence |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources: | ||
- ../../platforms/dataindex_and_jobservice_platform | ||
- ../../infra/service_discovery | ||
- ../../workflows/sonataflow-callbackstatetimeouts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resources: | ||
- ../../platforms/dataindex_and_jobservice_platform | ||
- ../../infra/service_discovery | ||
- ../../workflows/sonataflow-greeting | ||
- ../../workflows/sonataflow-callbackstatetimeouts | ||
- ../../workflows/sonataflow-workflowtimeouts |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, can we use Startup probes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if a startup probe will help here, what we need to check, is that, before the jobs-service initialization begins, the postgres service is available. And this is what the init-postgres init container is trying to do.
But, a startup prob, won't prevent the jobs-service container to wait for the postgres service to start , instead, the jobs-service container will just start, and if the postgres service is not there yet, it'll just fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is that for prod, we can't use
busybox
. The Quarkus Health checks won't ping the postgres service?