k8s: update crd and it's example plus version updated

This commit is contained in:
singchia
2024-05-31 18:09:23 +08:00
parent 57778fa0cd
commit e4f874ee3a
20 changed files with 134 additions and 63 deletions

View File

@@ -5,6 +5,7 @@
<div align="center">
[![Go Report Card](https://goreportcard.com/badge/github.com/singchia/frontier)](https://goreportcard.com/report/github.com/singchia/frontier)
[![Go Reference](https://pkg.go.dev/badge/badge/github.com/singchia/frontier.svg)](https://pkg.go.dev/github.com/singchia/frontier/api/dataplane/v1/service)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
</div>
@@ -888,7 +889,7 @@ exchange:
### docker
```
docker run -d --name frontier -p 30011:30011 -p 30012:30012 singchia/frontier:1.0.0
docker run -d --name frontier -p 30011:30011 -p 30012:30012 singchia/frontier:1.1.0
```
@@ -910,6 +911,12 @@ cd dist/helm
helm install frontier ./ -f values.yaml
```
你的微服务应该连接`service/frontier-servicebound-svc:40011`,你的边缘节点可以连接`:30012`所在的NodePort。
### operator
见下面集群部署章节
## 集群
### Frontier + Frontlas架构
@@ -1039,11 +1046,23 @@ service ClusterService {
```
git clone https://github.com/singchia/frontier.git
cd pkg/operator
make install && make deploy
cd dist/crd
kubectl apply -f install.yaml
```
**CR**
查看CRD
```
kubectl get crd frontierclusters.frontier.singchia.io
```
查看Operator
```
kubectl get all -n frontier-system
```
**FrontierCluster集群**
```yaml
apiVersion: frontier.singchia.io/v1alpha1
@@ -1056,7 +1075,7 @@ metadata:
spec:
frontier:
# 单实例Frontier
replicas: 1
replicas: 2
# 微服务侧端口
servicebound:
port: 30011
@@ -1069,8 +1088,8 @@ spec:
# 控制面端口
controlplane:
port: 40011
# 依赖的Redis配置
redis:
# 依赖的Redis配置
addrs:
- rfs-redisfailover:26379
password: your-password
@@ -1078,8 +1097,40 @@ spec:
redisType: sentinel
```
1分钟你即可拥有一个Frontier+Frontlas的集群。
1分钟你即可拥有一个2实例Frontier+1实例Frontlas的集群。
通过一下来检查资源部署情况
> kubectl get all -l app=frontiercluster-frontier
> kubectl get all -l app=frontiercluster-frontlas
```
NAME READY STATUS RESTARTS AGE
pod/frontiercluster-frontier-57d565c89-dn6n8 1/1 Running 0 7m22s
pod/frontiercluster-frontier-57d565c89-nmwmt 1/1 Running 0 7m22s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/frontiercluster-edgebound-svc NodePort 10.233.23.174 <none> 30012:30012/TCP 8m7s
service/frontiercluster-servicebound-svc ClusterIP 10.233.29.156 <none> 30011/TCP 8m7s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/frontiercluster-frontier 2/2 2 2 7m22s
NAME DESIRED CURRENT READY AGE
replicaset.apps/frontiercluster-frontier-57d565c89 2 2 2 7m22s
```
```
kubectl get all -l app=frontiercluster-frontlas
NAME READY STATUS RESTARTS AGE
pod/frontiercluster-frontlas-85c4fb6d9b-5clkh 1/1 Running 0 8m11s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/frontiercluster-frontlas-svc ClusterIP 10.233.0.23 <none> 40011/TCP,40012/TCP 8m11s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/frontiercluster-frontlas 1/1 1 1 8m11s
NAME DESIRED CURRENT READY AGE
replicaset.apps/frontiercluster-frontlas-85c4fb6d9b 1 1 1 8m11s
```
你的微服务应该连接`service/frontiercluster-frontlas-svc:40011`,你的边缘节点可以连接`:30012`所在的NodePort。
## 开发
@@ -1107,4 +1158,8 @@ spec:
## 许可证
Released under the [Apache License 2.0](https://github.com/singchia/geminio/blob/main/LICENSE)
Released under the [Apache License 2.0](https://github.com/singchia/geminio/blob/main/LICENSE)
---
已经看到这里点个Star⭐是莫大的认可♥

View File

@@ -1 +1 @@
1.0.0
1.1.0

View File

@@ -3,8 +3,9 @@ version: "3.7"
services:
frontier:
container_name: frontier
image: singchia/frontier:1.0.0
image: singchia/frontier:1.1.0
restart: always
command: --config /usr/conf/frontier.yaml -v 1
ports:
- 30010:30010
- 30011:30011
@@ -16,7 +17,7 @@ services:
max-file: "5"
frontlas:
container_name: frontlas
image: singchia/frontlas:1.0.0
image: singchia/frontlas:1.1.0
restart: always
ports:
- 40011:40011

View File

@@ -7,15 +7,17 @@ metadata:
name: frontiercluster
spec:
frontier:
replicas: 1
replicas: 2
servicebound:
port: 30011
edgebound:
port: 30012
image: singchia/frontier:1.1.0
frontlas:
replicas: 1
controlplane:
port: 40011
image: singchia/frontlas:1.1.0
redis:
addrs:
- rfs-redisfailover:26379

20
dist/crd/iclm-service_example.yaml vendored Normal file
View File

@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: iclm-service
spec:
selector:
matchLabels:
app: iclm-service
replicas: 1
template:
metadata:
labels:
app: iclm-service
spec:
imagePullSecrets:
- name: Always
containers:
- name: iclm-service
image: singchia/iclm_service:1.0.0-dev
imagePullPolicy: Always

View File

@@ -109,6 +109,8 @@ spec:
- mtls
type: object
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
@@ -328,6 +330,8 @@ spec:
for a service
type: string
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
@@ -525,6 +529,8 @@ spec:
type: array
db:
type: integer
masterName:
type: string
password:
type: string
redisType:
@@ -859,7 +865,7 @@ spec:
- --leader-elect
command:
- /manager
image: singchia/frontiercluster-controller:1.0.0
image: singchia/frontiercluster-controller:1.1.0
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -7,52 +7,14 @@ daemon:
enable: true
addr: 0.0.0.0:6060
cpu_profile_rate: 0
controlplane:
enable: false
listen:
network: tcp
addr: 0.0.0.0:30010
servicebound:
listen:
network: tcp
addr: 0.0.0.0:30011
tls:
enable: false
mtls: false
ca_certs:
- ca1.cert
- ca2.cert
certs:
- cert: servicebound.cert
key: servicebound.key
insecure_skip_verify: false
edgebound:
listen:
network: tcp
addr: 0.0.0.0:30012
tls:
enable: false
mtls: false
ca_certs:
- ca1.cert
- ca2.cert
certs:
- cert: edgebound.cert
key: edgebound.key
insecure_skip_verify: false
bypass:
network: tcp
addr: 192.168.1.10:8443
tls:
enable: true
mtls: true
ca_certs:
- ca1.cert
certs:
- cert: frontier.cert
key: frontier.key
insecure_skip_verify: false
bypass_enable: false
edgeid_alloc_when_no_idservice_on: true
dao:
debug: false

View File

@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "frontier.fullname" . }}
name: "frontier-servicebound-svc"
labels:
{{- include "frontier.labels" . | nindent 4 }}
spec:
@@ -19,7 +19,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: {{ include "frontier.fullname" . }}
name: "frontier-edgebound-svc"
labels:
{{- include "frontier.labels" . | nindent 4 }}
spec:

View File

@@ -2,7 +2,7 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
global:
registry: hub.docker.com/singchia
registry: singchia
pullPolicy: Always
imagePullSecrets: []
@@ -14,7 +14,7 @@ image:
image: frontier
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 1.0.0
tag: 1.1.0
replicaCount: 1
@@ -47,7 +47,7 @@ service:
type: ClusterIP
targetPort: controlbound
port: 30010
- name: servicebound
- name: frontier-edgebound-svc
type: ClusterIP
targetPort: servicebound
port: 30011

View File

@@ -87,6 +87,7 @@ func newEdgeManager(conf *config.Configuration, repo apis.Repo, informer apis.Ed
klog.Errorf("edge manager listen err: %s", err)
return nil, err
}
klog.V(0).Infof("edgebound server listening on: %s", ln.Addr())
geminioLn := ln
bypass := conf.Edgebound.BypassEnable

View File

@@ -33,6 +33,9 @@ func NewInformer(conf *config.Configuration, tmr timer.Timer) (*Informer, error)
if dial.Addrs == nil || len(dial.Addrs) == 0 {
return nil, errors.New("illegal dial addrs")
}
if dial.Network == "" {
dial.Network = "tcp"
}
sbAddr, ebAddr, err := getAdvertisedAddrs(conf.Servicebound.Listen, conf.Edgebound.Listen, dial)
// meta

View File

@@ -87,6 +87,7 @@ func newServiceManager(conf *config.Configuration, repo apis.Repo, informer apis
klog.Errorf("service manager listen err: %s", err)
return nil, err
}
klog.V(0).Infof("servicebound server listening on: %s", ln.Addr())
sm.ln = ln
return sm, nil
}

View File

@@ -130,7 +130,7 @@ func (sm *serviceManager) ConnOffline(d delegate.ConnDescriber) error {
serviceID := d.ClientID()
meta := string(d.Meta())
addr := d.RemoteAddr()
klog.V(2).Infof("service offline, serviceID: %d, service: %s, remote addr: %s", serviceID, meta, addr)
klog.V(1).Infof("service offline, serviceID: %d, service: %s, remote addr: %s", serviceID, meta, addr)
// offline the cache
err := sm.offline(serviceID, addr)
if err != nil {

View File

@@ -46,7 +46,7 @@ func NewFrontierManager(conf *config.Configuration, dao *repo.Dao, tmr timer.Tim
klog.Errorf("frontier plane listen err: %s", err)
return nil, err
}
klog.V(1).Infof("server listening on: %v", ln.Addr())
klog.V(0).Infof("frontierbound server listening on: %v", ln.Addr())
fm.ln = ln
return fm, nil

View File

@@ -1,5 +1,5 @@
# Image URL to use all building/pushing image targets
IMG ?= singchia/frontiercluster-controller:1.0.0-dev
IMG ?= singchia/frontiercluster-controller:1.1.0
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0

View File

@@ -65,6 +65,7 @@ type Frontier struct {
Replicas int `json:"replicas,omitempty"` // frontier replicas, default 1
Servicebound Servicebound `json:"servicebound"`
Edgebound Edgebound `json:"edgebound"`
Image string `json:"image,omitempty"` // default singchia/frontier:1.1.0
NodeAffinity corev1.NodeAffinity `json:"nodeAffinity,omitempty"`
}
@@ -95,6 +96,7 @@ type Frontlas struct {
Replicas int `json:"replicas,omitempty"` // frontlas replicas, default 1
ControlPlane ControlPlane `json:"controlplane,omitempty"`
NodeAffinity corev1.NodeAffinity `json:"nodeAffinity,omitempty"`
Image string `json:"image,omitempty"`
Redis Redis `json:"redis"`
}

View File

@@ -97,6 +97,8 @@ spec:
- mtls
type: object
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
@@ -316,6 +318,8 @@ spec:
for a service
type: string
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.

View File

@@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: singchia/frontiercluster-controller
newTag: 1.0.0-dev
newTag: 1.1.0

View File

@@ -109,6 +109,8 @@ spec:
- mtls
type: object
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
@@ -328,6 +330,8 @@ spec:
for a service
type: string
type: object
image:
type: string
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
@@ -525,6 +529,8 @@ spec:
type: array
db:
type: integer
masterName:
type: string
password:
type: string
redisType:
@@ -859,7 +865,7 @@ spec:
- --leader-elect
command:
- /manager
image: singchia/frontiercluster-controller:1.0.0
image: singchia/frontiercluster-controller:1.1.0
imagePullPolicy: Always
livenessProbe:
httpGet:

View File

@@ -96,6 +96,10 @@ func (r *FrontierClusterReconciler) ensureFrontierDeployment(ctx context.Context
labels := map[string]string{
"app": app,
}
image := fc.Spec.Frontier.Image
if image == "" {
image = "singchia/frontier:1.1.0"
}
volumeMounts := []corev1.VolumeMount{}
volumes := []corev1.Volume{}
@@ -146,7 +150,7 @@ func (r *FrontierClusterReconciler) ensureFrontierDeployment(ctx context.Context
// container
container := container.Builder().
SetName("frontier").
SetImage("singchia/frontier:1.0.0-dev").
SetImage(image).
SetImagePullPolicy(corev1.PullAlways).
SetEnvs([]corev1.EnvVar{{
Name: FrontierServiceboundPortEnv,
@@ -221,13 +225,17 @@ func (r *FrontierClusterReconciler) ensureFrontlasDeployment(ctx context.Context
labels := map[string]string{
"app": app,
}
image := fc.Spec.Frontlas.Image
if image == "" {
image = "singchia/frontlas:1.1.0"
}
service, _, cpport, _ := fc.FrontlasServicePort()
// container
container := container.Builder().
SetName("frontlas").
SetImage("singchia/frontlas:1.0.0-dev").
SetImage(image).
SetImagePullPolicy(corev1.PullAlways).
SetEnvs([]corev1.EnvVar{{
Name: FrontlasControlPlanePortEnv,