Skip to content

Commit 53e00c5

Browse files
feat: adds new field for helm values input for cilium CNI (#1011)
**What problem does this PR solve?**: Introduces new field in CAREN API to add custom helm values input for cilium CNI. **Which issue(s) this PR fixes**: Fixes # https://jira.nutanix.com/browse/NCN-105147 **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 38a5fab commit 53e00c5

6 files changed

+227
-0
lines changed

api/v1alpha1/addon_types.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,40 @@ type CNI struct {
115115
// +kubebuilder:default=HelmAddon
116116
// +kubebuilder:validation:Enum=ClusterResourceSet;HelmAddon
117117
Strategy *AddonStrategy `json:"strategy,omitempty"`
118+
119+
// AddonConfig contains the configuration for the CNI provider.
120+
// +kubebuilder:validation:Optional
121+
AddonConfig `json:",inline"`
122+
}
123+
124+
// AddonConfig contains the configuration for the Addon provider.
125+
type AddonConfig struct {
126+
// Values contains the helm values for the CNI when HelmAddon is the strategy.
127+
// +kubebuilder:validation:Optional
128+
Values *AddonValues `json:"values,omitempty"`
129+
}
130+
131+
// AddonValues contains the configuration values for the Helm Addon.
132+
type AddonValues struct {
133+
// SourceRef is an object reference to Configmap/Secret inside the same namespace
134+
// which contains inline YAML representing the values for the Helm chart.
135+
// +kubebuilder:validation:Optional
136+
SourceRef *ValuesReference `json:"sourceRef,omitempty"`
137+
}
138+
139+
// ValuesReference contains enough information to let you locate the
140+
// typed referenced object inside the same namespace.
141+
// This is redacted from the upstream https://pkg.go.dev/k8s.io/api/core/v1#TypedLocalObjectReference
142+
type ValuesReference struct {
143+
// Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
144+
// +kubebuilder:validation:Enum=Secret;ConfigMap
145+
// +kubebuilder:validation:Required
146+
Kind string `json:"kind"`
147+
148+
// Name is the name of resource being referenced.
149+
// +kubebuilder:validation:Required
150+
// +kubebuilder:validation:MinLength=1
151+
Name string `json:"name"`
118152
}
119153

120154
// NFD tells us to enable or disable the node feature discovery addon.

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ spec:
101101
- ClusterResourceSet
102102
- HelmAddon
103103
type: string
104+
values:
105+
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
106+
properties:
107+
sourceRef:
108+
description: |-
109+
SourceRef is an object reference to Configmap/Secret inside the same namespace
110+
which contains inline YAML representing the values for the Helm chart.
111+
properties:
112+
kind:
113+
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
114+
enum:
115+
- Secret
116+
- ConfigMap
117+
type: string
118+
name:
119+
description: Name is the name of resource being referenced.
120+
minLength: 1
121+
type: string
122+
required:
123+
- kind
124+
- name
125+
type: object
126+
type: object
104127
required:
105128
- provider
106129
type: object

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ spec:
101101
- ClusterResourceSet
102102
- HelmAddon
103103
type: string
104+
values:
105+
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
106+
properties:
107+
sourceRef:
108+
description: |-
109+
SourceRef is an object reference to Configmap/Secret inside the same namespace
110+
which contains inline YAML representing the values for the Helm chart.
111+
properties:
112+
kind:
113+
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
114+
enum:
115+
- Secret
116+
- ConfigMap
117+
type: string
118+
name:
119+
description: Name is the name of resource being referenced.
120+
minLength: 1
121+
type: string
122+
required:
123+
- kind
124+
- name
125+
type: object
126+
type: object
104127
required:
105128
- provider
106129
type: object

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ spec:
101101
- ClusterResourceSet
102102
- HelmAddon
103103
type: string
104+
values:
105+
description: Values contains the helm values for the CNI when HelmAddon is the strategy.
106+
properties:
107+
sourceRef:
108+
description: |-
109+
SourceRef is an object reference to Configmap/Secret inside the same namespace
110+
which contains inline YAML representing the values for the Helm chart.
111+
properties:
112+
kind:
113+
description: Kind is the type of resource being referenced, valid values are ('Secret', 'ConfigMap').
114+
enum:
115+
- Secret
116+
- ConfigMap
117+
type: string
118+
name:
119+
description: Name is the name of resource being referenced.
120+
minLength: 1
121+
type: string
122+
required:
123+
- kind
124+
- name
125+
type: object
126+
type: object
104127
required:
105128
- provider
106129
type: object

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/addons/cni.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,74 @@ spec:
3636
strategy: HelmAddon
3737
```
3838
39+
## Cilium Example with custom values
40+
41+
To enable deployment of Cilium on a cluster with custom helm values, specify the following:
42+
43+
```yaml
44+
apiVersion: cluster.x-k8s.io/v1beta1
45+
kind: Cluster
46+
metadata:
47+
name: <NAME>
48+
spec:
49+
topology:
50+
variables:
51+
- name: clusterConfig
52+
value:
53+
addons:
54+
cni:
55+
provider: Cilium
56+
strategy: HelmAddon
57+
values:
58+
sourceRef:
59+
name: <NAME> #name of ConfigMap/Secret present in same namespace
60+
kind: <ConfigMap/Secret>
61+
```
62+
63+
NOTE: Only ConfigMap/Secret kind objects will be allowed to refer helm values from.
64+
65+
ConfigMap Format -
66+
67+
```yaml
68+
apiVersion: v1
69+
data:
70+
values.yaml: |-
71+
cni:
72+
chainingMode: portmap
73+
exclusive: false
74+
ipam:
75+
mode: kubernetes
76+
kind: ConfigMap
77+
metadata:
78+
labels:
79+
clusterctl.cluster.x-k8s.io/move: ""
80+
name: <CLUSTER_NAME>-cilium-cni-helm-values-template
81+
namespace: <CLUSTER_NAMESPACE>
82+
```
83+
84+
Secret Format -
85+
86+
```yaml
87+
apiVersion: v1
88+
stringData:
89+
values.yaml: |-
90+
cni:
91+
chainingMode: portmap
92+
exclusive: false
93+
ipam:
94+
mode: kubernetes
95+
kind: Secret
96+
metadata:
97+
labels:
98+
clusterctl.cluster.x-k8s.io/move: ""
99+
name: <CLUSTER_NAME>-cilium-cni-helm-values-template
100+
namespace: <CLUSTER_NAMESPACE>
101+
type: Opaque
102+
```
103+
104+
NOTE: ConfigMap/Secret should contain complete helm values for Cilium as same will be applied
105+
to Cilium helm chart as it is.
106+
39107
To deploy the addon via `ClusterResourceSet` replace the value of `strategy` with `ClusterResourceSet`.
40108

41109
## Calico

0 commit comments

Comments
 (0)