Skip to content
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
53 changes: 28 additions & 25 deletions api/v1alpha1/clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,33 @@ type NutanixClusterConfigSpec struct {

// +kubebuilder:object:root=true

// EKSClusterConfig is the Schema for the eksclusterconfigs API.
type EKSClusterConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +kubebuilder:validation:Optional
Spec EKSClusterConfigSpec `json:"spec,omitempty"`
}

func (s EKSClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
return eksClusterConfigVariableSchema
}

// EKSClusterConfigSpec defines the desired state of ClusterConfig.
type EKSClusterConfigSpec struct {
// EKS cluster configuration.
// +kubebuilder:validation:Optional
EKS *EKSSpec `json:"eks,omitempty"`

GenericClusterConfigSpec `json:",inline"`

// +kubebuilder:validation:Optional
Addons *AWSAddons `json:"addons,omitempty"`
}

// +kubebuilder:object:root=true

// KubeadmClusterConfig is the Schema for the kubeadmconfigs API.
type KubeadmClusterConfig struct {
metav1.TypeMeta `json:",inline"`
Expand Down Expand Up @@ -257,31 +284,6 @@ type GenericClusterConfigSpec struct {
NTP *NTP `json:"ntp,omitempty"`
}

// +kubebuilder:object:root=true

// EKSClusterConfig is the Schema for the eksclusterconfigs API.
type EKSClusterConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +kubebuilder:validation:Optional
Spec EKSClusterConfigSpec `json:"spec,omitempty"`
}

func (s EKSClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
return eksClusterConfigVariableSchema
}

// EKSClusterConfigSpec defines the desired state of ClusterConfig.
type EKSClusterConfigSpec struct {
// EKS cluster configuration.
// +kubebuilder:validation:Optional
EKS *EKSSpec `json:"eks,omitempty"`

// +kubebuilder:validation:Optional
Addons *AWSAddons `json:"addons,omitempty"`
}

type Image struct {
// Repository is used to override the image repository to pull from.
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -444,5 +446,6 @@ func init() {
&AWSClusterConfig{},
&DockerClusterConfig{},
&NutanixClusterConfig{},
&EKSClusterConfig{},
)
}
147 changes: 147 additions & 0 deletions api/v1alpha1/crds/caren.nutanix.com_eksclusterconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,153 @@ spec:
minLength: 4
type: string
type: object
globalImageRegistryMirror:
description: GlobalImageRegistryMirror sets default mirror configuration
for all the image registries.
properties:
credentials:
description: Credentials and CA certificate for the image registry
mirror
properties:
secretRef:
description: |-
A reference to the Secret containing the registry credentials and optional CA certificate
using the keys `username`, `password` and `ca.crt`.
This credentials Secret is not required for some registries, e.g. ECR.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
maxLength: 253
minLength: 1
type: string
required:
- name
type: object
type: object
url:
description: Registry mirror URL.
format: uri
pattern: ^https?://
type: string
required:
- url
type: object
imageRegistries:
items:
properties:
credentials:
description: Credentials and CA certificate for the image registry
properties:
secretRef:
description: |-
A reference to the Secret containing the registry credentials and optional CA certificate
using the keys `username`, `password` and `ca.crt`.
This credentials Secret is not required for some registries, e.g. ECR.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
maxLength: 253
minLength: 1
type: string
required:
- name
type: object
type: object
url:
description: Registry URL.
format: uri
pattern: ^https?://
type: string
required:
- url
type: object
maxItems: 32
type: array
ntp:
description: NTP defines the NTP configuration for the cluster.
properties:
servers:
description: Servers is a list of NTP servers to use for time
synchronization.
items:
maxLength: 253
type: string
maxItems: 16
minItems: 1
type: array
required:
- servers
type: object
proxy:
description: HTTPProxy required for providing proxy configuration.
properties:
additionalNo:
description: |-
AdditionalNo Proxy list that will be added to the automatically calculated
values that will apply no_proxy configuration for cluster internal network.
Default values: localhost,127.0.0.1,<POD_NETWORK>,<SERVICE_NETWORK>,kubernetes
,kubernetes.default,.svc,.svc.<SERVICE_DOMAIN>
items:
maxLength: 253
minLength: 1
type: string
maxItems: 128
type: array
http:
description: HTTP proxy value.
maxLength: 2048
minLength: 1
type: string
https:
description: HTTPS proxy value.
maxLength: 2048
minLength: 1
type: string
type: object
users:
items:
description: User defines the input for a generated user in cloud-init.
properties:
hashedPassword:
description: |-
HashedPassword is a hashed password for the user, formatted as described
by the crypt(5) man page. See your distribution's documentation for
instructions to create a hashed password.
An empty string is not marshalled, because it is not a valid value.
maxLength: 106
minLength: 1
type: string
name:
description: Name specifies the user name.
maxLength: 256
type: string
sshAuthorizedKeys:
description: |-
SSHAuthorizedKeys is a list of public SSH keys to write to the
machine. Use the corresponding private SSH keys to authenticate. See SSH
documentation for instructions to create a key pair.
items:
maxLength: 256
type: string
maxItems: 32
type: array
sudo:
description: |-
Sudo is a sudo user specification, formatted as described in the sudo
documentation.
An empty string is not marshalled, because it is not a valid value.
maxLength: 1024
minLength: 1
type: string
required:
- name
type: object
maxItems: 32
type: array
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ spec:
- effect
- key
type: object
maxItems: 32
type: array
type: object
type: object
Expand Down
29 changes: 13 additions & 16 deletions api/v1alpha1/nodeconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,6 @@ type NutanixWorkerNodeConfigSpec struct {
GenericNodeSpec `json:",inline"`
}

type KubeadmNodeSpec struct {
// NodeRegistration holds fields that relate to registering the new node to the cluster.
// +kubebuilder:validation:Optional
// +kubebuilder:default={}
NodeRegistration *NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
}

type GenericNodeSpec struct {
// Taints specifies the taints the Node API object should be registered with.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MaxItems=32
Taints []Taint `json:"taints,omitempty"`
}

// +kubebuilder:object:root=true

// EKSWorkerNodeConfig is the Schema for the eksnodeconfigs API.
Expand All @@ -144,12 +130,23 @@ type EKSWorkerNodeConfigSpec struct {
// +kubebuilder:validation:Optional
EKS *AWSWorkerNodeSpec `json:"eks,omitempty"`

EKSNodeSpec `json:",inline"`
EKSNodeSpec `json:",inline"`
GenericNodeSpec `json:",inline"`
}

type EKSNodeSpec struct{}

type KubeadmNodeSpec struct {
// NodeRegistration holds fields that relate to registering the new node to the cluster.
// +kubebuilder:validation:Optional
// +kubebuilder:default={}
NodeRegistration *NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
}

type EKSNodeSpec struct {
type GenericNodeSpec struct {
// Taints specifies the taints the Node API object should be registered with.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MaxItems=32
Taints []Taint `json:"taints,omitempty"`
}

Expand Down
9 changes: 3 additions & 6 deletions api/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 12 additions & 0 deletions pkg/handlers/generic/mutation/ntp/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
awsclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/clusterconfig"
dockerclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/clusterconfig"
eksclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/eks/clusterconfig"
nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig"
)

Expand Down Expand Up @@ -74,3 +75,14 @@ func TestVariableValidation_Nutanix(t *testing.T) {
testDefs...,
)
}

func TestVariableValidation_EKS(t *testing.T) {
capitest.ValidateDiscoverVariables(
t,
v1alpha1.ClusterConfigVariableName,
ptr.To(v1alpha1.EKSClusterConfig{}.VariableSchema()),
true,
eksclusterconfig.NewVariable,
testDefs...,
)
}
53 changes: 37 additions & 16 deletions pkg/handlers/generic/mutation/taints/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,48 @@ import (

"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
nutanixclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/clusterconfig"
eksworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/eks/workerconfig"
nutanixworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/workerconfig"
)

func TestVariableValidation(t *testing.T) {
func TestVariableValidation_Nutanix(t *testing.T) {
capitest.ValidateDiscoverVariables(
t,
v1alpha1.ClusterConfigVariableName,
ptr.To(v1alpha1.NutanixClusterConfig{}.VariableSchema()),
true,
nutanixclusterconfig.NewVariable,
v1alpha1.WorkerConfigVariableName,
ptr.To(v1alpha1.NutanixWorkerNodeConfig{}.VariableSchema()),
false,
nutanixworkerconfig.NewVariable,
capitest.VariableTestDef{
Name: "specified instance type",
Vals: v1alpha1.NutanixClusterConfigSpec{
ControlPlane: &v1alpha1.NutanixControlPlaneSpec{
GenericNodeSpec: v1alpha1.GenericNodeSpec{
Taints: []v1alpha1.Taint{{
Key: "key",
Effect: v1alpha1.TaintEffectNoExecute,
Value: "value",
}},
},
Name: "specified nodepool taints",
Vals: v1alpha1.NutanixWorkerNodeConfigSpec{
GenericNodeSpec: v1alpha1.GenericNodeSpec{
Taints: []v1alpha1.Taint{{
Key: "key",
Effect: v1alpha1.TaintEffectNoExecute,
Value: "value",
}},
},
},
},
)
}

func TestVariableValidation_EKS(t *testing.T) {
capitest.ValidateDiscoverVariables(
t,
v1alpha1.WorkerConfigVariableName,
ptr.To(v1alpha1.EKSWorkerNodeConfig{}.VariableSchema()),
false,
eksworkerconfig.NewVariable,
capitest.VariableTestDef{
Name: "specified nodepool taints",
Vals: v1alpha1.EKSWorkerNodeConfigSpec{
GenericNodeSpec: v1alpha1.GenericNodeSpec{
Taints: []v1alpha1.Taint{{
Key: "key",
Effect: v1alpha1.TaintEffectNoExecute,
Value: "value",
}},
},
},
},
Expand Down
Loading