env0/self-hosted

Feature request: allow configuration of kubectl versions.

Opened this issue · 1 comments

The Problem:
The Env0 agent is currently on version 1.23. K8s version 1.24 is scheduled for end of life in July of 2023. According to Env0's own documentation

Supported versions

The kubectl version is 1.23, and the kustomize version is 4.5.4.
It is recommended for the remote cluster not to be more than 1 minor version ahead or behind the client's.

This means that anyone using Azure will be outside the recommended compatibility range of the Env0 Kubectl client. Furthermore, it limits any customer upgrades to 1.25 because of the api changes with HPAs in version 1.26.

The Solution
IMO, it's unrealistic to imagine that you can satisfy the whims of every one of your clients with a single pre-installed Kubectl version. We run into the same problem with Terraform, but instead of installing any particular version of Terraform, you use tfenv to manage the Terraform binaries. There's a similar project for kubectl called kbenv that employs the same usage pattern.

I would really like to see the ability to run whatever kubectl version I need, just like I can do with Terraform.

if anyone else finds this especially in the light of the new upgrade, I added this script to my env0.yml in the before hooks for planning and applying:

### Adding kbenv
# https://github.com/little-angry-clouds/kubernetes-binaries-managers/tree/master/cmd/kbenv
mv /opt/kubectl /opt/kubectl.bak

wget https://github.com/little-angry-clouds/kubernetes-binaries-managers/releases/download/v1.0.0/kubernetes-binaries-managers_1.0.0_linux_amd64.tar.gz
tar -xzf kubernetes-binaries-managers_1.0.0_linux_amd64.tar.gz
mv kubectl-linux-amd64/kbenv /opt/kbenv
mv kubectl-linux-amd64/kubectl-wrapper /opt/kubectl

echo "installing kubectl version: ${KubectlVersion}"
kbenv install "${KubectlVersion}"
kbenv use "${KubectlVersion}"

echo "path to kubectl: $(which kubectl)"
echo "kubectl version: $(kubectl version --client  --short)"

kubectl config view

Then I pass in an environmental variable KubectlVersion with the kubectl version I need.