move crds to the helm chart (#34)

* Fixes to the controller and cli

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* Move crds to the helm chart

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

* fix statically configured cluster

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>

---------

Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
Hussein Galal
2023-03-23 21:33:52 +02:00
committed by GitHub
parent dde877e285
commit 7bcc312b4b
4 changed files with 29 additions and 8 deletions
@@ -57,8 +57,12 @@ spec:
status:
type: object
properties:
overrideClusterCIDR:
type: boolean
clusterCIDR:
type: string
overrideServiceCIDR:
type: boolean
serviceCIDR:
type: string
clusterDNS:
+5 -3
View File
@@ -55,9 +55,11 @@ type LoadBalancerConfig struct {
}
type ClusterStatus struct {
ClusterCIDR string `json:"clusterCIDR,omitempty"`
ServiceCIDR string `json:"serviceCIDR,omitempty"`
ClusterDNS string `json:"clusterDNS,omitempty"`
OverrideClusterCIDR bool `json:"overrideClusterCIDR"`
OverrideServiceCIDR bool `json:"overrideServiceCIDR"`
ClusterCIDR string `json:"clusterCIDR,omitempty"`
ServiceCIDR string `json:"serviceCIDR,omitempty"`
ClusterDNS string `json:"clusterDNS,omitempty"`
}
type Allocation struct {
+20 -5
View File
@@ -147,9 +147,16 @@ func (c *ClusterReconciler) Reconcile(ctx context.Context, req reconcile.Request
}
if controllerutil.ContainsFinalizer(&cluster, clusterFinalizerName) {
// TODO: handle CIDR deletion
if err := c.releaseCIDR(ctx, cluster.Status.ClusterCIDR, cluster.Name); err != nil {
return reconcile.Result{}, err
if !cluster.Status.OverrideClusterCIDR {
if err := c.releaseCIDR(ctx, cluster.Status.ClusterCIDR, cluster.Name); err != nil {
return reconcile.Result{}, err
}
}
if !cluster.Status.OverrideServiceCIDR {
if err := c.releaseCIDR(ctx, cluster.Status.ServiceCIDR, cluster.Name); err != nil {
return reconcile.Result{}, err
}
}
// remove our finalizer from the list and update it.
@@ -169,22 +176,30 @@ func (c *ClusterReconciler) createCluster(ctx context.Context, cluster *v1alpha1
return util.WrapErr("failed to create ns", err)
}
if cluster.Spec.ClusterCIDR == "" && cluster.Status.ClusterCIDR == "" {
klog.Info(cluster)
if cluster.Spec.ClusterCIDR == "" {
clusterCIDR, err := c.nextCIDR(ctx, cidrAllocationClusterPoolName, cluster.Name)
if err != nil {
return err
}
cluster.Status.ClusterCIDR = clusterCIDR.String()
} else {
cluster.Status.OverrideClusterCIDR = true
cluster.Status.ClusterCIDR = cluster.Spec.ClusterCIDR
}
if cluster.Spec.ServiceCIDR == "" && cluster.Status.ServiceCIDR == "" {
if cluster.Spec.ServiceCIDR == "" {
serviceCIDR, err := c.nextCIDR(ctx, cidrAllocationServicePoolName, cluster.Name)
if err != nil {
return err
}
cluster.Status.ServiceCIDR = serviceCIDR.String()
} else {
cluster.Status.OverrideServiceCIDR = true
cluster.Status.ClusterCIDR = cluster.Spec.ClusterCIDR
}
klog.Infof("creating cluster service")
serviceIP, err := c.createClusterService(ctx, cluster)
if err != nil {
return util.WrapErr("failed to create cluster service", err)