-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (41 loc) · 1.01 KB
/
main.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
41
42
43
44
45
46
47
48
49
package main
import (
"os"
"path/filepath"
"github.com/sirupsen/logrus"
commander "github.com/spirosoik/k8s-commander"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
)
func main() {
logger := logrus.New()
kubeconfig := filepath.Join(homedir.HomeDir(), ".kube", "config")
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
logger.WithError(err).Error()
os.Exit(-1)
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
logger.WithError(err).Error()
os.Exit(-1)
}
// Create a new commander
cmer := commander.New()
// create a recipe with a set of commands
opts := recipeOpts{
Name: "es",
Namespace: "default",
ContainerImage: "elastic/elasticsearch",
ContainerPort: 9200,
ContainerTag: "7.8.1",
}
recipe := NewElasticsearchDeployment(opts, clientset, logger)
// Execute the recipe
err = cmer.Execute(recipe)
if err != nil {
logger.WithError(err).Error()
os.Exit(-1)
}
}