Skip to content

Commit

Permalink
Creating an edge cluster supports custom parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
feeli committed Jun 21, 2022
1 parent b430a6c commit a1f0cb4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 4 additions & 1 deletion docs/design-proposals/edge-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -97,6 +98,8 @@ spec:
- etcd.kube-system
features:
containerRuntime: docker
skipConditions:
- EnsureCilium
machines:
- ip: 10.0.200.98
password: PasswordBase64
Expand All @@ -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 边缘集群成功,
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
12 changes: 10 additions & 2 deletions pkg/platform/provider/edge/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a1f0cb4

Please sign in to comment.