Skip to content

Commit

Permalink
feat: azure support (#84)
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Léonard Suslian <[email protected]>
Co-authored-by: Dario Tranchitella <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 7ca279f commit 1669bed
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The Kamaji Cluster API Control Plane provider documentation is referenced in the
| [vSphere](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere) ([technical considerations](docs/providers-vsphere.md)) | += 1.7.0 |
| [IONOS Cloud](https://github.com/ionos-cloud/cluster-api-provider-ionoscloud) ([technical considerations](docs/providers-ionoscloud.md)) | += v0.3.0 |
| [Proxmox by IONOS Cloud](https://github.com/ionos-cloud/cluster-api-provider-proxmox) ([technical considerations](docs/providers-proxmox.md)) | unreleased |
| [Azure](https://github.com/kubernetes-sigs/cluster-api-provider-azure) ([technical considerations](docs/providers-azure.md)) | += v1.18.0 |

> Are you looking for further integrations?
> Please, engage with the community on the [#kamaji](https://kubernetes.slack.com/archives/C03GLTTMWNN) Kubernetes Slack
Expand Down
1 change: 1 addition & 0 deletions config/control-plane-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13338,6 +13338,7 @@ rules:
- infrastructure.cluster.x-k8s.io
resources:
- awsclusters
- azureclusters
- hetznerclusters
- ionoscloudclusters
- kubevirtclusters
Expand Down
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ rules:
- infrastructure.cluster.x-k8s.io
resources:
- awsclusters
- azureclusters
- hetznerclusters
- ionoscloudclusters
- kubevirtclusters
Expand Down
4 changes: 3 additions & 1 deletion controllers/kamajicontrolplane_controller_cluster_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (r *KamajiControlPlaneReconciler) patchCluster(ctx context.Context, cluster
switch cluster.Spec.InfrastructureRef.Kind {
case "AWSCluster":
return r.patchGenericCluster(ctx, cluster, endpoint, port, false)
case "AzureCluster":
return r.patchGenericCluster(ctx, cluster, endpoint, port, false)
case "HetznerCluster":
return r.patchGenericCluster(ctx, cluster, endpoint, port, false)
case "IonosCloudCluster":
Expand Down Expand Up @@ -127,7 +129,7 @@ func (r *KamajiControlPlaneReconciler) checkOrPatchGenericCluster(ctx context.Co
return nil
}

//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters;hetznerclusters;kubevirtclusters;nutanixclusters;packetclusters;ionoscloudclusters,verbs=patch;get;list;watch
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters;azureclusters;hetznerclusters;kubevirtclusters;nutanixclusters;packetclusters;ionoscloudclusters,verbs=patch;get;list;watch
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=kubevirtclusters/status;nutanixclusters/status;packetclusters/status,verbs=patch

func (r *KamajiControlPlaneReconciler) patchGenericCluster(ctx context.Context, cluster capiv1beta1.Cluster, endpoint string, port int64, patchStatus bool) error {
Expand Down
171 changes: 171 additions & 0 deletions docs/providers-azure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Kamaji and Azure

The Kamaji Control Plane provider was able to create an _Azure_ backed Kubernetes cluster by providing Kamaji Control Planes.

```
NAME READY SEVERITY REASON SINCE MESSAGE
Cluster/capi-quickstart True 31m
├─ClusterInfrastructure - AzureCluster/kamaji-quickstart-control-plane True 31m
├─ControlPlane - KamajiControlPlane/kamaji-azure-127
└─Workers
└─MachineDeployment/capi-quickstart-md-0 True 28s
└─3 Machines... True 12m See capi-quickstart-md-0-6848dccdffxn5j9b-cjgp5, capi-quickstart-md-0-6848dccdffxn5j9b-gk95g, ...
```

## Example manifests

The said cluster has been created with the following manifests.

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: capi-quickstart
namespace: default
spec:
clusterNetwork:
apiServerPort: 443
pods:
cidrBlocks:
- 10.244.0.0/16
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KamajiControlPlane
name: kamaji-quickstart-control-plane
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureCluster
name: capi-quickstart
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureCluster
metadata:
name: capi-quickstart
namespace: default
spec:
identityRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
name: azure-identity
location: westeurope
controlPlaneEnabled: false
networkSpec:
subnets:
- name: node-subnet
role: node
vnet:
name: workload
resourceGroup: test-resource-group
subscriptionID: 00000000-0000-0000-0000-000000000000
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
metadata:
labels:
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
name: azure-identity
spec:
allowedNamespaces: {}
clientID: 00000000-0000-0000-0000-000000000000
clientSecret:
name: azure-client-secret
namespace: azure
tenantID: 00000000-0000-0000-0000-000000000000
type: ServicePrincipal
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: KamajiControlPlane
metadata:
name: kamaji-quickstart-control-plane
namespace: default
spec:
apiServer:
extraArgs:
- --cloud-provider=external
controllerManager:
extraArgs:
- --cloud-provider=external
dataStoreName: default
addons:
coreDNS: { }
konnectivity: { }
kubeProxy: { }
kubelet:
cgroupfs: systemd
preferredAddressTypes:
- ExternalIP
- InternalIP
- Hostname
network:
serviceType: LoadBalancer
deployment:
replicas: 2
version: 1.30.0
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: capi-quickstart-md-0
namespace: default
spec:
clusterName: capi-quickstart
replicas: 2
selector:
matchLabels: null
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: capi-quickstart-md-0
clusterName: workload
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: capi-quickstart-md-0
version: v1.30.0
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: capi-quickstart-md-0
namespace: default
spec:
template:
spec:
osDisk:
diskSizeGB: 128
osType: Linux
sshPublicKey: ""
vmSize: Standard_DS3_v2
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: capi-quickstart-md-0
namespace: default
spec:
template:
spec:
files:
- contentFrom:
secret:
key: worker-node-azure.json
name: workload-md-0-azure-json
owner: root:root
path: /etc/kubernetes/azure.json
permissions: "0644"
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
name: '{{ ds.meta_data["local_hostname"] }}'
preKubeadmCommands: []
```
## Technical considerations
The Cluster API Azure infrastructure provider supports starting from [v1.18.0](https://github.com/kubernetes-sigs/cluster-api-provider-azure/milestone/40).
Once the cluster has been provisioned, you need to install the [Azure Cloud Controller Manager](https://github.com/kubernetes-sigs/cloud-provider-azure).

0 comments on commit 1669bed

Please sign in to comment.