Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
convert additionaldeployments and additionalservices to annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Gan authored and LavenderQAQ committed Feb 18, 2023
1 parent ac5710c commit 1ffe70e
Show file tree
Hide file tree
Showing 8 changed files with 8,842 additions and 10,208 deletions.
4,328 changes: 1,957 additions & 2,371 deletions EdgeXConfig/config-nosecty.yaml

Large diffs are not rendered by default.

14,497 changes: 6,722 additions & 7,775 deletions EdgeXConfig/config.yaml

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions api/v1alpha1/edgex_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ limitations under the License.
package v1alpha1

import (
"encoding/json"

"github.com/openyurtio/yurt-edgex-manager/api/v1alpha2"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
Expand All @@ -39,7 +41,26 @@ func (src *EdgeX) ConvertTo(dstRaw conversion.Hub) error {
dst.Status.UnreadyComponentNum = src.Status.DeploymentReplicas - src.Status.DeploymentReadyReplicas
dst.Status.Conditions = src.Status.Conditions

// Transform additionaldeployment
if len(src.Spec.AdditionalDeployment) > 0 {
additionalDeployment, err := json.Marshal(src.Spec.AdditionalDeployment)
if err != nil {
return err
}
dst.ObjectMeta.Annotations["AdditionalDeployments"] = string(additionalDeployment)
}

// Transform additionalservice
if len(src.Spec.AdditionalDeployment) > 0 {
additionalService, err := json.Marshal(src.Spec.AdditionalService)
if err != nil {
return err
}
dst.ObjectMeta.Annotations["AdditionalServices"] = string(additionalService)
}

//TODO: Components

return nil
}
func (dst *EdgeX) ConvertFrom(srcRaw conversion.Hub) error {
Expand All @@ -64,6 +85,26 @@ func (dst *EdgeX) ConvertFrom(srcRaw conversion.Hub) error {
dst.Status.DeploymentReplicas = src.Status.ReadyComponentNum + src.Status.UnreadyComponentNum
dst.Status.Conditions = src.Status.Conditions

// Transform additionaldeployment
if _, ok := src.ObjectMeta.Annotations["AdditionalDeployments"]; ok {
var additionalDeployments []DeploymentTemplateSpec = make([]DeploymentTemplateSpec, 0)
err := json.Unmarshal([]byte(src.ObjectMeta.Annotations["AdditionalDeployments"]), &additionalDeployments)
if err != nil {
return err
}
dst.Spec.AdditionalDeployment = additionalDeployments
}

// Transform additionalservice
if _, ok := src.ObjectMeta.Annotations["AdditionalServices"]; ok {
var additionalServices []ServiceTemplateSpec = make([]ServiceTemplateSpec, 0)
err := json.Unmarshal([]byte(src.ObjectMeta.Annotations["AdditionalServices"]), &additionalServices)
if err != nil {
return err
}
dst.Spec.AdditionalService = additionalServices
}

//TODO: AdditionalService and AdditionalDeployment
return nil
}
8 changes: 4 additions & 4 deletions config/samples/hangzhou.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: edgex-sample-hangzhou
spec:
version: hanoi
poolname: hangzhou
additinalservices:
poolName: hangzhou
additionalServices:
- metadata:
name: edgex-device-virtual
spec:
Expand All @@ -18,7 +18,7 @@ spec:
protocol: TCP
targetPort: 49990
nodePort: 30090
additinaldeployments:
additionalDeployments:
- metadata:
name: edgex-device-virtual
spec:
Expand All @@ -41,7 +41,7 @@ spec:
containerPort: 49990
envFrom:
- configMapRef:
name: common-variables
name: common-variable-hanoi
env:
- name: Service_Host
value: "edgex-device-virtual"
11 changes: 5 additions & 6 deletions config/samples/jakarta-sak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: edgex-sample-hangzhou
spec:
version: jakarta
poolname: hangzhou
additinalservices:
poolName: beijing
additionalServices:
- metadata:
name: edgex-device-sak
spec:
Expand All @@ -18,7 +18,7 @@ spec:
protocol: TCP
targetPort: 59100
nodePort: 30090
additinaldeployments:
additionalDeployments:
- metadata:
name: edgex-device-sak
spec:
Expand All @@ -41,9 +41,8 @@ spec:
containerPort: 59100
envFrom:
- configMapRef:
name: common-variables
name: common-variable-jakarta
env:
- name: SERVICE_HOST
value: "edgex-device-sak"
securityContext:
privileged: true

61 changes: 61 additions & 0 deletions controllers/edgex_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"encoding/json"
"reflect"
"time"

Expand Down Expand Up @@ -161,6 +162,13 @@ func (r *EdgeXReconciler) reconcileDelete(ctx context.Context, edgex *devicev1al
} else {
desiredComponents = NoSectyComponents[edgex.Spec.Version]
}

additionalComponents, err := annotationToComponent(edgex.Annotations)
if err != nil {
return ctrl.Result{}, err
}
desiredComponents = append(desiredComponents, additionalComponents...)

//TODO: handle edgex.Spec.Components

for _, dc := range desiredComponents {
Expand Down Expand Up @@ -285,6 +293,13 @@ func (r *EdgeXReconciler) reconcileComponent(ctx context.Context, edgex *devicev
} else {
desireComponents = NoSectyComponents[edgex.Spec.Version]
}

additionalComponents, err := annotationToComponent(edgex.Annotations)
if err != nil {
return false, err
}
desireComponents = append(desireComponents, additionalComponents...)

//TODO: handle edgex.Spec.Components

defer func() {
Expand Down Expand Up @@ -459,6 +474,52 @@ func (r *EdgeXReconciler) handleYurtAppSet(ctx context.Context, edgex *devicev1a
return ud, nil
}

// For version compatibility, v1alpha1's additionalservice and additionaldeployment are placed in
// v2alpha2's annotation, this function is to convert the annotation to component.
func annotationToComponent(annotation map[string]string) ([]*Component, error) {
var components []*Component = []*Component{}
var additionalDeployments []devicev1alpha1.DeploymentTemplateSpec = make([]devicev1alpha1.DeploymentTemplateSpec, 0)
err := json.Unmarshal([]byte(annotation["AdditionalDeployments"]), &additionalDeployments)
if err != nil {
return nil, err
}
var additionalServices []devicev1alpha1.ServiceTemplateSpec = make([]devicev1alpha1.ServiceTemplateSpec, 0)
err = json.Unmarshal([]byte(annotation["AdditionalServices"]), &additionalServices)
if err != nil {
return nil, err
}
var services map[string]*corev1.ServiceSpec = make(map[string]*corev1.ServiceSpec)
var usedServices map[string]struct{} = make(map[string]struct{})
for _, additionalservice := range additionalServices {
services[additionalservice.Name] = &additionalservice.Spec
}
for _, additionalDeployment := range additionalDeployments {
var component Component
component.Name = additionalDeployment.Name
component.Deployment = &additionalDeployment.Spec
service, ok := services[component.Name]
if ok {
component.Service = service
usedServices[component.Name] = struct{}{}
}
components = append(components, &component)
}
if len(usedServices) < len(services) {
for name, service := range services {
_, ok := usedServices[name]
if ok {
continue
}
var component Component
component.Name = name
component.Service = service
components = append(components, &component)
}
}

return components, nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *EdgeXReconciler) SetupWithManager(mgr ctrl.Manager) error {

Expand Down
26 changes: 13 additions & 13 deletions tools/collector/config/multiarch_imagelist.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
redis:7.0.5-alpine
consul:1.13.2
postgres:13.8-alpine
lfedge/ekuiper:1.7.1-alpine
vault:1.11.4
redis:7.0.5-alpine
consul:1.13.2
kong:2.8.1
postgres:13.4-alpine
consul:1.10.3
vault:1.8.4
lfedge/ekuiper:1.4.4-alpine
kong:2.5.1
vault:1.8.4
redis:6.2.6-alpine
postgres:13.5-alpine
lfedge/ekuiper:1.4.4-alpine
postgres:13.4-alpine
consul:1.10.3
vault:1.8.9
kong:2.6.1
redis:6.2.6-alpine
consul:1.10.10
lfedge/ekuiper:1.4.4-alpine
redis:6.2.6-alpine
vault:1.7.2
postgres:13.5-alpine
kong:2.4.1-alpine
vault:1.7.2
lfedge/ekuiper:1.3.0-alpine
consul:1.9.5
redis:6.2.4-alpine
postgres:12.3-alpine
redis:6.2.4-alpine
consul:1.9.5
vault:1.5.3
kong:2.0.5
emqx/kuiper:1.1.1-alpine
redis:6.0.9-alpine
postgres:12.3-alpine
kong:2.0.5
kong:2.0.5
redis:6.0.9-alpine
78 changes: 39 additions & 39 deletions tools/collector/config/singlearch_imagelist.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
edgexfoundry/support-scheduler:2.3.0 edgexfoundry/support-scheduler-arm64:2.3.0
edgexfoundry/security-bootstrapper:2.3.0 edgexfoundry/security-bootstrapper-arm64:2.3.0
edgexfoundry/core-command:2.3.0 edgexfoundry/core-command-arm64:2.3.0
edgexfoundry/security-secretstore-setup:2.3.0 edgexfoundry/security-secretstore-setup-arm64:2.3.0
edgexfoundry/sys-mgmt-agent:2.3.0 edgexfoundry/sys-mgmt-agent-arm64:2.3.0
edgexfoundry/device-virtual:2.3.0 edgexfoundry/device-virtual-arm64:2.3.0
edgexfoundry/app-service-configurable:2.3.0 edgexfoundry/app-service-configurable-arm64:2.3.0
edgexfoundry/edgex-ui:2.3.0 edgexfoundry/edgex-ui-arm64:2.3.0
edgexfoundry/core-data:2.3.0 edgexfoundry/core-data-arm64:2.3.0
edgexfoundry/device-rest:2.3.0 edgexfoundry/device-rest-arm64:2.3.0
edgexfoundry/support-notifications:2.3.0 edgexfoundry/support-notifications-arm64:2.3.0
edgexfoundry/edgex-ui:2.3.0 edgexfoundry/edgex-ui-arm64:2.3.0
edgexfoundry/security-secretstore-setup:2.3.0 edgexfoundry/security-secretstore-setup-arm64:2.3.0
edgexfoundry/core-metadata:2.3.0 edgexfoundry/core-metadata-arm64:2.3.0
edgexfoundry/security-bootstrapper:2.3.0 edgexfoundry/security-bootstrapper-arm64:2.3.0
edgexfoundry/support-scheduler:2.3.0 edgexfoundry/support-scheduler-arm64:2.3.0
edgexfoundry/core-command:2.3.0 edgexfoundry/core-command-arm64:2.3.0
edgexfoundry/support-notifications:2.3.0 edgexfoundry/support-notifications-arm64:2.3.0
edgexfoundry/app-service-configurable:2.3.0 edgexfoundry/app-service-configurable-arm64:2.3.0
edgexfoundry/security-proxy-setup:2.3.0 edgexfoundry/security-proxy-setup-arm64:2.3.0
edgexfoundry/security-proxy-setup:2.1.1 edgexfoundry/security-proxy-setup-arm64:2.1.1
edgexfoundry/support-scheduler:2.1.1 edgexfoundry/support-scheduler-arm64:2.1.1
edgexfoundry/device-rest:2.1.1 edgexfoundry/device-rest-arm64:2.1.1
edgexfoundry/core-command:2.1.1 edgexfoundry/core-command-arm64:2.1.1
edgexfoundry/core-metadata:2.1.1 edgexfoundry/core-metadata-arm64:2.1.1
edgexfoundry/sys-mgmt-agent:2.1.1 edgexfoundry/sys-mgmt-agent-arm64:2.1.1
edgexfoundry/edgex-ui:2.1.0 edgexfoundry/edgex-ui-arm64:2.1.0
edgexfoundry/device-virtual:2.1.1 edgexfoundry/device-virtual-arm64:2.1.1
edgexfoundry/security-secretstore-setup:2.1.1 edgexfoundry/security-secretstore-setup-arm64:2.1.1
edgexfoundry/support-notifications:2.1.1 edgexfoundry/support-notifications-arm64:2.1.1
edgexfoundry/core-data:2.1.1 edgexfoundry/core-data-arm64:2.1.1
edgexfoundry/edgex-ui:2.1.0 edgexfoundry/edgex-ui-arm64:2.1.0
edgexfoundry/support-scheduler:2.1.1 edgexfoundry/support-scheduler-arm64:2.1.1
edgexfoundry/app-service-configurable:2.1.1 edgexfoundry/app-service-configurable-arm64:2.1.1
edgexfoundry/device-rest:2.1.1 edgexfoundry/device-rest-arm64:2.1.1
edgexfoundry/core-metadata:2.1.1 edgexfoundry/core-metadata-arm64:2.1.1
edgexfoundry/core-command:2.1.1 edgexfoundry/core-command-arm64:2.1.1
edgexfoundry/security-bootstrapper:2.1.1 edgexfoundry/security-bootstrapper-arm64:2.1.1
edgexfoundry/security-secretstore-setup:2.1.1 edgexfoundry/security-secretstore-setup-arm64:2.1.1
edgexfoundry/device-virtual:2.1.1 edgexfoundry/device-virtual-arm64:2.1.1
edgexfoundry/security-proxy-setup:2.1.1 edgexfoundry/security-proxy-setup-arm64:2.1.1
edgexfoundry/security-bootstrapper:2.2.0 edgexfoundry/security-bootstrapper-arm64:2.2.0
edgexfoundry/support-scheduler:2.2.0 edgexfoundry/support-scheduler-arm64:2.2.0
edgexfoundry/edgex-ui:2.2.0 edgexfoundry/edgex-ui-arm64:2.2.0
edgexfoundry/support-notifications:2.2.0 edgexfoundry/support-notifications-arm64:2.2.0
edgexfoundry/core-command:2.2.0 edgexfoundry/core-command-arm64:2.2.0
edgexfoundry/device-rest:2.2.0 edgexfoundry/device-rest-arm64:2.2.0
edgexfoundry/security-proxy-setup:2.2.0 edgexfoundry/security-proxy-setup-arm64:2.2.0
edgexfoundry/security-secretstore-setup:2.2.0 edgexfoundry/security-secretstore-setup-arm64:2.2.0
edgexfoundry/support-scheduler:2.2.0 edgexfoundry/support-scheduler-arm64:2.2.0
edgexfoundry/core-metadata:2.2.0 edgexfoundry/core-metadata-arm64:2.2.0
edgexfoundry/sys-mgmt-agent:2.2.0 edgexfoundry/sys-mgmt-agent-arm64:2.2.0
edgexfoundry/support-notifications:2.2.0 edgexfoundry/support-notifications-arm64:2.2.0
edgexfoundry/device-virtual:2.2.0 edgexfoundry/device-virtual-arm64:2.2.0
edgexfoundry/core-data:2.2.0 edgexfoundry/core-data-arm64:2.2.0
edgexfoundry/app-service-configurable:2.2.0 edgexfoundry/app-service-configurable-arm64:2.2.0
edgexfoundry/security-proxy-setup:2.2.0 edgexfoundry/security-proxy-setup-arm64:2.2.0
edgexfoundry/core-data:2.2.0 edgexfoundry/core-data-arm64:2.2.0
edgexfoundry/device-virtual:2.2.0 edgexfoundry/device-virtual-arm64:2.2.0
edgexfoundry/sys-mgmt-agent:2.2.0 edgexfoundry/sys-mgmt-agent-arm64:2.2.0
edgexfoundry/edgex-ui:2.2.0 edgexfoundry/edgex-ui-arm64:2.2.0
edgexfoundry/device-rest:2.0.0 edgexfoundry/device-rest-arm64:2.0.0
edgexfoundry/core-metadata:2.0.0 edgexfoundry/core-metadata-arm64:2.0.0
edgexfoundry/security-proxy-setup:2.0.0 edgexfoundry/security-proxy-setup-arm64:2.0.0
edgexfoundry/sys-mgmt-agent:2.0.0 edgexfoundry/sys-mgmt-agent-arm64:2.0.0
edgexfoundry/security-secretstore-setup:2.0.0 edgexfoundry/security-secretstore-setup-arm64:2.0.0
edgexfoundry/core-data:2.0.0 edgexfoundry/core-data-arm64:2.0.0
edgexfoundry/device-virtual:2.0.0 edgexfoundry/device-virtual-arm64:2.0.0
edgexfoundry/security-bootstrapper:2.0.0 edgexfoundry/security-bootstrapper-arm64:2.0.0
edgexfoundry/app-service-configurable:2.0.1 edgexfoundry/app-service-configurable-arm64:2.0.1
edgexfoundry/security-bootstrapper:2.0.0 edgexfoundry/security-bootstrapper-arm64:2.0.0
edgexfoundry/core-metadata:2.0.0 edgexfoundry/core-metadata-arm64:2.0.0
edgexfoundry/sys-mgmt-agent:2.0.0 edgexfoundry/sys-mgmt-agent-arm64:2.0.0
edgexfoundry/support-scheduler:2.0.0 edgexfoundry/support-scheduler-arm64:2.0.0
edgexfoundry/core-command:2.0.0 edgexfoundry/core-command-arm64:2.0.0
edgexfoundry/security-proxy-setup:2.0.0 edgexfoundry/security-proxy-setup-arm64:2.0.0
edgexfoundry/core-data:2.0.0 edgexfoundry/core-data-arm64:2.0.0
edgexfoundry/security-secretstore-setup:2.0.0 edgexfoundry/security-secretstore-setup-arm64:2.0.0
edgexfoundry/support-notifications:2.0.0 edgexfoundry/support-notifications-arm64:2.0.0
edgexfoundry/docker-security-secrets-setup-go:1.3.1 edgexfoundry/docker-security-secrets-setup-go-arm64:1.3.1
edgexfoundry/docker-core-data-go:1.3.1 edgexfoundry/docker-core-data-go-arm64:1.3.1
edgexfoundry/docker-security-secretstore-setup-go:1.3.1 edgexfoundry/docker-security-secretstore-setup-go-arm64:1.3.1
edgexfoundry/docker-app-service-configurable:1.3.1 edgexfoundry/docker-app-service-configurable-arm64:1.3.1
edgexfoundry/docker-support-scheduler-go:1.3.1 edgexfoundry/docker-support-scheduler-go-arm64:1.3.1
edgexfoundry/docker-support-notifications-go:1.3.1 edgexfoundry/docker-support-notifications-go-arm64:1.3.1
edgexfoundry/docker-device-virtual-go:1.3.1 edgexfoundry/docker-device-virtual-go-arm64:1.3.1
edgexfoundry/docker-core-command-go:1.3.1 edgexfoundry/docker-core-command-go-arm64:1.3.1
edgexfoundry/docker-device-rest-go:1.2.1 edgexfoundry/docker-device-rest-go-arm64:1.2.1
edgexfoundry/docker-security-proxy-setup-go:1.3.1 edgexfoundry/docker-security-proxy-setup-go-arm64:1.3.1
edgexfoundry/docker-sys-mgmt-agent-go:1.3.1 edgexfoundry/docker-sys-mgmt-agent-go-arm64:1.3.1
edgexfoundry/docker-core-data-go:1.3.1 edgexfoundry/docker-core-data-go-arm64:1.3.1
edgexfoundry/docker-security-secrets-setup-go:1.3.1 edgexfoundry/docker-security-secrets-setup-go-arm64:1.3.1
edgexfoundry/docker-core-metadata-go:1.3.1 edgexfoundry/docker-core-metadata-go-arm64:1.3.1
edgexfoundry/docker-security-bootstrap-redis-go:1.3.1 edgexfoundry/docker-security-bootstrap-redis-go-arm64:1.3.1
edgexfoundry/docker-app-service-configurable:1.3.1 edgexfoundry/docker-app-service-configurable-arm64:1.3.1
edgexfoundry/docker-edgex-consul:1.3.0 edgexfoundry/docker-edgex-consul-arm64:1.3.0
edgexfoundry/docker-security-proxy-setup-go:1.3.1 edgexfoundry/docker-security-proxy-setup-go-arm64:1.3.1
edgexfoundry/docker-security-bootstrap-redis-go:1.3.1 edgexfoundry/docker-security-bootstrap-redis-go-arm64:1.3.1
edgexfoundry/docker-core-command-go:1.3.1 edgexfoundry/docker-core-command-go-arm64:1.3.1
edgexfoundry/docker-sys-mgmt-agent-go:1.3.1 edgexfoundry/docker-sys-mgmt-agent-go-arm64:1.3.1
edgexfoundry/docker-device-rest-go:1.2.1 edgexfoundry/docker-device-rest-go-arm64:1.2.1
edgexfoundry/docker-support-notifications-go:1.3.1 edgexfoundry/docker-support-notifications-go-arm64:1.3.1
edgexfoundry/docker-device-virtual-go:1.3.1 edgexfoundry/docker-device-virtual-go-arm64:1.3.1
edgexfoundry/docker-security-secretstore-setup-go:1.3.1 edgexfoundry/docker-security-secretstore-setup-go-arm64:1.3.1

0 comments on commit 1ffe70e

Please sign in to comment.