-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathk8s.go
More file actions
106 lines (97 loc) · 3.26 KB
/
k8s.go
File metadata and controls
106 lines (97 loc) · 3.26 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package cmd
import (
"fmt"
"sync"
"time"
"github.com/deis/deis/deisctl/backend"
"github.com/deis/deis/deisctl/utils"
)
//InstallK8s Installs K8s
func InstallK8s(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
defer close(outchan)
defer close(errchan)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Installing K8s...")
outchan <- fmt.Sprintf("K8s API Server ...")
b.Create([]string{"kube-apiserver"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s controller and scheduler ...")
b.Create([]string{"kube-controller-manager","kube-scheduler"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s proxy and kubelet ...")
b.Create([]string{"kube-proxy","kube-kubelet"}, &wg, outchan, errchan)
wg.Wait()
fmt.Println("Done.")
fmt.Println()
fmt.Println("Please run `deisctl start k8s` to start K8s.")
return nil
}
//StartK8s starts K8s Schduler
func StartK8s(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
defer close(outchan)
defer close(errchan)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Starting K8s...")
outchan <- fmt.Sprintf("K8s API Server ...")
b.Start([]string{"kube-apiserver"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s controller and scheduler ...")
b.Start([]string{"kube-controller-manager","kube-scheduler"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s proxy and kubelet ...")
b.Start([]string{"kube-proxy","kube-kubelet"}, &wg, outchan, errchan)
wg.Wait()
fmt.Println("Done.")
fmt.Println("Please run `deisctl config controller set schedulerModule=k8s` to use the K8s scheduler.")
return nil
}
//StopK8s stops K8s
func StopK8s(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
defer close(outchan)
defer close(errchan)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Stopping K8s...")
outchan <- fmt.Sprintf("K8s proxy and kubelet ...")
b.Stop([]string{"kube-proxy","kube-kubelet"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s controller and scheduler ...")
b.Stop([]string{"kube-controller-manager","kube-scheduler"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s API Server ...")
b.Stop([]string{"kube-apiserver"}, &wg, outchan, errchan)
wg.Wait()
fmt.Println("Done.")
fmt.Println()
return nil
}
//UnInstallK8s uninstall K8s
func UnInstallK8s(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
defer close(outchan)
defer close(errchan)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Destroying K8s...")
outchan <- fmt.Sprintf("K8s proxy and kubelet ...")
b.Destroy([]string{"kube-proxy","kube-kubelet"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s controller and scheduler ...")
b.Destroy([]string{"kube-controller-manager","kube-scheduler"}, &wg, outchan, errchan)
wg.Wait()
outchan <- fmt.Sprintf("K8s API Server ...")
b.Destroy([]string{"kube-apiserver"}, &wg, outchan, errchan)
wg.Wait()
fmt.Println("Done.")
fmt.Println()
return nil
}