• Kubernetes Submit Queue's avatar
    Merge pull request #35220 from MrHohn/kubectl-apply-type · e4edd817
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Implement --prune-whitelist(-w) flag to overwrite default whitelist for --prune
    
    From #34274.
    
    Updates:
    
    As suggested, the new commits implement a default whitelist for `kubectl apply --prune`, which could be overwritten by using `--prune-whitelist`or `-w` flag. The default whitelist and example as below.
    
    Also supports `--dry-run` for `--prune` to fix #35222.
    
    whitelist:
    
    ```
    type pruneResource struct {
        group      string
        version    string
        kind       string
        namespaced bool
    }
    
    *pruneResources = []pruneResource{
        {"", "v1", "ConfigMap", true},
        {"", "v1", "Endpoints", true},
        {"", "v1", "Namespace", false},
        {"", "v1", "PersistentVolumeClaim", true},
        {"", "v1", "PersistentVolume", false},
        {"", "v1", "Pod", true},
        {"", "v1", "ReplicationController", true},
        {"", "v1", "Secret", true},
        {"", "v1", "Service", true},
        {"batch", "v1", "Job", true},
        {"extensions", "v1beta1", "DaemonSet", true},
        {"extensions", "v1beta1", "Deployment", true},
        {"extensions", "v1beta1", "HorizontalPodAutoscaler", true},
        {"extensions", "v1beta1", "Ingress", true},
        {"extensions", "v1beta1", "ReplicaSet", true},
        {"apps", "v1beta1", "StatefulSet", true},
    }
    ```
    
    example:
    
    ```
    $ kubectl apply -f /path/to/file --prune -l test=true \
          -w core/v1/Pod \
          -w core/v1/Service \
          -w extensions/v1beta1/Deployment 
    ```
    
    @mikedanese
    e4edd817
Name
Last commit
Last update
..
filter Loading commit data...
prune Loading commit data...
prune-reap Loading commit data...
recursive Loading commit data...
deployment-multicontainer.yaml Loading commit data...
deployment-revision1.yaml Loading commit data...
deployment-revision2.yaml Loading commit data...
frontend-controller.yaml Loading commit data...
frontend-replicaset.yaml Loading commit data...
invalid-rc-with-empty-args.yaml Loading commit data...
list.yaml Loading commit data...
multi-resource-json-modify.json Loading commit data...
multi-resource-json.json Loading commit data...
multi-resource-list-modify.json Loading commit data...
multi-resource-list.json Loading commit data...
multi-resource-rclist-modify.json Loading commit data...
multi-resource-rclist.json Loading commit data...
multi-resource-svclist-modify.json Loading commit data...
multi-resource-svclist.json Loading commit data...
multi-resource-yaml-modify.yaml Loading commit data...
multi-resource-yaml.yaml Loading commit data...
nginx-petset.yaml Loading commit data...
pod-apply.yaml Loading commit data...
pod-with-api-env.yaml Loading commit data...
pod-with-large-name.yaml Loading commit data...
pod-with-precision.json Loading commit data...
pod.yaml Loading commit data...
redis-slave-replicaset.yaml Loading commit data...
tls.crt Loading commit data...
tls.key Loading commit data...