Skip to content

Commit

Permalink
implementation of cloud provider config update
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Belgaied Hassine <[email protected]>
  • Loading branch information
belgaied2 committed Nov 25, 2024
1 parent 2aa1d01 commit a00ecf3
Show file tree
Hide file tree
Showing 13 changed files with 752 additions and 88 deletions.
51 changes: 45 additions & 6 deletions api/v1alpha1/harvestercluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ import (
)

const (
// ClusterFinalizer allows ReconcileHarvesterCluster to clean up resources associated with HarvesterCluster before.
ClusterFinalizer = "harvester.infrastructure.cluster.x-k8s.io"
DHCP = "dhcp"
POOL = "pool"
// DHCP is one of the possible values for the IPAMType field in the LoadBalancerConfig.
DHCP = "dhcp"
// POOL is one of the possible values for the IPAMType field in the LoadBalancerConfig.
POOL = "pool"
)

const (
// LoadBalancerReadyCondition documents the status of the load balancer in Harvester.
LoadBalancerReadyCondition clusterv1.ConditionType = "LoadBalancerReady"
// LoadBalancerNotReadyReason documents the reason why the load balancer is not ready.
LoadBalancerNotReadyReason = "LoadBalancerNotReady"
// LoadBalancerReadyMessage documents the message why the load balancer is not ready.
LoadBalancerNotReadyReason = "The Load Balancer is not ready"
// LoadBalancerNoBackendMachineReason documents that there are no machines matching the load balancer configuration.
LoadBalancerNoBackendMachineReason = "There are no machines matching the load balancer configuration"
// LoadBalancerHealthcheckFailedReason documents the reason why the load balancer is not ready.
LoadBalancerHealthcheckFailedReason = "The healthcheck for the load balancer failed"
Expand All @@ -44,13 +47,22 @@ const (
CustomPoolCreationInHarvesterFailedReason = "The custom Pool creation in Harvester failed"
// CustomIPPoolCreatedSuccessfullyReason documents the reason why Custom IP Pool was created.
CustomIPPoolCreatedSuccessfullyReason = "Custom IP Pool was successfully created"

// CloudProviderConfigReadyCondition documents the status of the cloud provider configuration in Harvester.
CloudProviderConfigReadyCondition clusterv1.ConditionType = "CloudProviderConfigReady"
// CloudProviderConfigNotReadyReason documents the reason why the cloud provider configuration is not ready.
CloudProviderConfigNotReadyReason = "The Cloud Provider configuration is not ready"
// CloudProviderConfigGenerationFailedReason documents the reason why the cloud provider configuration generation failed.
CloudProviderConfigGenerationFailedReason = "The Cloud Provider configuration generation failed"
// CloudProviderConfigGeneratedSuccessfullyReason documents the reason why the cloud provider configuration was generated.
CloudProviderConfigGeneratedSuccessfullyReason = "The Cloud Provider configuration was generated successfully"
)

const (
// InitMachineCreatedCondition documents the status of the init machine in Harvester.
InitMachineCreatedCondition clusterv1.ConditionType = "InitMachineCreated"
// InitMachineNotCreatedReason documents the reason why the init machine is not ready.
InitMachineNotYetCreatedReason = "InitMachineNotYetCreated"
// InitMachineNotYetCreatedReason documents the reason why the init machine is not ready.
InitMachineNotYetCreatedReason = "Init Machine not yet created"
)

// HarvesterClusterSpec defines the desired state of HarvesterCluster.
Expand All @@ -71,8 +83,14 @@ type HarvesterClusterSpec struct {

// TargetNamespace is the namespace on the Harvester cluster where VMs, Load Balancers, etc. should be created.
TargetNamespace string `json:"targetNamespace"`

// UpdateCloudProviderConfig if not empty, will trigger the generation of the cloud provider configuration.
// It needs a reference to a ConfigMap containing the cloud provider deployment manifests, that are used by a ClusterResourceSet.
// +optional
UpdateCloudProviderConfig UpdateCloudProviderConfig `json:"updateCloudProviderConfig,omitempty"`
}

// SecretKey is a reference to a Secret which stores Identity information for the Target Harvester Cluster.
type SecretKey struct {
// Namespace is the namespace in which the required Identity Secret should be found.
Namespace string `json:"namespace"`
Expand All @@ -81,6 +99,7 @@ type SecretKey struct {
Name string `json:"name"`
}

// LoadBalancerConfig describes how the load balancer should be created in Harvester.
type LoadBalancerConfig struct {
// IPAMType is the configuration of IP addressing for the control plane load balancer.
// This can take two values, either "dhcp" or "ippool".
Expand Down Expand Up @@ -146,6 +165,26 @@ type Listener struct {
BackendPort int32 `json:"backendPort"`
}

// UpdateCloudProviderConfig is a reference to a ConfigMap containing the cloud provider deployment manifests.
// If you want to generate the cloud provider configuration, the cloud config will need a Harvester Endpoint. This is provider by `HarvesterCluster.Spec.ControlPlaneEndpoint`.
// Beware this does not work with an endpoint that uses a Rancher proxy!
type UpdateCloudProviderConfig struct {
// ManifestsConfigMapNamespace is the namespace in which the required ConfigMap should be found.
ManifestsConfigMapNamespace string `json:"manifestsConfigMapNamespace"`

// ManifestsConfigMapName is the name of the required ConfigMap.
ManifestsConfigMapName string `json:"manifestsConfigMapName"`

// ManifestConfigMapKey is the key in the ConfigMap that contains the cloud provider deployment manifests.
ManifestConfigMapKey string `json:"manifestConfigMapKey"`

// CloudConfigCredentialsSecretName is the name of the secret containing the cloud provider credentials.
CloudConfigCredentialsSecretName string `json:"cloudConfigCredentialsSecretName"`

// CloudConfigCredentialsSecretKey is the key in the secret that contains the cloud provider credentials.
CloudConfigCredentialsSecretKey string `json:"cloudConfigCredentialsSecretKey"`
}

// HarvesterClusterStatus defines the observed state of HarvesterCluster.
type HarvesterClusterStatus struct {
// Ready describes if the Harvester Cluster can be considered ready for machine creation.
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/harvestermachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type HarvesterMachineSpec struct {
WorkloadAffinity *corev1.PodAffinity `json:"workloadAffinity,omitempty"`
}

// Volume defines a volume that should be attached to the VM.
type Volume struct {
// VolumeType is the type of volume to attach.
// Choose between: "storageClass" or "image"
Expand Down
16 changes: 16 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.

Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,38 @@ spec:
description: TargetNamespace is the namespace on the Harvester cluster
where VMs, Load Balancers, etc. should be created.
type: string
updateCloudProviderConfig:
description: |-
UpdateCloudProviderConfig if not empty, will trigger the generation of the cloud provider configuration.
It needs a reference to a ConfigMap containing the cloud provider deployment manifests, that are used by a ClusterResourceSet.
properties:
cloudConfigCredentialsSecretKey:
description: CloudConfigCredentialsSecretKey is the key in the
secret that contains the cloud provider credentials.
type: string
cloudConfigCredentialsSecretName:
description: CloudConfigCredentialsSecretName is the name of the
secret containing the cloud provider credentials.
type: string
manifestConfigMapKey:
description: ManifestConfigMapKey is the key in the ConfigMap
that contains the cloud provider deployment manifests.
type: string
manifestsConfigMapName:
description: ManifestsConfigMapName is the name of the required
ConfigMap.
type: string
manifestsConfigMapNamespace:
description: ManifestsConfigMapNamespace is the namespace in which
the required ConfigMap should be found.
type: string
required:
- cloudConfigCredentialsSecretKey
- cloudConfigCredentialsSecretName
- manifestConfigMapKey
- manifestsConfigMapName
- manifestsConfigMapNamespace
type: object
required:
- identitySecret
- loadBalancerConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ spec:
volumes:
description: Volumes is a list of Volumes to attach to the VM
items:
description: Volume defines a volume that should be attached to
the VM.
properties:
bootOrder:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ spec:
description: Volumes is a list of Volumes to attach to the
VM
items:
description: Volume defines a volume that should be attached
to the VM.
properties:
bootOrder:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,38 @@ spec:
description: TargetNamespace is the namespace on the Harvester
cluster where VMs, Load Balancers, etc. should be created.
type: string
updateCloudProviderConfig:
description: |-
UpdateCloudProviderConfig if not empty, will trigger the generation of the cloud provider configuration.
It needs a reference to a ConfigMap containing the cloud provider deployment manifests, that are used by a ClusterResourceSet.
properties:
cloudConfigCredentialsSecretKey:
description: CloudConfigCredentialsSecretKey is the key
in the secret that contains the cloud provider credentials.
type: string
cloudConfigCredentialsSecretName:
description: CloudConfigCredentialsSecretName is the name
of the secret containing the cloud provider credentials.
type: string
manifestConfigMapKey:
description: ManifestConfigMapKey is the key in the ConfigMap
that contains the cloud provider deployment manifests.
type: string
manifestsConfigMapName:
description: ManifestsConfigMapName is the name of the
required ConfigMap.
type: string
manifestsConfigMapNamespace:
description: ManifestsConfigMapNamespace is the namespace
in which the required ConfigMap should be found.
type: string
required:
- cloudConfigCredentialsSecretKey
- cloudConfigCredentialsSecretName
- manifestConfigMapKey
- manifestsConfigMapName
- manifestsConfigMapNamespace
type: object
required:
- identitySecret
- loadBalancerConfig
Expand Down
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down
Loading

0 comments on commit a00ecf3

Please sign in to comment.