mirror of
https://github.com/singchia/frontier.git
synced 2025-10-08 09:40:09 +08:00
operator: add basic resource define
This commit is contained in:
22
Makefile
22
Makefile
@@ -67,11 +67,31 @@ image-gen-api:
|
|||||||
image-gen-swagger:
|
image-gen-swagger:
|
||||||
docker buildx build -t frontier-gen-swagger:${VERSION} -f images/Dockerfile.controlplane-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
|
# container
|
||||||
|
.PHONY: container
|
||||||
|
container: container-frontier container-frontlas
|
||||||
|
|
||||||
.PHONY: container-frontier
|
.PHONY: container-frontier
|
||||||
container-frontier:
|
container-frontier:
|
||||||
docker rm -f 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
|
# api
|
||||||
.PHONY: api-frontier
|
.PHONY: api-frontier
|
||||||
|
@@ -60,7 +60,7 @@ frontlas:
|
|||||||
enable: false
|
enable: false
|
||||||
dial:
|
dial:
|
||||||
network: tcp
|
network: tcp
|
||||||
addr: 127.0.0.1:30021
|
addr: 127.0.0.1:30022
|
||||||
metrics:
|
metrics:
|
||||||
enable: false
|
enable: false
|
||||||
interval: 0
|
interval: 0
|
||||||
|
@@ -9,11 +9,11 @@ daemon:
|
|||||||
control_plane:
|
control_plane:
|
||||||
listen:
|
listen:
|
||||||
network: tcp
|
network: tcp
|
||||||
addr: 0.0.0.0:30020
|
addr: 0.0.0.0:30021
|
||||||
frontier_plane:
|
frontier_plane:
|
||||||
listen:
|
listen:
|
||||||
network: tcp
|
network: tcp
|
||||||
addr: 0.0.0.0:30021
|
addr: 0.0.0.0:30022
|
||||||
expiration:
|
expiration:
|
||||||
service_meta: 30
|
service_meta: 30
|
||||||
edge_meta: 30
|
edge_meta: 30
|
||||||
|
@@ -72,7 +72,7 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
network := pflag.String("network", "tcp", "network to dial")
|
network := pflag.String("network", "tcp", "network to dial")
|
||||||
address := pflag.String("address", "127.0.0.1:30011", "address 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")
|
frontlas := pflag.Bool("frontlas", false, "frontlas or frontier")
|
||||||
loglevel := pflag.String("loglevel", "info", "log level, trace debug info warn error")
|
loglevel := pflag.String("loglevel", "info", "log level, trace debug info warn error")
|
||||||
serviceName := pflag.String("service", "foo", "service name")
|
serviceName := pflag.String("service", "foo", "service name")
|
||||||
|
@@ -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 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
|
RUN apk add glibc-2.34-r0.apk
|
||||||
|
|
||||||
EXPOSE 30020
|
|
||||||
EXPOSE 30021
|
EXPOSE 30021
|
||||||
|
EXPOSE 30022
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/frontlas"]
|
ENTRYPOINT ["/usr/bin/frontlas"]
|
||||||
CMD ["--config", "/usr/conf/frontlas.yaml"]
|
CMD ["--config", "/usr/conf/frontlas.yaml"]
|
@@ -418,7 +418,7 @@ func genDefaultConfig(writer io.Writer) error {
|
|||||||
Enable: false,
|
Enable: false,
|
||||||
Dial: config.Dial{
|
Dial: config.Dial{
|
||||||
Network: "tcp",
|
Network: "tcp",
|
||||||
Addr: "127.0.0.1:30021",
|
Addr: "127.0.0.1:30022",
|
||||||
TLS: config.TLS{
|
TLS: config.TLS{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
MTLS: false,
|
MTLS: false,
|
||||||
|
@@ -206,13 +206,13 @@ func genDefaultConfig(writer io.Writer) error {
|
|||||||
ControlPlane: ControlPlane{
|
ControlPlane: ControlPlane{
|
||||||
Listen: config.Listen{
|
Listen: config.Listen{
|
||||||
Network: "tcp",
|
Network: "tcp",
|
||||||
Addr: "0.0.0.0:30020",
|
Addr: "0.0.0.0:30021",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
FrontierManager: FrontierManager{
|
FrontierManager: FrontierManager{
|
||||||
Listen: config.Listen{
|
Listen: config.Listen{
|
||||||
Network: "tcp",
|
Network: "tcp",
|
||||||
Addr: "0.0.0.0:30021",
|
Addr: "0.0.0.0:30022",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Redis: Redis{
|
Redis: Redis{
|
||||||
|
@@ -28,15 +28,16 @@ type FrontierClusterSpec struct {
|
|||||||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||||
// Important: Run "make" to regenerate code after modifying this file
|
// Important: Run "make" to regenerate code after modifying this file
|
||||||
|
|
||||||
// Foo is an example field of FrontierCluster. Edit frontiercluster_types.go to remove/update
|
Frontiers int `json:"frontiers"`
|
||||||
Replica string `json:"replica"`
|
Frontlases int `json:"frontlases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FrontierClusterStatus defines the observed state of FrontierCluster
|
// FrontierClusterStatus defines the observed state of FrontierCluster
|
||||||
type FrontierClusterStatus struct {
|
type FrontierClusterStatus struct {
|
||||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||||
// Important: Run "make" to regenerate code after modifying this file
|
// 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
|
//+kubebuilder:object:root=true
|
||||||
@@ -48,7 +49,7 @@ type FrontierCluster struct {
|
|||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
Spec FrontierClusterSpec `json:"spec,omitempty"`
|
Spec FrontierClusterSpec `json:"spec,omitempty"`
|
||||||
//Status FrontierClusterStatus `json:"status,omitempty"`
|
Status FrontierClusterStatus `json:"status,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//+kubebuilder:object:root=true
|
//+kubebuilder:object:root=true
|
||||||
|
@@ -30,6 +30,7 @@ func (in *FrontierCluster) DeepCopyInto(out *FrontierCluster) {
|
|||||||
out.TypeMeta = in.TypeMeta
|
out.TypeMeta = in.TypeMeta
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
out.Spec = in.Spec
|
out.Spec = in.Spec
|
||||||
|
out.Status = in.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrontierCluster.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrontierCluster.
|
||||||
|
@@ -34,8 +34,8 @@ import (
|
|||||||
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
|
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||||
|
|
||||||
frontierv1alpha1 "github.com/singchia/frontier/api/v1alpha1"
|
frontierv1alpha1 "github.com/singchia/frontier/operator/api/v1alpha1"
|
||||||
"github.com/singchia/frontier/internal/controller"
|
"github.com/singchia/frontier/operator/internal/controller"
|
||||||
//+kubebuilder:scaffold:imports
|
//+kubebuilder:scaffold:imports
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -39,12 +39,27 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
description: FrontierClusterSpec defines the desired state of FrontierCluster
|
description: FrontierClusterSpec defines the desired state of FrontierCluster
|
||||||
properties:
|
properties:
|
||||||
replica:
|
frontiers:
|
||||||
description: Foo is an example field of FrontierCluster. Edit frontiercluster_types.go
|
type: integer
|
||||||
to remove/update
|
frontlases:
|
||||||
type: string
|
type: integer
|
||||||
required:
|
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
|
||||||
type: object
|
type: object
|
||||||
served: true
|
served: true
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
module github.com/singchia/frontier
|
module github.com/singchia/frontier/operator
|
||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
|
@@ -18,14 +18,13 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
"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
|
// 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")
|
log.Error(err, "get frontier cluster error")
|
||||||
return ctrl.Result{}, err
|
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 {
|
if err := r.Status().Update(ctx, frontiercluster); err != nil {
|
||||||
log.Error(err, "unable to update status")
|
log.Error(err, "unable to update status")
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
|
@@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
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() {
|
var _ = Describe("FrontierCluster Controller", func() {
|
||||||
|
@@ -32,7 +32,7 @@ import (
|
|||||||
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
"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
|
//+kubebuilder:scaffold:imports
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/singchia/frontier/test/utils"
|
"github.com/singchia/frontier/operator/test/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const namespace = "frontier-system"
|
const namespace = "frontier-system"
|
||||||
|
Reference in New Issue
Block a user