Introduction
In the realm of automation, a recipe serves as a powerful procedure for backup and restore operations. However, its effectiveness hinges on its ability to be applied across various applications. Without a generic approach, the utility of such recipes diminishes significantly. In this blog post, we'll delve into the concept of creating a generic recipe that can be adapted to different applications, ensuring feasibility and versatility.
Background
Fusion recipe is a custom resource (CR) that encapsulates one or more application resources within groups. Having multiple groups in the Recipe offers several advantages, such as providing fine-grained control over the application, arranging resources in a logical order, and facilitating the execution of similar operations together, among other benefits. Therefore, the creation of appropriate groups holds significant importance in preserving the application details within the Fusion Recipe.
In this blog, how to create a first recipe is explained briefly, but it is not generic. Why is that?
apiVersion: spp-data-protection.isf.ibm.com/v1alpha1
kind: Recipe metadata:
name: filebrowser-simple-recipe
namespace: ibm-spectrum-fusion-ns
spec:
appType: filebrowser
groups:
...
- name: filebrowser_resources
type: resource
includedNamespaces:
- filebrowser
hooks:
- name: backup-hook
type: exec
namespace: filebrowser
...
Notice the namespace i.e., filebrowser
is hardcoded . What if our application is deployed in a different namespace? In that case, this recipe won’t be able to take backup.
To make it generic, we can do the following things:
1. 1. In groups, includedNamespaces
are not mandatory. So, how will it work then? The answer is: When we assign the policy to an application for backup and restore, that policy is updated with this recipe. Therefore, when this recipe gets executed automatically, it picks up the namespace where the application is deployed.
To get the policy assignment details :
oc get fpa -n ibm-spectrum-fusion-ns
2. 2. In hooks, the namespace
is mandatory. So, how do we make it generic? The answer is: ${GROUP.filebrowser_resources.namespace}
. This will pick up the namespace assigned to the group filebrowser_resources.
Now, your final generic recipe will look like this:
apiVersion: spp-data-protection.isf.ibm.com/v1alpha1
kind: Recipe metadata:
name: filebrowser-simple-recipe
namespace: ibm-spectrum-fusion-ns
spec:
appType: filebrowser
groups:
...
- name: filebrowser_resources
type: resource
hooks:
- name: backup-hook
type: exec
namespace: {GROUP.filebrowser_resources.namespace}
...
In Conclusion, some applications will require application specific logic in the recipe, and you might need to have more specific recipes, but a generic recipe is a good starting point.