On this page you can find additional information, learnings, solutions to daily problems.
1 - Adopt existing resources
Adopt service instances
To adopt an existing Cloud Foundry instance, create a Kubernetes ServiceInstance object that specifies the spec.name
with the name of the existing Cloud Foundry instance and provides the offering, plans, parameters, and tags matching the current state.
Such as:
apiVersion: cf.cs.sap.com/v1alpha1
kind: ServiceInstance
metadata:
name: example-instance
namespace: demo
spec:
# Name of a Space object in the same namespace;
# this defines the Cloud Foundry space where the instance will be created
spaceName: k8s
# Name of service offering to be used
serviceOfferingName: xsuaa
# Name of service plan to be used
servicePlanName: standard
# Explicitly specify the name of the Cloud Foundry instance
name: <cf instance name>
# Current paremeters (if any)
parameters:
...
# Current tags (if any)
tags:
...
After deploying this object, it will enter an error state, complaining that an instance with the same name already exists in Cloud Foundry, but is not managed by the controller.
Check the status of the Instance. The following error is expected:
cfclient error (CF-UnprocessableEntity|10008): The service instance name is taken
To solve this, the Cloud Foundry metadata of the existing instance must be updated.
More information about how this controller leverages Cloud Foundry metadata can be found here.
The CF Service Operator provides a way to adopt orphan instances via a Kubernetes Annotation.
Using the annotations adopt-cf-resources
An automated way of adopting Cloud Foundry instance is via the Kuberneste annotation service-operator.cf.cs.sap.com/adopt-cf-resources
.
During the reconciliation of an orphan ServiceInstance and ServiceBinding custom resource, the controller will check if this annotation is present. If the annotation is found then the controller will try to update the Cloud Foundry instance with label service-operator.cf.cs.sap.com/owner
, and the annotations service-operator.cf.cs.sap.com/generation
and service-operator.cf.cs.sap.com/parameter-hash
Here’s an example of how to use this annotation in a ServiceInstance and ServiceBinding:
apiVersion: cf.cs.sap.com/v1alpha1
kind: ServiceInstance
metadata:
name: example-instance
namespace: demo
annotations:
service-operator.cf.cs.sap.com/adopt-cf-resources: "adopt"
spec:
spaceName: k8s
serviceOfferingName: xsuaa
servicePlanName: standard
apiVersion: cf.cs.sap.com/v1alpha1
kind: ServiceBinding
metadata:
name: example-binding-instance
namespace: demo
annotations:
service-operator.cf.cs.sap.com/adopt-cf-resources: "adopt"
spec:
serviceInstanceName: example-instance
After some time the controller will consider the ServiceInstance and ServiceBinding as managed.
2 - Annotations
Annotation Polling Interval Ready
The AnnotationPollingIntervalReady annotation is used to specify the duration of the requeue after interval at which the operator polls the status of a Custom Resource after final state ready. It is possible to apply this annotations to Space, ServiceInstance and ServiceBiding CRs.
By using this annotation, the code allows for flexible configuration of the polling interval, making it easier to adjust the readiness checking frequency based on specific requirements or conditions.
The value of the annotation is a string representing a duration, such as “100m” or “5h”.
Usage:
apiVersion: cf.cs.sap.com/v1alpha1
kind: ServiceInstance
metadata:
annotations:
service-operator.cf.cs.sap.com/polling-interval-ready: "3h"
In the example above the custom resource will be reconcile every three hours after reaching the state Ready.
Default Requeue After Interval
If the annotation AnnotationPollingIntervalReady is not set, the interval duration will be set to 10 minutes by default.
Annotation Polling Interval Fail
The AnnotationPollingIntervalFail annotation is used to specify the duration of the requeue interval at which the operator polls the status of a Custom Resource after the final states Creation Failed and Deletion Failed. Currently it is possible to apply this annotations to ServiceInstance custom resource only.
By using this annotation, the code allows for flexible configuration of the polling interval, making it easier to adjust the re-queue frequency after the failure based on specific requirements or conditions.
The value of the annotation is a string representing a duration, such as “20s” or “10m”.
Usage:
apiVersion: cf.cs.sap.com/v1alpha1
kind: ServiceInstance
metadata:
annotations:
service-operator.cf.cs.sap.com/polling-interval-fail: "5m"
In the example above the custom resource will be reconcile every five minutes after reaching the final state Failed.
Default Requeue After Interval
If the annotation AnnotationPollingIntervalFail is not set, there won’t be an immediate requeue. This means the resource will not be re-reconciled right away. The operator will consider the custom resource to be in a stable state, at least for now.
That means there is no default time duration for it, and it will return an empty result, ctrl.Result{}.