Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 235cda7

Browse files
committed
Add GetServer func
Signed-off-by: Nguyen Thanh Nguyen <[email protected]>
1 parent 99651aa commit 235cda7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

docs/developer/configuration.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Configuration file
2+
3+
EMCO Configuration File:
4+
`
5+
EMCOConfigPath = "/home/ubuntu/l-kaas/L-KaaS/pkg/emcoclient/.emco.yaml"
6+
`
7+
8+
EMCO Default Configuration File:
9+
`
10+
EMCO_DEFAULT_CONFIG_FILE_PATH = "/.l-kaas/config/emco/.emco.yaml"
11+
`
12+
13+
14+
## CAPI Resources Template Compatible
15+
16+
CAPI Template Example:
17+
File name: `cluster-template.yaml`
18+
Link folder: `
19+
https://github.com/ntnguyencse/L-KaaS/blob/dev/templates/capi/
20+
`
21+
22+
## EMCO Resources Template
23+
24+
Configuare:
25+
`
26+
EmptyProfileForCompositeAppURL = "https://raw.githubusercontent.com/ntnguyencse/L-KaaS/main/templates/emco/vfw/vfw/profile.tar.gz"
27+
CompositeAppTemplateURL = "https://raw.githubusercontent.com/ntnguyencse/L-KaaS/main/templates/emco/vfw/vfw/test-vfw.yaml"
28+
PrerequisiteCompositeAppURL = "https://raw.githubusercontent.com/ntnguyencse/L-KaaS/main/templates/emco/vfw/vfw/prerequisites.yaml"
29+
`
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package kubernetesclient
2+
3+
import (
4+
"fmt"
5+
6+
"k8s.io/apimachinery/pkg/version"
7+
"k8s.io/client-go/discovery"
8+
"k8s.io/client-go/tools/clientcmd"
9+
)
10+
11+
func GetKubernetesServerVersion(kubeConfigPath string) (*version.Info, error) {
12+
13+
config, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath)
14+
if err != nil {
15+
fmt.Println("Error :", err)
16+
return nil, err
17+
}
18+
19+
discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
20+
if err != nil {
21+
fmt.Println("error in discoveryClient", err)
22+
return nil, err
23+
}
24+
25+
information, err := discoveryClient.ServerVersion()
26+
if err != nil {
27+
fmt.Println("Error while fetching server version information", err)
28+
return nil, err
29+
}
30+
31+
fmt.Println("Version", information)
32+
return information, err
33+
34+
}

0 commit comments

Comments
 (0)