Skip to content

Commit 3774cad

Browse files
dkoshkinjimmidyson
authored andcommitted
feat: deploy Nutanix CCM as an Addon (#38)
* build: remove nutanix CCM from examples * build: add scripts to sync Nutanix CCM manifests * build: add CCM addon var to Nutanix examples * feat: deploy Nutanix CCM addon Aligns the method of deploying the CCM with all other addons. * fixup! build: add scripts to sync Nutanix CCM manifests * fixup! feat: deploy Nutanix CCM addon * build: remove unused CRS tooling for Nutanix CCM The CRS strategy is not supported for the Nutanix CCM, removing it until we actually need it.
1 parent e08e2ee commit 3774cad

File tree

28 files changed

+538
-1110
lines changed

28 files changed

+538
-1110
lines changed

api/v1alpha1/addon_types.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,34 @@ func (CSI) VariableSchema() clusterv1.VariableSchema {
308308
}
309309

310310
// CCM tells us to enable or disable the cloud provider interface.
311-
type CCM struct{}
311+
type CCM struct {
312+
// A reference to the Secret for credential information for the target Prism Central instance
313+
// +optional
314+
Credentials *corev1.LocalObjectReference `json:"credentials"`
315+
}
312316

313317
func (CCM) VariableSchema() clusterv1.VariableSchema {
318+
// TODO Validate credentials is set.
319+
// This CCM is shared across all providers.
320+
// Some of these providers may require credentials to be set, but we don't want to require it for all providers.
321+
// The Nutanix CCM handler will fail in at runtime if credentials are not set.
314322
return clusterv1.VariableSchema{
315323
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
316324
Type: "object",
325+
Properties: map[string]clusterv1.JSONSchemaProps{
326+
"credentials": {
327+
Description: "A reference to the Secret for credential information" +
328+
"for the target Prism Central instance",
329+
Type: "object",
330+
Properties: map[string]clusterv1.JSONSchemaProps{
331+
"name": {
332+
Description: "The name of the Secret",
333+
Type: "string",
334+
},
335+
},
336+
Required: []string{"name"},
337+
},
338+
},
317339
},
318340
}
319341
}

api/v1alpha1/clusterconfig_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const (
2525
CSIProviderAWSEBS = "aws-ebs"
2626
CSIProviderNutanix = "nutanix"
2727

28-
CCMProviderAWS = "aws"
28+
CCMProviderAWS = "aws"
29+
CCMProviderNutanix = "nutanix"
2930
)
3031

3132
// +kubebuilder:object:root=true

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
package v1alpha1
55

66
import (
7+
"fmt"
8+
"net/url"
9+
"strconv"
10+
711
corev1 "k8s.io/api/core/v1"
812
"k8s.io/utils/ptr"
913
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -99,3 +103,26 @@ func (NutanixPrismCentralEndpointSpec) VariableSchema() clusterv1.VariableSchema
99103
},
100104
}
101105
}
106+
107+
//nolint:gocritic // no need for named return values
108+
func (s NutanixPrismCentralEndpointSpec) ParseURL() (string, int32, error) {
109+
var prismCentralURL *url.URL
110+
prismCentralURL, err := url.Parse(s.URL)
111+
if err != nil {
112+
return "", -1, fmt.Errorf("error parsing Prism Central URL: %w", err)
113+
}
114+
115+
hostname := prismCentralURL.Hostname()
116+
117+
// return early with the default port if no port is specified
118+
if prismCentralURL.Port() == "" {
119+
return hostname, DefaultPrismCentralPort, nil
120+
}
121+
122+
port, err := strconv.ParseInt(prismCentralURL.Port(), 10, 32)
123+
if err != nil {
124+
return "", -1, fmt.Errorf("error converting port to int: %w", err)
125+
}
126+
127+
return hostname, int32(port), nil
128+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/cluster-api-runtime-extensions-nutanix/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
3232
| deployment.replicas | int | `1` | |
3333
| env | object | `{}` | |
3434
| helmAddonsConfigMap | string | `"default-helm-addons-config"` | |
35+
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
36+
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nutanix-ccm-helm-values-template"` | |
3537
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
3638
| hooks.clusterAutoscaler.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
3739
| hooks.clusterAutoscaler.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cluster-autoscaler-helm-values-template"` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.create }}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: '{{ .Values.hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.name }}'
9+
data:
10+
values.yaml: |-
11+
---
12+
prismCentralEndPoint: {{ `{{ .PrismCentralHost }}` }}
13+
prismCentralPort: {{ `{{ .PrismCentralPort }}` }}
14+
prismCentralInsecure: {{ `{{ .PrismCentralInsecure }}` }}
15+
prismCentralAdditionalTrustBundle: {{ `"{{ or .PrismCentralAdditionalTrustBundle "" }}"` }}
16+
17+
# The Secret containing the credentials will be created by the handler.
18+
createSecret: false
19+
secretName: nutanix-ccm-credentials
20+
{{- end -}}

charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ data:
1919
ChartName: node-feature-discovery
2020
ChartVersion: 0.15.2
2121
RepositoryURL: https://kubernetes-sigs.github.io/node-feature-discovery/charts
22+
nutanix-ccm: |
23+
ChartName: nutanix-cloud-provider
24+
ChartVersion: 0.3.3
25+
RepositoryURL: https://nutanix.github.io/helm/
2226
nutanix-snapshot-csi: |
2327
ChartName: nutanix-csi-snapshot
2428
ChartVersion: v6.3.2

charts/cluster-api-runtime-extensions-nutanix/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ hooks:
4949
defaultValueTemplateConfigMap:
5050
create: true
5151
name: default-nutanix-csi-helm-values-template
52+
ccm:
53+
nutanix:
54+
helmAddonStrategy:
55+
defaultValueTemplateConfigMap:
56+
create: true
57+
name: default-nutanix-ccm-helm-values-template
5258
nfd:
5359
crsStrategy:
5460
defaultInstallationConfigMap:

0 commit comments

Comments
 (0)