Skip to content

feat: COSI controller Addon #1008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ type DockerAddons struct {

// +kubebuilder:validation:Optional
CSI *DockerCSI `json:"csi,omitempty"`

// +kubebuilder:validation:Optional
COSI *DockerCOSI `json:"cosi,omitempty"`
}

type NutanixAddons struct {
GenericAddons `json:",inline"`

// +kubebuilder:validation:Optional
CSI *NutanixCSI `json:"csi,omitempty"`

// +kubebuilder:validation:Optional
COSI *NutanixCOSI `json:"cosi,omitempty"`
}

type GenericAddons struct {
Expand All @@ -96,8 +102,6 @@ type GenericAddons struct {
ServiceLoadBalancer *ServiceLoadBalancer `json:"serviceLoadBalancer,omitempty"`
}

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
type AddonStrategy string

// CNI required for providing CNI configuration.
Expand All @@ -109,13 +113,15 @@ type CNI struct {

// Addon strategy used to deploy the CNI provider to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

// NFD tells us to enable or disable the node feature discovery addon.
type NFD struct {
// Addon strategy used to deploy Node Feature Discovery (NFD) to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

Expand All @@ -124,6 +130,7 @@ type ClusterAutoscaler struct {
// Addon strategy used to deploy cluster-autoscaler to the management cluster
// targeting the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

Expand All @@ -136,9 +143,17 @@ type GenericCSI struct {
SnapshotController *SnapshotController `json:"snapshotController,omitempty"`
}

type GenericCOSI struct {
// Addon strategy used to deploy the COSI controller to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

type SnapshotController struct {
// Addon strategy used to deploy the snapshot controller to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

Expand Down Expand Up @@ -197,6 +212,7 @@ type CSIProvider struct {

// Addon strategy used to deploy the CSI provider to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`

// The reference to any secret used by the CSI Provider.
Expand Down Expand Up @@ -231,6 +247,14 @@ type CSICredentials struct {
SecretRef LocalObjectReference `json:"secretRef"`
}

type DockerCOSI struct {
GenericCOSI `json:",inline"`
}

type NutanixCOSI struct {
GenericCOSI `json:",inline"`
}

// CCM tells us to enable or disable the cloud provider interface.
type CCM struct {
// A reference to the Secret for credential information for the target Prism Central instance
Expand All @@ -239,6 +263,7 @@ type CCM struct {

// Addon strategy used to deploy the CCM to the workload cluster.
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`
}

Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const (
CNIVariableName = "cni"
// NFDVariableName is the NFD external patch variable name.
NFDVariableName = "nfd"

// COSIVariableName is the COSI external patch variable name.
COSIVariableName = "cosi"
// ClusterAutoscalerVariableName is the cluster-autoscaler external patch variable name.
ClusterAutoscalerVariableName = "clusterAutoscaler"
// ServiceLoadBalancerVariableName is the Service LoadBalancer config patch variable name.
Expand Down
9 changes: 9 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ spec:
required:
- provider
type: object
cosi:
properties:
strategy:
default: HelmAddon
description: Addon strategy used to deploy the COSI controller to the workload cluster.
enum:
- HelmAddon
type: string
type: object
csi:
properties:
defaultStorage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ spec:
required:
- provider
type: object
cosi:
properties:
strategy:
default: HelmAddon
description: Addon strategy used to deploy the COSI controller to the workload cluster.
enum:
- HelmAddon
type: string
type: object
csi:
properties:
defaultStorage:
Expand Down
62 changes: 62 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/variables/aggregate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ type Addons struct {
carenv1.GenericAddons `json:",inline"`

CSI *CSI `json:"csi,omitempty"`

COSI *COSI `json:"cosi,omitempty"`
}

type CSI struct {
carenv1.GenericCSI `json:",inline"`

Providers map[string]carenv1.CSIProvider `json:"providers"`
}

type COSI struct {
carenv1.GenericCOSI `json:",inline"`
}
2 changes: 2 additions & 0 deletions charts/cluster-api-runtime-extensions-nutanix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
| hooks.cni.cilium.crsStrategy.defaultCiliumConfigMap.name | string | `"cilium"` | |
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cilium-cni-helm-values-template"` | |
| hooks.cosi.controller.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
| hooks.cosi.controller.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cosi-controller-helm-values-template"` | |
| hooks.csi.aws-ebs.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
| hooks.csi.aws-ebs.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-aws-ebs-csi-helm-values-template"` | |
| hooks.csi.local-path.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

{{- if (index .Values.hooks.cosi "controller").helmAddonStrategy.defaultValueTemplateConfigMap.create }}
apiVersion: v1
kind: ConfigMap
metadata:
name: '{{ (index .Values.hooks.cosi "controller").helmAddonStrategy.defaultValueTemplateConfigMap.name }}'
data:
values.yaml: |-
{{- .Files.Get "addons/cosi/controller/values-template.yaml" | nindent 4 }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ spec:
- --csi.local-path.helm-addon.default-values-template-configmap-name={{ (index .Values.hooks.csi "local-path").helmAddonStrategy.defaultValueTemplateConfigMap.name }}
- --csi.snapshot-controller.helm-addon.default-values-template-configmap-name={{ (index .Values.hooks.csi "snapshot-controller").helmAddonStrategy.defaultValueTemplateConfigMap.name }}
- --ccm.aws.helm-addon.default-values-template-configmap-name={{ .Values.hooks.ccm.aws.helmAddonStrategy.defaultValueTemplateConfigMap.name }}
- --cosi.controller.helm-addon.default-values-template-configmap-name={{ .Values.hooks.cosi.controller.helmAddonStrategy.defaultValueTemplateConfigMap.name }}
{{- range $k, $v := .Values.hooks.ccm.aws.k8sMinorVersionToCCMVersion }}
- --ccm.aws.aws-ccm-versions={{ $k }}={{ $v }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ data:
ChartName: cluster-autoscaler
ChartVersion: 9.43.2
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/autoscaler{{ end }}'
cosi-controller: |
ChartName: cosi
ChartVersion: 0.0.1-alpha.1
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://mesosphere.github.io/charts/stable/{{ end }}'
local-path-provisioner-csi: |
ChartName: local-path-provisioner
ChartVersion: 0.0.30
Expand Down
26 changes: 26 additions & 0 deletions charts/cluster-api-runtime-extensions-nutanix/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,32 @@
},
"type": "object"
},
"cosi": {
"properties": {
"controller": {
"properties": {
"helmAddonStrategy": {
"properties": {
"defaultValueTemplateConfigMap": {
"properties": {
"create": {
"type": "boolean"
},
"name": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
},
"csi": {
"properties": {
"aws-ebs": {
Expand Down
6 changes: 6 additions & 0 deletions charts/cluster-api-runtime-extensions-nutanix/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ hooks:
defaultTemplateConfigMap:
create: true
name: default-kube-vip-template
cosi:
controller:
helmAddonStrategy:
defaultValueTemplateConfigMap:
create: true
name: default-cosi-controller-helm-values-template

helmAddonsConfigMap: default-helm-addons-config

Expand Down
32 changes: 32 additions & 0 deletions docs/content/addons/cosi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
+++
title = " Container Object Storage Interface (COSI)"
icon = "fa-solid fa-eye"
+++

By leveraging CAPI cluster lifecycle hooks, this handler deploys [Container Object Storage Interface] (COSI)
on the new cluster at the `AfterControlPlaneInitialized` phase.

Deployment of COSI is opt-in via the [provider-specific cluster configuration]({{< ref ".." >}}).

The hook uses the [Cluster API Add-on Provider for Helm] to deploy the COSI resources.

## Example

To enable deployment of COSI on a cluster, specify the following values:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
variables:
- name: clusterConfig
value:
addons:
cosi: {}
```

[Container Object Storage Interface]: https://kubernetes.io/blog/2022/09/02/cosi-kubernetes-object-storage-management/
[Cluster API Add-on Provider for Helm]: https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm
1 change: 1 addition & 0 deletions examples/capi-quick-start/docker-cluster-calico-crs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
cni:
provider: Calico
strategy: ClusterResourceSet
cosi: {}
csi:
defaultStorage:
provider: local-path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
clusterAutoscaler: {}
cni:
provider: Calico
cosi: {}
csi:
defaultStorage:
provider: local-path
Expand Down
Loading
Loading