1

I am new to the writing a custom controllers for the kubernetes and trying to understand this. I have started referring the sample-controller https://github.com/kubernetes/sample-controller.

I want to extend the sample-controller to operate VM resource in cloud using kubernetes. It could create a Vm if new VM kind resource is detected. Update the sub resources or delete if user want.

Schema should be like the below:

apiVersion: samplecontroller.k8s.io/v1alpha1
kind: VM
metadata:
name: sample
spec:
vmname: test-1
status:
vmId: 1234-567-8910
cpuUtilization: 50 

Any suggestions or help is highly appreciable :)

2 Answers2

1

Start from https://book.kubebuilder.io/ instead. It's a much better jumping off point than sample-controller.

coderanger
  • 52,400
  • 4
  • 52
  • 75
0

You can use Operator SDK as well https://github.com/operator-framework/operator-sdk but I think kubebuilder.io is a way better!

However, if you're looking for a controller that supports multi-cloud, already there's one by Kubermatic. https://github.com/kubermatic/machine-controller

it works! you can have a look.

  • Hi, yes I will surely look in to the Operator SDK. Machine-controller you suggest basically a public provider. I just want a simple controller that will operate CRUD option for VM resource. – john snowker May 24 '21 at 11:00
  • Yeah, the machine-controller provide a native way to manage VM in the cloud, it supports multiple providers even Openstack! https://github.com/kubermatic/machine-controller/blob/master/docs/cloud-provider.md ... the way that you can manage VMs using kubectl by scaling MachineDeployment or creating a new MachineDeployment,, it's the same mechanism how k8s manages Deployment/Replicasets/Pods. – Mohamed chiheb Ben jemaa May 24 '21 at 11:05