Ability to generate a valid prune-whitelist for existing cluster & bootstrap repo.
In order to use oc apply --prune with an OpenShift cluster, we need to extend the set of APIs that the --prune flag will act on. By default it is a static set of Kubernetes core apis. Right now we are handling this statically in a text file in the repo, but it would be better to generate a list of <Group/Version/Kind>s based on the cluster we are targetting and the set of resources we are managing.
I am looking at this. @etsauer are you saying that we should have an ability to create the manifest.yaml file based on the cluster that we are managing? and should the file be created automatically using a tool (that we need to investigate or develop) or command? Or this is basically a test that we want to do.
@etsauer Just to clarify. The script that we need to create will go through all flags within the prune-whitelist.txt file and apply all of that at the end of the command. Example:
The command we need to execute:
oc apply -f manifest.yaml --prune --all
--prune-whitelist core/v1/ConfigMap
--prune-whitelist core/v1/Endpoints
....
--prune-whitelist redhatcop.redhat.io/v1alpha1/NamespaceConfig
The script can be executed like this: sh applyPruning.sh -m manifest.yaml -p prune-whitelist.txt
@FWCoder no, we want the script to replace the prune-whitelist.txt, by querying the cluster and figuring out what API resource types are currently provided in the given cluster.
So, rather than maintaining a static prune-whitelist.txt in the repo, we want a script that can generate a set of --prune-whitelist core/v1/ConfigMap type flags to feed to oc apply --prune.
As I see it, this script would likely be written around some combination of oc api-resources and oc api-versions.
@sabre1041 any other ideas on how to approach this?