From 8f8eae25c60cb510f5b9b69ca2f89e9f8ce6cd15 Mon Sep 17 00:00:00 2001 From: ubombar Date: Wed, 24 Jan 2024 23:50:33 +0100 Subject: [PATCH] change go.work version --- .../yamls/kubernetes/federation-workload.yaml | 400 +++++++++--------- go.work | 2 +- .../selectivedeployment/controller.go | 4 + .../federation/v1alpha1/fedlet/controller.go | 16 +- 4 files changed, 213 insertions(+), 209 deletions(-) diff --git a/build/yamls/kubernetes/federation-workload.yaml b/build/yamls/kubernetes/federation-workload.yaml index 8a61e8db..67e8cf3a 100644 --- a/build/yamls/kubernetes/federation-workload.yaml +++ b/build/yamls/kubernetes/federation-workload.yaml @@ -64,219 +64,219 @@ metadata: spec: group: apps.edgenet.io versions: - - name: v1alpha2 - served: true - storage: true - subresources: - status: {} - additionalPrinterColumns: - - name: Ready - type: string - jsonPath: .status.ready - - name: Status - type: string - jsonPath: .status.state - - name: Age - type: date - jsonPath: .metadata.creationTimestamp - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - required: - - workloads - - clusterAffinity - properties: - workloads: - type: object - properties: - deployment: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - daemonset: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - statefulset: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - job: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - cronjob: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - clusterAffinity: - type: object - properties: - matchExpressions: - type: array - items: - type: object - properties: - key: - type: string - operator: - enum: - - In - - NotIn - - Exists - - DoesNotExist + - name: v1alpha2 + served: true + storage: true + subresources: + status: {} + additionalPrinterColumns: + - name: Ready + type: string + jsonPath: .status.ready + - name: Status + type: string + jsonPath: .status.state + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: + - workloads + - clusterAffinity + properties: + workloads: + type: object + properties: + deployment: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + daemonset: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + statefulset: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + job: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + cronjob: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + clusterAffinity: + type: object + properties: + matchExpressions: + type: array + items: + type: object + properties: + key: + type: string + operator: + enum: + - In + - NotIn + - Exists + - DoesNotExist + type: string + values: + type: array + items: type: string - values: - type: array - items: - type: string - pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" - matchLabels: + pattern: "^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$" + matchLabels: + x-kubernetes-preserve-unknown-fields: true + clusterReplicas: + type: integer + minimum: 1 + status: + type: object + properties: + state: + type: string + message: + type: string + clusters: + type: object + x-kubernetes-preserve-unknown-fields: true + failed: + type: integer + - name: v1alpha1 + served: true + storage: false + subresources: + status: {} + additionalPrinterColumns: + - name: Ready + type: string + jsonPath: .status.ready + - name: Status + type: string + jsonPath: .status.state + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: + - workloads + - selector + properties: + workloads: + type: object + properties: + deployment: + type: array + items: + type: object + x-kubernetes-embedded-resource: true x-kubernetes-preserve-unknown-fields: true - clusterReplicas: - type: integer - minimum: 1 - status: - type: object - properties: - state: - type: string - message: - type: string - clusters: - type: object - x-kubernetes-preserve-unknown-fields: true - failed: - type: integer - - name: v1alpha1 - served: true - storage: false - subresources: - status: {} - additionalPrinterColumns: - - name: Ready - type: string - jsonPath: .status.ready - - name: Status - type: string - jsonPath: .status.state - - name: Age - type: date - jsonPath: .metadata.creationTimestamp - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - required: - - workloads - - selector - properties: - workloads: + nullable: true + daemonset: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + statefulset: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + job: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + cronjob: + type: array + items: + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + nullable: true + selector: + type: array + items: type: object properties: - deployment: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - daemonset: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - statefulset: + name: + type: string + enum: + - City + - State + - Country + - Continent + - Polygon + value: type: array items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - job: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - cronjob: - type: array - items: - type: object - x-kubernetes-embedded-resource: true - x-kubernetes-preserve-unknown-fields: true - nullable: true - selector: - type: array - items: - type: object - properties: - name: type: string - enum: - - City - - State - - Country - - Continent - - Polygon - value: - type: array - items: - type: string - operator: - type: string - enum: - - In - - NotIn - quantity: - type: integer - description: The count of nodes that will be picked for this selector. - minimum: 1 - nullable: true - minimum: 1 - recovery: - type: boolean - status: - type: object - properties: - ready: - type: string - state: + operator: + type: string + enum: + - In + - NotIn + quantity: + type: integer + description: The count of nodes that will be picked for this selector. + minimum: 1 + nullable: true + minimum: 1 + recovery: + type: boolean + status: + type: object + properties: + ready: + type: string + state: + type: string + message: + type: array + items: type: string - message: - type: array - items: - type: string scope: Namespaced names: plural: selectivedeployments singular: selectivedeployment kind: SelectiveDeployment shortNames: - - sd + - sd --- apiVersion: v1 kind: ServiceAccount @@ -457,4 +457,4 @@ spec: - effect: NoSchedule key: node-role.kubernetes.io/control-plane - effect: NoSchedule - key: node.kubernetes.io/unschedulable \ No newline at end of file + key: node.kubernetes.io/unschedulable diff --git a/go.work b/go.work index 96825b12..767c526b 100644 --- a/go.work +++ b/go.work @@ -1,3 +1,3 @@ -go 1.21.5 +go 1.21.3 use . diff --git a/pkg/controller/apps/v1alpha2/selectivedeployment/controller.go b/pkg/controller/apps/v1alpha2/selectivedeployment/controller.go index e2bf08bf..1cb02d09 100644 --- a/pkg/controller/apps/v1alpha2/selectivedeployment/controller.go +++ b/pkg/controller/apps/v1alpha2/selectivedeployment/controller.go @@ -412,7 +412,10 @@ func (c *Controller) processSelectiveDeployment(selectivedeploymentCopy *appsv1a switch selectivedeploymentCopy.Status.State { case appsv1alpha2.StatusCreated: annotations := selectivedeploymentCopy.GetAnnotations() + + // If the selective deployment has the annotation as follower if value, ok := annotations["edge-net.io/selective-deployment"]; ok && value == "follower" { + // Prepare the multi provider manager multiproviderManager, _, ok := c.prepareMultiProviderManager(selectivedeploymentCopy.GetNamespace(), annotations["edge-net.io/origin-selective-deployment-uid"]) if !ok { c.recorder.Event(selectivedeploymentCopy, corev1.EventTypeWarning, appsv1alpha2.StatusReconciliation, messageCredsFailed) @@ -427,6 +430,7 @@ func (c *Controller) processSelectiveDeployment(selectivedeploymentCopy *appsv1a c.updateStatus(context.TODO(), selectivedeploymentCopy, appsv1alpha2.StatusReconciliation, messageWorkloadDeploymentFailed) return } + // Get the address location address, location := multiproviderManager.GetClusterAddressWithLocation() workloadClusterStatus.Location = location workloadClusterStatus.Server = address diff --git a/pkg/controller/federation/v1alpha1/fedlet/controller.go b/pkg/controller/federation/v1alpha1/fedlet/controller.go index df735989..b5ecae7a 100644 --- a/pkg/controller/federation/v1alpha1/fedlet/controller.go +++ b/pkg/controller/federation/v1alpha1/fedlet/controller.go @@ -216,12 +216,12 @@ func (c *Controller) updateClusterResourceStatus() { overallCapacityResources := make(corev1.ResourceList) // Below is the logic to calculate the total allocatable resources and total capacity resources of all nodes in the cluster. // It also prepares the bundledAllocatableResourcesList. - nodeRaw, _ := c.kubeclientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{LabelSelector: "edge-net.io/access=public,edge-net.io/access-scope=federation"}) - if len(nodeRaw.Items) == 0 { + nodesRaw, _ := c.kubeclientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{LabelSelector: "edge-net.io/access=public,edge-net.io/access-scope=federation"}) + if len(nodesRaw.Items) == 0 { return } - for _, nodeRow := range nodeRaw.Items { - for key, value := range nodeRow.Status.Allocatable { + for _, nodeRaw := range nodesRaw.Items { + for key, value := range nodeRaw.Status.Allocatable { if allocatableQuantity, ok := overallAllocatableResources[key]; ok { allocatableQuantity.Add(value) overallAllocatableResources[key] = *resource.NewQuantity(allocatableQuantity.Value(), value.Format) @@ -231,17 +231,17 @@ func (c *Controller) updateClusterResourceStatus() { } if len(bundledAllocatableResourcesList) > 0 { for key, bundledAllocatableResources := range bundledAllocatableResourcesList { - if reflect.DeepEqual(bundledAllocatableResources, nodeRow.Status.Allocatable) { + if reflect.DeepEqual(bundledAllocatableResources, nodeRaw.Status.Allocatable) { bundledAllocatableResourcesList[key].Count++ break } else { - bundledAllocatableResourcesList = append(bundledAllocatableResourcesList, federationv1alpha1.BundledAllocatableResources{Count: 1, ResourceList: nodeRow.Status.Allocatable}) + bundledAllocatableResourcesList = append(bundledAllocatableResourcesList, federationv1alpha1.BundledAllocatableResources{Count: 1, ResourceList: nodeRaw.Status.Allocatable}) } } } else { - bundledAllocatableResourcesList = append(bundledAllocatableResourcesList, federationv1alpha1.BundledAllocatableResources{Count: 1, ResourceList: nodeRow.Status.Allocatable}) + bundledAllocatableResourcesList = append(bundledAllocatableResourcesList, federationv1alpha1.BundledAllocatableResources{Count: 1, ResourceList: nodeRaw.Status.Allocatable}) } - for key, value := range nodeRow.Status.Capacity { + for key, value := range nodeRaw.Status.Capacity { if capacityQuantity, ok := overallCapacityResources[key]; ok { capacityQuantity.Add(value) overallCapacityResources[key] = *resource.NewQuantity(capacityQuantity.Value(), value.Format)