Generate resources in policy is similar to trait, policy can be used to define things across components.
vela def init to create a basic policy scaffold:
The content of the scaffold expected to be:
The rule is align with component definition, you must specify
output, while you can use
outputs for more objects, the format as below:
Below is an example that we create a traffic split service mesh object in policy.
Apply to our control plane to make this trait work:
Then our end users can discover it immediately and use it in
vela up by the following command:
The policy will generate Kubernetes resources by KubeVela like below:
You can define any Kubernetes API objects in policies if you want.
Not all policies generate resources, there're several built-in policies which are used to control the whole delivery precess and workflows. These special polices are usually coded in the application controller.