Kubectl change default behaviour of record Kubectl change default behaviour of record kubernetes kubernetes

Kubectl change default behaviour of record


AFAIK, you can't define default values for commands parameters

Your alternatives are:

  • create a bash function with the default parameters and call it with the parameters you want

    diego@PC:/$k8s() { kubectl $1 $2 $3 --record=true;}

    diego@PC:/$k8s create -f https://test

  • Create kubectl plugins and write your custom command to replace the create subcommand with your own parameter set and internally you call the kubectl create.

    The idea is similar to above, but you would still use the kubectl,

    i.e: kubectl createrec -f https://raw.githubusercontent.com/../d09.yaml

  • The other alternative is download the source and change the default value and compile a new version


The best way to address the problem is to create a wrapper script around kubectl create.call the wrapper script with 'r' param to append --record=true


In my opinion your use case is ideal for packaging your Kubernetes deployment manifest file in Helm. Once you have your own helm chart, you would run following cmd:

helm template --output-dir ./manifests ./charts/diego-chart --set record=true | kubectl apply ./manifests