|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * /applications/connecting_applications_to_services/binding-workloads-using-sbo.adoc |
| 4 | + |
| 5 | +[id="sbo-binding-workloads-that-are-not-compliant-with-PodSpec_{context}"] |
| 6 | += Binding secondary workloads that are not compliant with PodSpec |
| 7 | + |
| 8 | +A typical scenario in service binding involves configuring the backing service, the workload (Deployment), and {servicebinding-title}. Consider a scenario that involves a secondary workload (which can also be an application Operator) that is not compliant with PodSpec and is between the primary workload (Deployment) and {servicebinding-title}. |
| 9 | + |
| 10 | +For such secondary workload resources, the location of the container path is arbitrary. For service binding, if the secondary workload in a CR is not compliant with the PodSpec, you must specify the location of the container path. Doing so projects the binding data into the container path specified in the secondary workload of the `ServiceBinding` CR, for example, when you do not want the binding data inside a pod. |
| 11 | + |
| 12 | +{servicebinding-title} provides an option to configure the value of where the container path or secret path is and bind these paths at a custom location. This option is available only for the `binding.operators.coreos.com` API group when the binding data is projected as environment variables. |
| 13 | + |
| 14 | +=== Configuring the custom location of the container path |
| 15 | +Consider a secondary workload CR, which is not compliant with the PodSpec and has containers located at the `spec.containers` path: |
| 16 | + |
| 17 | +.Example: Secondary workload CR |
| 18 | +[source,yaml] |
| 19 | +---- |
| 20 | +apiVersion: "operator.sbo.com/v1" |
| 21 | +kind: SecondaryWorkload |
| 22 | +metadata: |
| 23 | + name: secondary-workload |
| 24 | +spec: |
| 25 | + containers: |
| 26 | + - name: hello-world |
| 27 | + image: quay.io/baijum/secondary-workload:latest |
| 28 | + ports: |
| 29 | + - containerPort: 9966 |
| 30 | +---- |
| 31 | + |
| 32 | +The following example shows how to configure the `spec.containers` path by specifying a value in the `ServiceBinding` CR and to bind this path to a `spec.application.bindingPath.containersPath` custom location: |
| 33 | + |
| 34 | +.Example: `ServiceBinding` CR with the `spec.containers` path in a custom location |
| 35 | +[source,yaml] |
| 36 | +---- |
| 37 | +apiVersion: binding.operators.coreos.com/v1alpha1 |
| 38 | +kind: ServiceBinding |
| 39 | +metadata: |
| 40 | + name: spring-petclinic-rest |
| 41 | +spec: |
| 42 | + services: |
| 43 | + - group: postgres-operator.crunchydata.com |
| 44 | + version: v1beta1 |
| 45 | + kind: PostgresCluster |
| 46 | + name: hippo |
| 47 | + id: postgresDB |
| 48 | + - group: "" |
| 49 | + version: v1 |
| 50 | + kind: Secret |
| 51 | + name: hippo-pguser-hippo |
| 52 | + id: postgresSecret |
| 53 | + application: <1> |
| 54 | + name: spring-petclinic-rest |
| 55 | + group: apps |
| 56 | + version: v1 |
| 57 | + resource: deployments |
| 58 | + application: <2> |
| 59 | + name: secondary-workload |
| 60 | + group: operator.sbo.com |
| 61 | + version: v1 |
| 62 | + resource: secondaryworkloads |
| 63 | + bindingPath: |
| 64 | + containersPath: spec.containers <3> |
| 65 | +---- |
| 66 | +<1> The sample application that points to a Deployment or any other similar resource with an embedded PodSpec. |
| 67 | +<2> The secondary workload, which is not compliant with the PodSpec. |
| 68 | +<3> The custom location of the container path. |
| 69 | + |
| 70 | +After you specify the location of the container path, {servicebinding-title} generates the binding data, which becomes available in the container path specified in the secondary workload of the `ServiceBinding` CR. |
| 71 | + |
| 72 | +The following example shows the `spec.containers` path with the `envFrom` and `secretRef` fields: |
| 73 | + |
| 74 | +.Example: Secondary workload CR with the `envFrom` and `secretRef` fields |
| 75 | +[source,yaml] |
| 76 | +---- |
| 77 | +apiVersion: "operator.sbo.com/v1" |
| 78 | +kind: SecondaryWorkload |
| 79 | +metadata: |
| 80 | + name: secondary-workload |
| 81 | +spec: |
| 82 | + containers: |
| 83 | + - env: <1> |
| 84 | + - name: ServiceBindingOperatorChangeTriggerEnvVar |
| 85 | + value: "31793" |
| 86 | + envFrom: |
| 87 | + - secretRef: |
| 88 | + name: secret-resource-name <2> |
| 89 | + image: quay.io/baijum/secondary-workload:latest |
| 90 | + name: hello-world |
| 91 | + ports: |
| 92 | + - containerPort: 9966 |
| 93 | + resources: {} |
| 94 | +---- |
| 95 | +<1> Unique array of containers with values generated by the {servicebinding-title}. These values are based on the backing service CR. |
| 96 | +<2> Name of the `Secret` resource generated by the {servicebinding-title}. |
| 97 | + |
| 98 | +=== Configuring the custom location of the secret path |
| 99 | +Consider a secondary workload CR, which is not compliant with the PodSpec, with only the secret at the `spec.secret` path: |
| 100 | + |
| 101 | +.Example: Secondary workload CR |
| 102 | +[source,yaml] |
| 103 | +---- |
| 104 | +apiVersion: "operator.sbo.com/v1" |
| 105 | +kind: SecondaryWorkload |
| 106 | +metadata: |
| 107 | + name: secondary-workload |
| 108 | +spec: |
| 109 | + secret: "" |
| 110 | +---- |
| 111 | + |
| 112 | +The following example shows how to configure the `spec.secret` path by specifying a value in the `ServiceBinding` CR and to bind this path at a `spec.application.bindingPath.secretPath` custom location: |
| 113 | + |
| 114 | +.Example: `ServiceBinding` CR with the `spec.secret` path in a custom location |
| 115 | +[source,yaml] |
| 116 | +---- |
| 117 | +apiVersion: binding.operators.coreos.com/v1alpha1 |
| 118 | +kind: ServiceBinding |
| 119 | +metadata: |
| 120 | + name: spring-petclinic-rest |
| 121 | +spec: |
| 122 | +... |
| 123 | + application: <1> |
| 124 | + name: secondary-workload |
| 125 | + group: operator.sbo.com |
| 126 | + version: v1 |
| 127 | + resource: secondaryworkloads |
| 128 | + bindingPath: |
| 129 | + secretPath: spec.secret <2> |
| 130 | +... |
| 131 | +---- |
| 132 | +<1> The secondary workload, which is not compliant with the PodSpec. |
| 133 | +<2> The custom location of the secret path that contains the name of the `Secret` resource. |
| 134 | + |
| 135 | +After you specify the location of the secret path, {servicebinding-title} generates the binding data, which becomes available in the secret path specified in the secondary workload of the `ServiceBinding` CR. |
| 136 | + |
| 137 | +The following example shows the `spec.secret` path with the `binding-request` value: |
| 138 | + |
| 139 | +.Example: Secondary workload CR with the `binding-request` value |
| 140 | +[source,yaml] |
| 141 | +---- |
| 142 | +... |
| 143 | +apiVersion: "operator.sbo.com/v1" |
| 144 | +kind: SecondaryWorkload |
| 145 | +metadata: |
| 146 | + name: secondary-workload |
| 147 | +spec: |
| 148 | + secret: binding-request-72ddc0c540ab3a290e138726940591debf14c581 <1> |
| 149 | +... |
| 150 | +---- |
| 151 | +<1> Unique name of the `Secret` resource generated by the {servicebinding-title}. |
0 commit comments