Kubernetes-native declarative infrastructure for UCLOUD.
The Cluster API is a Kubernetes project to bring declarative, Kubernetes-style APIs to cluster creation, configuration, and management. It provides optional, additive functionality on top of core Kubernetes.
- Only UCloud Region
cn-bj2is supported currently. - cluster-api-provider-ucloud does not provide control-plane controller or bootstrap controller.
- The kubeadm based control-plane and bootstrap controller provided by cluster-api community should be installed.
- Configure a management cluster following cluster-api doc
- Install clusterctl following cluster-api doc.
- init cluster-api use following command:
clusterctl init - download deploy yaml from release page
- deploy cluster-api-provider-ucloud(replace ucloud keys with yours)
kubectl create ns capu-system kubectl create secret generic manager-bootstrap-credentials -from-literal=UCLOUD_ACCESS_PUBKEY=REPLACE_WITH_YOUR_PUBLIC_KEY --from-literal=UCLOUD_ACCESS_PRIKEY=REPLACE_WITH_YOUR_PRIVATE_KEY -n capu-system kubectl apply -f infrastructure-components.yaml
- replace network info and base64 encoded ssh password for instances by yours in example/cluster.yaml
- then apply it
kubectl apply -f example/cluster.yaml
- get kubeconfig frome secret
kubectl get secret/test-kubeconfig -o jsonpath={.data.value} | base64 --decode > /tmp/capi-ucloud.kubeconfig - check nodes status
kubectl --kubeconfig=/tmp/capi-ucloud.kubeconfig get nodes -owide - install cni plugin
kubectl --kubeconfig=/tmp/capi-ucloud.kubeconfig apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml - after cni plugin installed successfully, nodes will be ready and you can deploy a test app
kubectl --kubeconfig=/tmp/capi-ucloud.kubeconfig apply -f example/test.yaml
If you specify sshPassword for bastion in UCloudCluster just like the example/cluster.yaml does. A bastion instance willed be launched. The bastion has a public ip, so you can use it to login your kubernetes nodes.
- get public ip of bastion
kubectl get ucloudcluster test -o jsonpath={.status.bastion.publicIP} - just login with the passwd you have set.
The tool cluster-api-uk8s-init used in preKubeadmCommands and postKubeadmCommands is provided by ucloud k8s team. It is neccessary for deploying cloudprovider and csi.
There is no where for configuring kubeproxy mode in KubeadmControlPlane provided by cluster-api community currently. So we provide an option in the preKubeadmCommands shell scripts. You can add an option --kubeproxy-mode=ipvs for cluster-api-uk8s-init like following:
cluster-api-uk8s-init prepare --kubeproxy-mode=ipvs --credential=UCLOUD_CREDENTIAL --node-role=master --k8s-version=KUBERNETES_VERSION --cloud-provider-version=20.04.22
NOTE: Once kubeproxy mode config is supported by cluster-api community, this approach is deprecated immediately.