-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from ifooth/cloud-native-joelei-dev
Feat: add Native K8s client
- Loading branch information
Showing
6 changed files
with
113 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ bk_dist/dashboard/pkg/dashboard/packrd/packed-packr.go | |
.temp | ||
build.yml | ||
.codecc | ||
.idea | ||
.idea | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/backend/booster/server/pkg/resource/crm/operator/k8s/operator_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2021 THL A29 Limited, a Tencent company. All rights reserved | ||
* | ||
* This source code file is licensed under the MIT License, you may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
*/ | ||
|
||
package k8s | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/common/net" | ||
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/server/config" | ||
) | ||
|
||
func TestGenerateNativeClient(t *testing.T) { | ||
wd, _ := os.Getwd() | ||
tplPath, _ := filepath.Abs(filepath.Join(wd, "../../../../../template/k8s_container.yaml.template")) | ||
|
||
conf := &config.ContainerResourceConfig{ | ||
BcsAppTemplate: tplPath, | ||
KubeConfigPath: "/root/.kube/config", | ||
} | ||
|
||
conf.BcsAPIPool = net.NewConnectPool(strings.Split(conf.BcsAPIAddress, ",")) | ||
conf.BcsAPIPool.Start() | ||
|
||
operator, err := NewOperator(conf) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
node, err := operator.GetResource("Fake-Cluster-ID") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if len(node) == 0 { | ||
t.Fatalf("have no node") | ||
} | ||
|
||
t.Log(node[0]) | ||
} |