|
| 1 | +:_mod-docs-content-type: PROCEDURE |
| 2 | + |
| 3 | +[id="proc-troubleshoot-sonataflow-cross-namespace-issues_{context}"] |
| 4 | += Troubleshooting cross-namespace SonataFlow configuration and deployment issues |
| 5 | + |
| 6 | +Use this procedure to resolve configuration and deployment failures when SonataFlow workflows are installed in a namespace separate from the core services, or if the Data Index fails to connect to the PostgreSQL database. |
| 7 | + |
| 8 | +.Prerequisites |
| 9 | +* You have administrator privileges to access the OpenShift cluster. |
| 10 | + |
| 11 | +.Procedure |
| 12 | + |
| 13 | +. Identify required namespaces. |
| 14 | + |
| 15 | +* Retrieve the namespace value where {product-very-short} is running using `oc get backstage -A`. |
| 16 | + |
| 17 | +* Identify the SonataFlow Services Namespace by checking for either a `sonataflowclusterplatform` or `sonataflowplatform` instance. |
| 18 | ++ |
| 19 | +[NOTE] |
| 20 | +==== |
| 21 | +By default, the SonataFlow namespace must be the same as the {product-very-short} namespace. |
| 22 | +==== |
| 23 | + |
| 24 | +. If the workflow is deployed to a namespace outside the core SonataFlow services, configure network policies to permit the necessary inter-namespace traffic. |
| 25 | ++ |
| 26 | +[source,subs="+attributes,+quotes"] |
| 27 | +---- |
| 28 | +# Example `NetworkPolicy` configuration to ingress traffic into the workflow namespace |
| 29 | +apiVersion: networking.k8s.io/v1 |
| 30 | +kind: NetworkPolicy |
| 31 | +metadata: |
| 32 | + name: {{ .Release.Name }}-allow-infra-ns-to-workflow-ns |
| 33 | + # Sonataflow and Workflows are using the {product-very-short} target namespace. |
| 34 | + namespace: {{ .Release.Namespace | quote }} |
| 35 | +spec: |
| 36 | + podSelector: {} |
| 37 | + ingress: |
| 38 | + - from: |
| 39 | + - namespaceSelector: |
| 40 | + matchLabels: |
| 41 | + # Allow knative events to be delivered to workflows. |
| 42 | + kubernetes.io/metadata.name: knative-eventing |
| 43 | + - namespaceSelector: |
| 44 | + matchLabels: |
| 45 | + # Allow auxiliary knative function for workflow (such as m2k-save-transformation) |
| 46 | + kubernetes.io/metadata.name: knative-serving |
| 47 | + - namespaceSelector: |
| 48 | + matchLabels: |
| 49 | + # Allow communication between the serverless logic operator and the workflow namespace. |
| 50 | + kubernetes.io/metadata.name: openshift-serverless-logic |
| 51 | +---- |
| 52 | + |
| 53 | +. Add `SonataFlowClusterPlatform` Custom Resource as shown in the following configuration: |
| 54 | ++ |
| 55 | +[source,yaml] |
| 56 | +---- |
| 57 | +oc create -f - <<EOF |
| 58 | +apiVersion: sonataflow.org/v1alpha08 |
| 59 | +kind: SonataFlowClusterPlatform |
| 60 | +metadata: |
| 61 | + name: cluster-platform |
| 62 | +spec: |
| 63 | + platformRef: |
| 64 | + name: sonataflow-platform |
| 65 | + namespace: $RHDH_NAMESPACE |
| 66 | +---- |
| 67 | + |
| 68 | +. To allow communication between {product-very-short} namespace and the workflow namespace, create the following network policies: |
| 69 | + |
| 70 | +.. Allow {product-very-short} services to accept traffic from workflows. Create an additional network policy within the {product-very-short} instance namespace as shown in the following configuration:: |
| 71 | ++ |
| 72 | +[source,yaml] |
| 73 | +---- |
| 74 | +oc create -f - <<EOF |
| 75 | +apiVersion: networking.k8s.io/v1 |
| 76 | +kind: NetworkPolicy |
| 77 | +metadata: |
| 78 | + name: allow-external-workflows-to-rhdh |
| 79 | + # Namespace where network policies are deployed |
| 80 | + namespace: $RHDH_NAMESPACE |
| 81 | +spec: |
| 82 | + podSelector: {} |
| 83 | + ingress: |
| 84 | + - from: |
| 85 | + - namespaceSelector: |
| 86 | + matchLabels: |
| 87 | + # Allow SonataFlow services to communicate with new/additional workflow namespace. |
| 88 | + kubernetes.io/metadata.name: $ADDITIONAL_WORKFLOW_NAMESPACE |
| 89 | +---- |
| 90 | + |
| 91 | +.. Allow traffic from {product-very-short}, SonataFlow and Knative. Create a network policy within the additional workflow namespace as shown in the following configuration: |
| 92 | ++ |
| 93 | +[source,yaml] |
| 94 | +---- |
| 95 | +oc create -f - <<EOF |
| 96 | +apiVersion: networking.k8s.io/v1 |
| 97 | +kind: NetworkPolicy |
| 98 | +metadata: |
| 99 | + name: allow-rhdh-and-knative-to-workflows |
| 100 | + namespace: $ADDITIONAL_WORKFLOW_NAMESPACE |
| 101 | +spec: |
| 102 | + podSelector: {} |
| 103 | + ingress: |
| 104 | + - from: |
| 105 | + - namespaceSelector: |
| 106 | + matchLabels: |
| 107 | + # Allows traffic from pods in the {product-very-short} namespace. |
| 108 | + kubernetes.io/metadata.name: $RHDH_NAMESPACE |
| 109 | + - namespaceSelector: |
| 110 | + matchLabels: |
| 111 | + # Allows traffic from pods in the Knative Eventing namespace. |
| 112 | + kubernetes.io/metadata.name: knative-eventing |
| 113 | + - namespaceSelector: |
| 114 | + matchLabels: |
| 115 | + # Allows traffic from pods in the Knative Serving namespace. |
| 116 | + kubernetes.io/metadata.name: knative-serving |
| 117 | +---- |
| 118 | + |
| 119 | +. (Optional) Create an `allow-intra-namespace` policy in the workflow namespace to enable unrestricted communication among all pods within that namespace. |
| 120 | + |
| 121 | +. If workflow persistence is required, perform the following configuration steps: |
| 122 | + |
| 123 | +.. Create a dedicated PostgreSQL Secret containing database credentials within the workflow namespace as shown in the following configuration: |
| 124 | ++ |
| 125 | +[source,yaml] |
| 126 | +---- |
| 127 | +oc get secret sonataflow-psql-postgresql -n <your_namespace> -o yaml > secret.yaml |
| 128 | +sed -i '/namespace: <your_namespace>/d' secret.yaml |
| 129 | +oc apply -f secret.yaml -n $ADDITIONAL_NAMESPACE |
| 130 | +---- |
| 131 | + |
| 132 | +.. Configure the workflow `serviceRef` property to correctly reference the PostgreSQL service namespace as shown in the following configuration: |
| 133 | ++ |
| 134 | +[source,yaml] |
| 135 | +---- |
| 136 | +apiVersion: sonataflow.org/v1alpha08 |
| 137 | +kind: SonataFlow |
| 138 | + ... |
| 139 | +spec: |
| 140 | + ... |
| 141 | + persistence: |
| 142 | + postgresql: |
| 143 | + secretRef: |
| 144 | + name: sonataflow-psql-postgresql |
| 145 | + passwordKey: postgres-password |
| 146 | + userKey: postgres-username |
| 147 | + serviceRef: |
| 148 | + databaseName: sonataflow |
| 149 | + databaseSchema: greeting |
| 150 | + name: sonataflow-psql-postgresql |
| 151 | + namespace: $POSTGRESQL_NAMESPACE |
| 152 | + port: 5432 |
| 153 | +---- |
| 154 | ++ |
| 155 | +`namespace`:: |
| 156 | +Enter the namespace where the PostgreSQL server is deployed. |
| 157 | + |
| 158 | +. If the `sonataflow-platform-data-index-service` cannot connect to the PostgreSQL database on startup, perform the following diagnostic checks: |
| 159 | + |
| 160 | +.. Verify that the PostgreSQL Pod has fully transitioned to a `running` and operational status. |
| 161 | +Allow additional time for database initialization before expecting related service pods (`DataIndex`, `JobService`) to establish a connection. |
| 162 | + |
| 163 | +.. If the PostgreSQL Server operates in a dedicated namespace (for example, outside {product-very-short}), verify that network policies are configured to allow ingress traffic from the SonataFlow services namespace. Network policies might prevent the Data Index and Job Service pods from connecting to the database. |
0 commit comments