-
Notifications
You must be signed in to change notification settings - Fork 0
/
rke.go
40 lines (32 loc) · 1.25 KB
/
rke.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package librke
import (
"context"
"github.com/docker/docker/api/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rke/cluster"
"github.com/rancher/rke/pki"
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
)
type rke struct {
}
func (*rke) GenerateRKENodeCerts(ctx context.Context, rkeConfig v3.RancherKubernetesEngineConfig, nodeAddress string, certBundle map[string]pki.CertificatePKI) map[string]pki.CertificatePKI {
return pki.GenerateRKENodeCerts(ctx, rkeConfig, nodeAddress, certBundle)
}
func (*rke) GenerateCerts(config *v3.RancherKubernetesEngineConfig) (map[string]pki.CertificatePKI, error) {
return pki.GenerateRKECerts(context.Background(), *config, "", "")
}
func (*rke) GeneratePlan(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfig, dockerInfo map[string]types.Info) (v3.RKEPlan, error) {
return cluster.GeneratePlan(ctx, rkeConfig.DeepCopy(), dockerInfo)
}
func GetDockerInfo(node *v3.Node) (map[string]types.Info, error) {
infos := map[string]types.Info{}
if node.Status.DockerInfo != nil {
dockerInfo := types.Info{}
err := convert.ToObj(node.Status.DockerInfo, &dockerInfo)
if err != nil {
return nil, err
}
infos[node.Status.NodeConfig.Address] = dockerInfo
}
return infos, nil
}