Skip to content
Merged
19 changes: 19 additions & 0 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ type CNI struct {
// +kubebuilder:default=HelmAddon
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
Strategy *AddonStrategy `json:"strategy,omitempty"`

// AddonConfig contains the configuration for the CNI provider.
// +kubebuilder:validation:Optional
AddonConfig `json:",inline"`
}

// AddonConfig contains the configuration for the Addon provider.
type AddonConfig struct {
// Values contains the helm values for the CNI when HelmAddon is the strategy.
// +kubebuilder:validation:Optional
Values *AddonValues `json:"values,omitempty"`
}

// AddonValues contains the configuration values for the Helm Addon.
type AddonValues struct {
// SourceRef is an object reference to Configmap/Secret inside the same namespace
// which contains inline YAML representing the values for the Helm chart.
// +kubebuilder:validation:Optional
SourceRef *TypedLocalObjectReference `json:"sourceRef,omitempty"`
}

// NFD tells us to enable or disable the node feature discovery addon.
Expand Down
23 changes: 23 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ spec:
- ClusterResourceSet
- HelmAddon
type: string
values:
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
properties:
sourceRef:
description: |-
SourceRef is an object reference to Configmap/Secret inside the same namespace
which contains inline YAML representing the values for the Helm chart.
properties:
kind:
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
enum:
- Secret
- ConfigMap
type: string
name:
description: Name is the name of resource being referenced.
minLength: 1
type: string
required:
- kind
- name
type: object
type: object
required:
- provider
type: object
Expand Down
23 changes: 23 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ spec:
- ClusterResourceSet
- HelmAddon
type: string
values:
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
properties:
sourceRef:
description: |-
SourceRef is an object reference to Configmap/Secret inside the same namespace
which contains inline YAML representing the values for the Helm chart.
properties:
kind:
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
enum:
- Secret
- ConfigMap
type: string
name:
description: Name is the name of resource being referenced.
minLength: 1
type: string
required:
- kind
- name
type: object
type: object
required:
- provider
type: object
Expand Down
23 changes: 23 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ spec:
- ClusterResourceSet
- HelmAddon
type: string
values:
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
properties:
sourceRef:
description: |-
SourceRef is an object reference to Configmap/Secret inside the same namespace
which contains inline YAML representing the values for the Helm chart.
properties:
kind:
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
enum:
- Secret
- ConfigMap
type: string
name:
description: Name is the name of resource being referenced.
minLength: 1
type: string
required:
- kind
- name
type: object
type: object
required:
- provider
type: object
Expand Down
19 changes: 19 additions & 0 deletions api/v1alpha1/meta_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 Nutanix. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

// TypedLocalObjectReference contains enough information to let you locate the
// typed referenced object inside the same namespace.
// This is redacted from the upstream https://pkg.go.dev/k8s.io/api/core/v1#TypedLocalObjectReference
type TypedLocalObjectReference struct {
// Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
// +kubebuilder:validation:Enum=Secret;ConfigMap
// +kubebuilder:validation:Required
Kind string `json:"kind"`

// Name is the name of resource being referenced.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
}
56 changes: 56 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.

64 changes: 64 additions & 0 deletions docs/content/addons/cni.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,70 @@ spec:
strategy: HelmAddon
```

## Cilium Example with custom values

To enable deployment of Cilium on a cluster with custom helm values, specify the following:

```yaml
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: <NAME>
spec:
topology:
variables:
- name: clusterConfig
value:
addons:
cni:
provider: Cilium
strategy: HelmAddon
values:
sourceRef:
name: <NAME> #name of ConfigMap/Secret present in same namespace
kind: <ConfigMap/Secret>
```

NOTE: Only ConfigMap/Secret kind objects will be allowed to refer helm values from.

ConfigMap Format -

```yaml
apiVersion: v1
data:
values.yaml: |-
cni:
chainingMode: portmap
exclusive: false
ipam:
mode: kubernetes
kind: ConfigMap
metadata:
name: <CLUSTER_NAME>-cilium-cni-helm-values-template
namespace: <CLUSTER_NAMESPACE>
```

Secret Format -

```yaml
apiVersion: v1
stringData:
values.yaml: |-
cni:
chainingMode: portmap
exclusive: false
ipam:
mode: kubernetes
kind: Secret
metadata:
name: <CLUSTER_NAME>-cilium-cni-helm-values-template
namespace: <CLUSTER_NAMESPACE>
type: Opaque
```

NOTE: ConfigMap/Secret should contain complete helm values for Cilium as same will be applied
to Cilium helm chart as it is.

To deploy the addon via `ClusterResourceSet` replace the value of `strategy` with `ClusterResourceSet`.

## Calico
Expand Down
Loading