diff --git a/Makefile b/Makefile index 13c9401..1dbf3dd 100644 --- a/Makefile +++ b/Makefile @@ -67,11 +67,31 @@ image-gen-api: image-gen-swagger: docker buildx build -t frontier-gen-swagger:${VERSION} -f images/Dockerfile.controlplane-swagger . +# push +.PHONY: push +push: push-frontier push-frontlas + +.PHONY: push-frontier +push-frontier: + docker push ${REGISTRY}/frontier:${VERSION} + +.PHONY: push-frontlas +push-frontlas: + docker push ${REGISTRY}/frontlas:${VERSION} + # container +.PHONY: container +container: container-frontier container-frontlas + .PHONY: container-frontier container-frontier: docker rm -f frontier - docker run -d --name frontier -p 2431:2431 -p 2432:2432 frontier:${VERSION} --config /usr/conf/frontier.yaml -v 1 + docker run -d --name frontier -p 30011:30011 -p 30012:30012 ${REGISTRY}/frontier:${VERSION} --config /usr/conf/frontier.yaml -v 1 + +.PHONY: container-frontlas +container-frontlas: + docker rm -f frontlas + docker run -d --name frontlas -p 30021:30021 -p 30022:30022 frontlas:${VERSION} --config /usr/conf/frontlas.yaml -v 1 # api .PHONY: api-frontier diff --git a/etc/frontier.yaml b/etc/frontier.yaml index bc22530..ea7afb4 100644 --- a/etc/frontier.yaml +++ b/etc/frontier.yaml @@ -60,7 +60,7 @@ frontlas: enable: false dial: network: tcp - addr: 127.0.0.1:30021 + addr: 127.0.0.1:30022 metrics: enable: false interval: 0 diff --git a/etc/frontlas.yaml b/etc/frontlas.yaml index 3fe0f22..2542910 100644 --- a/etc/frontlas.yaml +++ b/etc/frontlas.yaml @@ -9,11 +9,11 @@ daemon: control_plane: listen: network: tcp - addr: 0.0.0.0:30020 + addr: 0.0.0.0:30021 frontier_plane: listen: network: tcp - addr: 0.0.0.0:30021 + addr: 0.0.0.0:30022 expiration: service_meta: 30 edge_meta: 30 diff --git a/examples/iclm/service/service.go b/examples/iclm/service/service.go index f16419c..a609004 100644 --- a/examples/iclm/service/service.go +++ b/examples/iclm/service/service.go @@ -72,7 +72,7 @@ func main() { }() network := pflag.String("network", "tcp", "network to dial") address := pflag.String("address", "127.0.0.1:30011", "address to dial") - frontlasAddress := pflag.String("frontlas_address", "127.0.0.1:30020", "frontlas address to dial, mutex with address") + frontlasAddress := pflag.String("frontlas_address", "127.0.0.1:30021", "frontlas address to dial, mutex with address") frontlas := pflag.Bool("frontlas", false, "frontlas or frontier") loglevel := pflag.String("loglevel", "info", "log level, trace debug info warn error") serviceName := pflag.String("service", "foo", "service name") diff --git a/images/Dockerfile.frontlas b/images/Dockerfile.frontlas index bc02359..0a904a2 100644 --- a/images/Dockerfile.frontlas +++ b/images/Dockerfile.frontlas @@ -21,8 +21,8 @@ RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/s RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.34-r0/glibc-2.34-r0.apk RUN apk add glibc-2.34-r0.apk -EXPOSE 30020 EXPOSE 30021 +EXPOSE 30022 ENTRYPOINT ["/usr/bin/frontlas"] CMD ["--config", "/usr/conf/frontlas.yaml"] \ No newline at end of file diff --git a/pkg/frontier/config/config.go b/pkg/frontier/config/config.go index 4b8fd6d..8bce502 100644 --- a/pkg/frontier/config/config.go +++ b/pkg/frontier/config/config.go @@ -418,7 +418,7 @@ func genDefaultConfig(writer io.Writer) error { Enable: false, Dial: config.Dial{ Network: "tcp", - Addr: "127.0.0.1:30021", + Addr: "127.0.0.1:30022", TLS: config.TLS{ Enable: false, MTLS: false, diff --git a/pkg/frontlas/config/config.go b/pkg/frontlas/config/config.go index 7a809a1..f0fb709 100644 --- a/pkg/frontlas/config/config.go +++ b/pkg/frontlas/config/config.go @@ -206,13 +206,13 @@ func genDefaultConfig(writer io.Writer) error { ControlPlane: ControlPlane{ Listen: config.Listen{ Network: "tcp", - Addr: "0.0.0.0:30020", + Addr: "0.0.0.0:30021", }, }, FrontierManager: FrontierManager{ Listen: config.Listen{ Network: "tcp", - Addr: "0.0.0.0:30021", + Addr: "0.0.0.0:30022", }, }, Redis: Redis{ diff --git a/pkg/operator/api/v1alpha1/frontiercluster_types.go b/pkg/operator/api/v1alpha1/frontiercluster_types.go index d100869..5cbb2c6 100644 --- a/pkg/operator/api/v1alpha1/frontiercluster_types.go +++ b/pkg/operator/api/v1alpha1/frontiercluster_types.go @@ -28,15 +28,16 @@ type FrontierClusterSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - // Foo is an example field of FrontierCluster. Edit frontiercluster_types.go to remove/update - Replica string `json:"replica"` + Frontiers int `json:"frontiers"` + Frontlases int `json:"frontlases"` } // FrontierClusterStatus defines the observed state of FrontierCluster type FrontierClusterStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file - Replica int `json:"replica"` + CurrentFrontiers int `json:"current_frontier"` + CurrentFrontlases int `json:"current_frontlases"` } //+kubebuilder:object:root=true @@ -47,8 +48,8 @@ type FrontierCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec FrontierClusterSpec `json:"spec,omitempty"` - //Status FrontierClusterStatus `json:"status,omitempty"` + Spec FrontierClusterSpec `json:"spec,omitempty"` + Status FrontierClusterStatus `json:"status,omitempty"` } //+kubebuilder:object:root=true diff --git a/pkg/operator/api/v1alpha1/zz_generated.deepcopy.go b/pkg/operator/api/v1alpha1/zz_generated.deepcopy.go index e40caa6..7917959 100644 --- a/pkg/operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/operator/api/v1alpha1/zz_generated.deepcopy.go @@ -30,6 +30,7 @@ func (in *FrontierCluster) DeepCopyInto(out *FrontierCluster) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec + out.Status = in.Status } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrontierCluster. diff --git a/pkg/operator/cmd/main.go b/pkg/operator/cmd/main.go index 3cbbdba..0f08604 100644 --- a/pkg/operator/cmd/main.go +++ b/pkg/operator/cmd/main.go @@ -34,8 +34,8 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" - frontierv1alpha1 "github.com/singchia/frontier/api/v1alpha1" - "github.com/singchia/frontier/internal/controller" + frontierv1alpha1 "github.com/singchia/frontier/operator/api/v1alpha1" + "github.com/singchia/frontier/operator/internal/controller" //+kubebuilder:scaffold:imports ) diff --git a/pkg/operator/config/crd/bases/frontier.singchia.io_frontierclusters.yaml b/pkg/operator/config/crd/bases/frontier.singchia.io_frontierclusters.yaml index de46edd..01c9d8f 100644 --- a/pkg/operator/config/crd/bases/frontier.singchia.io_frontierclusters.yaml +++ b/pkg/operator/config/crd/bases/frontier.singchia.io_frontierclusters.yaml @@ -39,12 +39,27 @@ spec: spec: description: FrontierClusterSpec defines the desired state of FrontierCluster properties: - replica: - description: Foo is an example field of FrontierCluster. Edit frontiercluster_types.go - to remove/update - type: string + frontiers: + type: integer + frontlases: + type: integer required: - - replica + - frontiers + - frontlases + type: object + status: + description: FrontierClusterStatus defines the observed state of FrontierCluster + properties: + current_frontier: + description: |- + INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + Important: Run "make" to regenerate code after modifying this file + type: integer + current_frontlases: + type: integer + required: + - current_frontier + - current_frontlases type: object type: object served: true diff --git a/pkg/operator/go.mod b/pkg/operator/go.mod index 6228a36..118be2a 100644 --- a/pkg/operator/go.mod +++ b/pkg/operator/go.mod @@ -1,4 +1,4 @@ -module github.com/singchia/frontier +module github.com/singchia/frontier/operator go 1.21 diff --git a/pkg/operator/internal/controller/frontiercluster_controller.go b/pkg/operator/internal/controller/frontiercluster_controller.go index 3d7da10..5360c75 100644 --- a/pkg/operator/internal/controller/frontiercluster_controller.go +++ b/pkg/operator/internal/controller/frontiercluster_controller.go @@ -18,14 +18,13 @@ package controller import ( "context" - "encoding/json" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - frontierv1alpha1 "github.com/singchia/frontier/api/v1alpha1" + frontierv1alpha1 "github.com/singchia/frontier/operator/api/v1alpha1" ) // FrontierClusterReconciler reconciles a FrontierCluster object @@ -55,9 +54,7 @@ func (r *FrontierClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ log.Error(err, "get frontier cluster error") return ctrl.Result{}, err } - data, _ := json.Marshal(frontiercluster) - log.Info("singchia watching", "frontiercluster", string(data)) - //frontiercluster.Status.Replica = 1 + if err := r.Status().Update(ctx, frontiercluster); err != nil { log.Error(err, "unable to update status") return ctrl.Result{}, err diff --git a/pkg/operator/internal/controller/frontiercluster_controller_test.go b/pkg/operator/internal/controller/frontiercluster_controller_test.go index d75155d..56e7604 100644 --- a/pkg/operator/internal/controller/frontiercluster_controller_test.go +++ b/pkg/operator/internal/controller/frontiercluster_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - frontierv1alpha1 "github.com/singchia/frontier/api/v1alpha1" + frontierv1alpha1 "github.com/singchia/frontier/operator/api/v1alpha1" ) var _ = Describe("FrontierCluster Controller", func() { diff --git a/pkg/operator/internal/controller/suite_test.go b/pkg/operator/internal/controller/suite_test.go index a539e56..d657815 100644 --- a/pkg/operator/internal/controller/suite_test.go +++ b/pkg/operator/internal/controller/suite_test.go @@ -32,7 +32,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - frontierv1alpha1 "github.com/singchia/frontier/api/v1alpha1" + frontierv1alpha1 "github.com/singchia/frontier/operator/api/v1alpha1" //+kubebuilder:scaffold:imports ) diff --git a/pkg/operator/test/e2e/e2e_test.go b/pkg/operator/test/e2e/e2e_test.go index 9964bd1..8fe6bd9 100644 --- a/pkg/operator/test/e2e/e2e_test.go +++ b/pkg/operator/test/e2e/e2e_test.go @@ -24,7 +24,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/singchia/frontier/test/utils" + "github.com/singchia/frontier/operator/test/utils" ) const namespace = "frontier-system"