-
Notifications
You must be signed in to change notification settings - Fork 1.1k
`apply` Command
--resources (-r) → pass the path for resource file/folder
--set (-s) → pass the value for variable present in the policy (currently supports, single policy applied on single resource)
--values-file (-f) → pass the variables file
--output (-o) → pass the path of file/folder to print the mutated resource (in case of mutate policy)
--policy-report → this generates the policy report
--cluster (-c) → to apply the policy on the resources present in cluster
--namespace (-n) → pass this parameter to filter the resources in cluster
--stdin (-i) → pass this parameter to apply the mutated resource on the cluster
-
Get the variables from the terminal/file →
common.GetVariable -
Get the policies from the passed policy path →
common.GetPoliciesFromPaths -
Mutate the policies →
common.MutatePolices→ includes - ValidationFailureAction, Background, auto-gen annotation and rules -
Get the resources from the passed resource path →
common.GetResourceAccordingToResourcePath -
Validate the policy →
policy2.Validate-
If the policy is not valid add it in skip count and go for next policy
-
If policy is valid
-
check for variables in the policy and relevant variable file passed
-
if not add the policy in skipped policies and go for next policy
-
-
-
Now we apply this policy to each resource
-
Add resource, namespace selector and other variables to the context
-
Call
engine.Mutateand which gives mutated response-
If response is not successful, print the failed message
-
Else print the mutated resource in the terminal or in the output format(file/folder) provided by the user
-
-
We use this mutated resource from mutated response, ctx, policy to build policy context.
-
We Call
engine.Validateand get the validate response.-
If validate response is not successful then we print the failure message
-
Else continue the process
-
-
If policy contains generate block then
-
Build policy context and
-
engine.Generateis called which gives generate response -
Based on generate response success we print passed/failed.
-
-
If user has passed policy-report flag, build a policy report and print it, else print the counts for
pass,fail, etc…
policy2.Validate - This takes care about the following validation:
-
Policy have valid variables
-
Rules have unique name
-
Validates the rule type(validate, mutate, generate)
-
Conflicts between the match and exclude block
engine.Mutate - This creates a handler based on the type of mutate policy i.e, overly, Strategic Merge Patch and RFC 6902 JSONPatch. And accordingly process the resource and return the response accordingly.
engine.Validate - This checks for the pattern/deny in the policy and accordingly validates the resource.
engine.Generate - This will check for validity of the generate rule on the resource and returns the list of rules that are applicable on it.
THIS WIKI IS NO LONGER MAINTAINED
For developer guides please see the DEVELOPMENT.md file.
For user guides please see https://kyverno.io/docs/.
THIS WIKI IS NO LONGER MAINTAINED
For developer guides please see the DEVELOPMENT.md file.
For user guides please see https://kyverno.io/docs/.