A transport middleware working in clientside for client-go to mutate any k8s resource via (Cluster)OverridePolicy.
If you want to use it in serverside as a webhook, please use https://github.com/k-cloud-labs/kinitiras.
kubectl apply -f https://raw.githubusercontent.com/k-cloud-labs/pkg/main/charts/_crds/bases/policy.kcloudlabs.io_overridepolicies.yaml
kubectl apply -f https://raw.githubusercontent.com/k-cloud-labs/pkg/main/charts/_crds/bases/policy.kcloudlabs.io_clusteroverridepolicies.yaml
OverridePolicy is used to mutate object in the same namespace.
ClusterOverridePolicy can mutate object in any namespace.
For cluster scoped resource:
- Apply ClusterOverridePolicy by policies name in ascending;
For namespaced scoped resource, apply order is:
- First apply ClusterOverridePolicy;
- Then apply OverridePolicy;
What you need to do is just call RegisterPolicyTransport
func after rest.Config
initialized and before client to initialize.
import(
"github.com/k-cloud-labs/pidalio"
)
// the black magic code
pidalio.RegisterPolicyTransport(config, make(chan struct{}))
- Support mutate k8s resource by (Cluster)OverridePolicy via plaintext jsonpatch.
- Support mutate k8s resource by (Cluster)OverridePolicy programmable via CUE.
- Support render template to cue in transport(even policy is not created by others)