This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
rolling.go
53 lines (47 loc) · 2.23 KB
/
rolling.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
50
51
52
53
package cmd
import (
"os"
"time"
"github.com/flanksource/karina/pkg/provision"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var Rolling = &cobra.Command{
Use: "rolling",
}
var rollingOpts provision.RollingOptions
var RollingRestart = &cobra.Command{
Use: "restart",
Short: "Rolling restart of all nodes",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
if err := provision.RollingRestart(getPlatform(cmd), rollingOpts); err != nil {
log.Fatalf("Failed to restart nodes, %s", err)
}
},
}
var RollingUpdate = &cobra.Command{
Use: "update",
Short: "Rolling update of all nodes",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
if err := provision.RollingUpdate(getPlatform(cmd), rollingOpts); err != nil {
log.Fatalf("Failed to update nodes %s", err)
os.Exit(1)
}
},
}
func init() {
rollingOpts = provision.RollingOptions{}
RollingUpdate.Flags().DurationVar(&rollingOpts.MinAge, "min-age", time.Hour*24*7, "Minimum age of nodes to roll")
Rolling.PersistentFlags().DurationVar(&rollingOpts.Timeout, "timeout", time.Minute*5, "timeout between actions")
Rolling.PersistentFlags().DurationVar(&rollingOpts.BurninPeriod, "burnin-period", time.Minute*3, "Period to burn-in new nodes before scheduling workloads on")
Rolling.PersistentFlags().IntVar(&rollingOpts.Max, "max", 100, "Max number of nodes to roll")
RollingUpdate.PersistentFlags().IntVar(&rollingOpts.MaxSurge, "max-surge", 3, "Max number of nodes surge to, the higher the number the faster the rollout, but the more capacity that will be used ")
RollingUpdate.PersistentFlags().IntVar(&rollingOpts.HealthTolerance, "health-tolerance", 1, "Max number of failing pods to tolerate")
Rolling.PersistentFlags().BoolVar(&rollingOpts.MigrateLocalVolumes, "migrate-local-volumes", true, "Delete and recreate local PVC's")
Rolling.PersistentFlags().BoolVar(&rollingOpts.Force, "force", false, "ignore errors and continue with the rolling action regardless of health")
Rolling.PersistentFlags().BoolVar(&rollingOpts.Masters, "masters", true, "include master nodes")
Rolling.PersistentFlags().BoolVar(&rollingOpts.Workers, "workers", true, "include worker nodes")
Rolling.AddCommand(RollingRestart, RollingUpdate)
}