From a1f0cb46abfacc5b7e0a821511631838b8d3d758 Mon Sep 17 00:00:00 2001 From: feeli Date: Tue, 21 Jun 2022 10:27:01 +0800 Subject: [PATCH] Creating an edge cluster supports custom parameters --- docs/design-proposals/edge-cluster.md | 5 ++++- go.mod | 3 +-- go.sum | 6 ++++-- pkg/platform/provider/edge/cluster/create.go | 12 ++++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/design-proposals/edge-cluster.md b/docs/design-proposals/edge-cluster.md index bcb98ca04a..b29a336fff 100644 --- a/docs/design-proposals/edge-cluster.md +++ b/docs/design-proposals/edge-cluster.md @@ -86,6 +86,7 @@ metadata: annotations: superedge.io/edgeImageResository: superedge.tencentcloudcr.com/superedge ## 边缘节点上镜像仓库的地址 superedge.io/edge-version: v0.8.0 ## superedge 组件的版本 + superedge.io/edge-virtual-addr: 169.254.20.11 ##边缘节点虚拟网卡的地址 name: attlee-superedge spec: displayName: attlee-superedge-demo @@ -97,6 +98,8 @@ spec: - etcd.kube-system features: containerRuntime: docker + skipConditions: + - EnsureCilium machines: - ip: 10.0.200.98 password: PasswordBase64 @@ -111,7 +114,7 @@ spec: - 106.52.199.103 tenantID: default type: Edge ## 集群类型,标识创建的是SuperEdge的边缘集群 - version: 1.21.4-tke.1 + version: 1.20.6-tke.2 ``` 更多参数的详细解析请参考TKEStack的官方文档,用`kubectl apply -f superedge_edge.yaml ` 提交集群yaml,集群处于`Running`表示创建SuperEdge 边缘集群成功, diff --git a/go.mod b/go.mod index 2bce4e83d8..6a161da20d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ replace ( github.com/NetEase-Object-Storage/nos-golang-sdk => github.com/karuppiah7890/nos-golang-sdk v0.0.0-20191116042345-0792ba35abcc github.com/chartmuseum/storage => github.com/leoryu/chartmuseum-storage v0.11.1-0.20211104032734-9da39e8f5170 github.com/deislabs/oras => github.com/deislabs/oras v0.8.0 - github.com/superedge/edgeadm => github.com/00pf00/edgeadm v0.0.1 google.golang.org/grpc => google.golang.org/grpc v1.38.0 k8s.io/api => k8s.io/api v0.22.3 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.22.3 @@ -93,7 +92,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.8.1 github.com/stretchr/testify v1.7.0 - github.com/superedge/edgeadm v0.0.1 + github.com/superedge/edgeadm v0.8.0-tkestack github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.194 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.194 diff --git a/go.sum b/go.sum index 57d5a008de..4e20365035 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,6 @@ contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeS dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= entgo.io/ent v0.8.0/go.mod h1:KNjsukat/NJi6zJh1utwRadsbGOZsBbAZNDxkW7tMCc= -github.com/00pf00/edgeadm v0.0.1 h1:J4XYnwtYZ2JAcLCpZroOUNKEwUL28fe36yQLZr67WDw= -github.com/00pf00/edgeadm v0.0.1/go.mod h1:a4rgfAIF8bbOkxMKwIsEeT+fQqYIZdlm6zEIRn3DLHo= github.com/AlekSi/pointer v1.1.0 h1:SSDMPcXD9jSl8FPy9cRzoRaMJtm9g9ggGTxecRUbQoI= github.com/AlekSi/pointer v1.1.0/go.mod h1:y7BvfRI3wXPWKXEBhU71nbnIEEZX0QTSB2Bj48UJIZE= github.com/AppsFlyer/go-sundheit v0.4.0 h1:7ECd0YWaXJQ9LzdCFrpGxJVeAgXvNarN6uwxrJsh69A= @@ -1491,6 +1489,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/superedge/edgeadm v0.8.0-tkestack h1:kX/wSs9TxFJhDuth/E0rN6J384KENvXXfuV5O+lVMJk= +github.com/superedge/edgeadm v0.8.0-tkestack/go.mod h1:D7Qjr1HU4J4jK3UY8tWWVv0al1EBJGdGDC408aNI0vY= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -1532,9 +1532,11 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= +github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852 h1:cPXZWzzG0NllBLdjWoD1nDfaqu98YMv+OneaKc8sPOA= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= +github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= diff --git a/pkg/platform/provider/edge/cluster/create.go b/pkg/platform/provider/edge/cluster/create.go index 1cc9837413..815a5475ed 100644 --- a/pkg/platform/provider/edge/cluster/create.go +++ b/pkg/platform/provider/edge/cluster/create.go @@ -59,6 +59,7 @@ egressSelections: const ( EdgeImageRepository = "superedge.io/edgeImageResository" EdgeVersion = "superedge.io/edge-version" + EdgeVirtualAddr = "superedge.io/edge-virtual-addr" ) func (p *Provider) EnsureEdgeFlannel(ctx context.Context, c *v1.Cluster) error { @@ -191,13 +192,20 @@ func (p *Provider) EnsureApplyEdgeApps(ctx context.Context, c *v1.Cluster) error edgeConf.ManifestsDir = "" edgeConf.TunnelCloudToken = util.GetRandToken(32) edgeConf.Version = c.Annotations[EdgeVersion] + edgeConf.EdgeImageRepository = c.Annotations[EdgeImageRepository] + + virtualAddr, ok := c.Annotations[EdgeVirtualAddr] + if ok { + edgeConf.EdgeVirtualAddr = virtualAddr + } else { + edgeConf.EdgeVirtualAddr = constant.DefaultEdgeVirtualAddr + } cfg := &kubeadmapi.InitConfiguration{} cfg.APIServer.CertSANs = certSANs cfg.CertificatesDir = fmt.Sprintf("/tmp/%s/", c.Name) cfg.ControlPlaneEndpoint = apiserverIP cfg.NodeRegistration.Name = c.Spec.Machines[0].IP - cfg.ImageRepository = c.Annotations[EdgeImageRepository] version, err := kubeadmutil.KubernetesReleaseVersion(strings.Split(c.Spec.Version, "-")[0]) if err != nil { klog.Errorf("Failed to get k8s version, cluster: %s, error: %v", c.Name, err) @@ -235,7 +243,7 @@ func (p *Provider) EnsureApplyEdgeApps(ctx context.Context, c *v1.Cluster) error return err } - steps.EnsureEdgeKubeConfig(cfg, clientset) + steps.EnsureEdgeKubeConfig(cfg, edgeConf, clientset) if err != nil { klog.Errorf("Failed to install EdgeKubeConfig, cluster: %s, error: %v", c.Name, err) return err