Is there a way to use a higher version kubectl to request a lower version kubernetes?

10/15/2017

I have a kubectl which version is 1.8.0 and a kubernetes cluster which version is 1.7.4. Using this kubectl to request the kubernetes cluster will be wrong for some cases like applying an CronJob yaml file.

I have searched a lot but could not find a way to use a higer version kubectl to request a lower version kubernetes cluster.

For Docker, I could set DOCKER_API_VERSION to be compatible with the server API for the docker client. So for kubernetes, is there a similar to do this?

-- flyer
kubectl
kubernetes

3 Answers

10/16/2017

IMO, simply install the lower version kubectl, use it with the lower version cluster.

kubectl is a single file application, we can have multiple versions co-exist.

curl -L https://storage.googleapis.com/kubernetes-release/release/v1.7.4/bin/linux/amd64/kubectl -o kubectl-1.7
-- silverfox
Source: StackOverflow

10/16/2017

kubectl apply in particular has no ability to switch versions of a resource (it embeds a particular version in an annotation and must deal with that version forever).

For general fetching of resources, you can fully qualify the API group and version of resource you request from the server:

# no qualification, defaults to preferred server group and version
kubectl get deployments

# group qualification, defaults to preferred server version of that group
kubectl get deployments.extensions
kubectl get deployments.apps

# fully qualified resource.version.group
kubectl get deployments.v1beta1.extensions
kubectl get deployments.v1beta1.apps
kubectl get deployments.v1beta2.apps
-- Jordan Liggitt
Source: StackOverflow

10/15/2017

Yes, there is a option like that in my kubectl version 1.6.6.

kubectl options

--api-version='': DEPRECATED: The API version to use when talking to the server

It was deprecated though. I guess this option has been deleted in 1.8.0

-- 3h4x
Source: StackOverflow