creating a custom cluster api...
TRANSCRIPT
![Page 1: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/1.jpg)
Creating a custom Cluster API Provider
Himani Agrawal
@himani_93
Giri Kuncoro
@girikuncoro
![Page 2: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/2.jpg)
History
![Page 3: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/3.jpg)
70+ ways to deploy Kubernetes
![Page 4: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/4.jpg)
What is missing?
➔ Declarative, Kubernetes-style API
➔ Compatibility with tooling
➔ Cloud agnostic
➔ Single interface for infra/cluster
![Page 5: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/5.jpg)
Cluster API
![Page 6: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/6.jpg)
Kubernetes Cluster
Cluster API
Reference: Deep Dive: Cluster API KubeCon EU 2019
![Page 7: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/7.jpg)
Declarative Config
Kubernetes Cluster
Cluster API
Reference: Deep Dive: Cluster API KubeCon EU 2019
![Page 8: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/8.jpg)
Kubernetes Cluster
Cluster APIDeclarative Config
Reference: Deep Dive: Cluster API KubeCon EU 2019
![Page 9: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/9.jpg)
Cluster API CRDs
Cluster
![Page 10: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/10.jpg)
ClusterapiVersion: "cluster-api.k8s.io/v1alpha1"kind: Clustermetadata: name: fujisanspec: providerSpec: ... clusterNetwork: services: cidrBlocks: ["10.96.0.0/12"] pods: cidrBlocks: ["192.168.0.0/16"]
serviceDomain: "cluster.local"
![Page 11: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/11.jpg)
Cluster API CRDs
Cluster Machine
![Page 12: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/12.jpg)
MachineapiVersion: "cluster-api.k8s.io/v1alpha1"kind: Machinemetadata: name: kube-cpspec: providerSpec: vcpu: 2
... versions:
kubelet: 1.15.0
![Page 13: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/13.jpg)
Cluster API CRDs
Cluster Machine Machine Set
![Page 14: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/14.jpg)
Cluster API CRDs
Cluster Machine Machine Set Machine Deployment
![Page 15: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/15.jpg)
Cluster API CRDs
Cluster Machine Machine Set Machine Deployment
Machine Class
![Page 16: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/16.jpg)
Cluster API CRDs
Cluster Machine Machine Set Machine Deployment
Machine Class
Pod Replica Set Deployment Storage Class
![Page 17: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/17.jpg)
How Cluster API works?
Controller Actuator KVM BaremetalapiVersion: "cluster-api.k8s.io/v1alpha1"kind: Machinemetadata: name: kube-cpspec: providerSpec: vcpu: 2 versions: kubelet: 1.15.0
Machine CRD
Machine
![Page 18: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/18.jpg)
Provider Controller Manager
Cluster Controller Machine Controller
![Page 19: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/19.jpg)
Demo
Picture Credits: Ashley McNamara
![Page 20: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/20.jpg)
Code
func main() {
mgr, _ := manager.New(cfg, opts)
machineActuator, _ := machine.NewActuator(machine.ActuatorParams{ Client: mgr.GetClient(), })
apis.AddToScheme(mgr.GetScheme())
clusterapis.AddToScheme(mgr.GetScheme()) capimachine.AddWithActuator(mgr, machineActuator)
mgr.Start(signals.SetupSignalHandler())
}
cmd/manager/main.go
![Page 21: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/21.jpg)
Code
func init() {
// AddToManagerFuncs is a list of functions to create controllers // and add them to a manager. AddToManagerFuncs = append(AddToManagerFuncs, func(m manager.Manager) error { return capimachine.AddWithActuator(m, &machine.Actuator{}) })}
pkg/controller/add_machine_controller.go
![Page 22: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/22.jpg)
Code
type LibvirtMachineProviderSpecSpec struct { // Number of virtual CPU VCPU int `json:"vcpu"`
// Amount of RAM in GBs MemoryInGB int `json:"memoryInGB"`
// Image URL to be provisioned ImageURI string `json:"imageURI"`
// UserData URI of cloud-init image UserDataURI string `json:"userDataURI"`}
pkg/apis/libvirt/v1alpha1/libvirtmachineproviderspec_types.go
![Page 23: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/23.jpg)
Code
// CreateDomain connects to libvirt daemon and creates a new domain// as per domainXML.func CreateDomain(domainXML string) error { ...}
// DomainExists checks if the domain with the given name exists.func DomainExists(domainName string) bool { ...}
// defineDomain returns the XML representation of the domain to be created.// Output of this func is passed into CreateDomain() to create a new domain.func defineDomain() string { ...}
pkg/cloud/libvirt/domain.go
![Page 24: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/24.jpg)
func (a *Actuator) Create() error { return libvirt.CreateDomain()}
func (a *Actuator) Exists() (bool, error) { return libvirt.DomainExists() }
func (a *Actuator) Delete() { ... }
func (a *Actuator) Update() { ... }
Codepkg/cloud/libvirt/actuators/machine/actuator.go
![Page 25: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/25.jpg)
/himani93/cluster-api-provider-libvirt
![Page 26: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/26.jpg)
● Cluster API v0.1.0
● Kubebuilder v1.0.8
● Kustomize v1.0.11
● Kubectl v1.13
● Minikube v1.2.0
Dependency Versions
![Page 27: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/27.jpg)
Discussion
● Cluster API is super cool!
● Early work for production version
![Page 28: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/28.jpg)
Getting Involved➔ Github Repo
github.com/kubernetes-sigs/cluster-api
➔ Mailing List: kubernetes-sig-cluster-lifecyclehttps://groups.google.com/forum/#!forum/kubernetes-sig-clus
ter-lifecycle
➔ Slack: #cluster-apihttps://kubernetes.slack.com/messages/C8TSNPY4T
![Page 29: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/29.jpg)
Provider Implementations
● AWS, https://github.com/kubernetes-sigs/cluster-api-provider-aws
● Azure, https://github.com/kubernetes-sigs/cluster-api-provider-azure
● Baidu Cloud, https://github.com/baidu/cluster-api-provider-baiducloud
● Bare Metal, https://github.com/metal3-io/cluster-api-provider-baremetal
● DigitalOcean, https://github.com/kubernetes-sigs/cluster-api-provider-digitalocean
● Exoscale, https://github.com/exoscale/cluster-api-provider-exoscale
● GCP, https://github.com/kubernetes-sigs/cluster-api-provider-gcp
● IBM Cloud, https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud
● OpenStack, https://github.com/kubernetes-sigs/cluster-api-provider-openstack
● Talos, https://github.com/talos-systems/cluster-api-provider-talos
● Tencent Cloud, https://github.com/TencentCloud/cluster-api-provider-tencent
● vSphere, https://github.com/kubernetes-sigs/cluster-api-provider-vsphere
![Page 30: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/30.jpg)
API AdoptionFollowing are the implementations managed by third-parties adopting the standard cluster-api and/or
machine-api being developed here.
● Kubermatic machine-controller, https://github.com/kubermatic/machine-controller/tree/master
● Machine API Operator, https://github.com/openshift/machine-api-operator/tree/master
● Machine-controller-manager, https://github.com/gardener/machine-controller-manager/tree/cluster-api
![Page 31: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/31.jpg)
References
● https://kccna18.sched.com/event/Greh
● https://kccnceu19.sched.com/event/MPkR
● https://blogs.vmware.com/cloudnative/2019/03/14/what-and-why-of-cluster-api/
● https://blog.heptio.com/the-kubernetes-cluster-api-de5a1ff870a5
● https://github.com/kubernetes-sigs/cluster-api
● https://cluster-api.sigs.k8s.io/
![Page 32: Creating a custom Cluster API Providerevents19.linuxfoundation.org/wp-content/uploads/2018/07/OSS... · Creating a custom Cluster API Provider Himani Agrawal @himani_93 Giri Kuncoro](https://reader034.vdocuments.site/reader034/viewer/2022050405/5f828cbcc23fac07416171be/html5/thumbnails/32.jpg)
ありがとうございます。