kubernetes-upgrader
A set of Kubernetes controllers to automate Kubernetes clusters upgrade using Cluster API's ClusterClass.
Description
This project is a set of Kubernetes controllers that build Kubernetes machine images using upstream image-builder,
and then use those images to upgrade Kubernetes clusters that are using Cluster API's ClusterClass.
This should work with any Infrastructure provider supported by image-builder, but it was only tested with vSphere's CAPV.
Getting Started
You’ll need a Kubernetes cluster to run against. You can use KIND to get a local cluster for testing, or run against a remote cluster.
Note: Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster kubectl cluster-info
shows).
This will deploy the controllers and a sample to build a vSphere OVA,
read the upstream docs on how to configure the vSphere provider.
-
Deploy the CRDs and the controllers:
kubectl apply -f https://github.com/dkoshkin/kubernetes-upgrader/releases/latest/download/components.yaml
-
Create a Secret with vSphere credentials:
cat << 'EOF' > vsphere.json
{
"vcenter_server":"$VSPHERE_SERVER",
"insecure_connection": "true",
"username":"$VSPHERE_USERNAME",
"password":"$VSPHERE_PASSWORD",
"vsphere_datacenter": "$VSPHERE_DATACENTER",
"cluster": "$VSPHERE_CLUSTER",
"datastore":"$VSPHERE_DATASTORE",
"folder": "$VSPHERE_TEMPLATE_FOLDER",
"network": "$VSPHERE_NETWORK",
"convert_to_template": "true"
}
EOF
kubectl create secret generic image-builder-vsphere-vars --from-file=vsphere.json
-
Deploy the samples:
kubectl apply -f https://github.com/dkoshkin/kubernetes-upgrader/releases/latest/download/vsphere-with-job-template.yaml
-
The controller will create a Job to build the image, after some time you should see the image in the vSphere UI.
Check the status of MachineImage
to see if the image was successfully built:
kubectl get MachineImage -o yaml
You should see status.ready
set to true
and spec.id
set to a newly created OVA template.
For Developers
You’ll need a Kubernetes cluster to run against.
Follow CAPI's Quickstart documentation to create a cluster using KIND and the Docker provider.
Use Kubernetes version v1.26.3
if you are planning on using the sample config.
Running on the cluster
-
Generated the components manifests and build the image:
make release-snapshot
make docker-push IMG=ghcr.io/dkoshkin/kubernetes-upgrader:$(gojq -r '.version' dist/metadata.json)
-
If using a local KIND cluster:
kind load docker-image ghcr.io/dkoshkin/kubernetes-upgrader:$(gojq -r '.version' dist/metadata.json)
-
Deploy the controller to the cluster with the image specified by IMG
:
make deploy IMG=ghcr.io/dkoshkin/kubernetes-upgrader:$(gojq -r '.version' dist/metadata.json)
-
Deploy the samples:
kubectl apply -f config/samples/docker-static.yaml
Undeploy controller
UnDeploy the controller from the cluster:
make undeploy
How it works
This project aims to follow the Kubernetes Operator pattern.
It uses Controllers,
which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster.
Modifying the API definitions
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
make manifests
NOTE: Run make help
for more information on all potential make
targets
More information can be found via the Kubebuilder Documentation