Skip to content

Commit

Permalink
Adding new phases for security groups and load balancers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislovecnm committed Oct 16, 2017
1 parent 2c2f9fd commit adccaad
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cmd/kops/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func NewCmdUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.SSHPublicKey, "ssh-public-key", options.SSHPublicKey, "SSH public key to use (deprecated: use kops create secret instead)")
cmd.Flags().StringVar(&options.OutDir, "out", options.OutDir, "Path to write any local output")
cmd.Flags().BoolVar(&options.CreateKubecfg, "create-kube-config", options.CreateKubecfg, "Will control automatically creating the kube config file on your local filesystem")
cmd.Flags().StringVar(&options.Phase, "phase", options.Phase, "Subset of tasks to run: "+strings.Join(cloudup.Phases.List(), ","))
cmd.Flags().StringVar(&options.Phase, "phase", options.Phase, "Subset of tasks to run: "+strings.Join(cloudup.Phases.List(), ", "))
return cmd
}

Expand Down Expand Up @@ -185,6 +185,10 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd
phase = cloudup.PhaseNetwork
case string(cloudup.PhaseCluster):
phase = cloudup.PhaseCluster
case string(cloudup.PhaseSecurityGroups):
phase = cloudup.PhaseSecurityGroups
case string(cloudup.PhaseLoadBalancers):
phase = cloudup.PhaseLoadBalancers
default:
return fmt.Errorf("unknown phase %q, available phases: %s", c.Phase, strings.Join(cloudup.Phases.List(), ","))
}
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/kops_update_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kops update cluster
--create-kube-config Will control automatically creating the kube config file on your local filesystem (default true)
--model string Models to apply (separate multiple models with commas) (default "config,proto,cloudup")
--out string Path to write any local output
--phase string Subset of tasks to run: assets,cluster,iam,network
--phase string Subset of tasks to run: assets, cluster, iam, load-balancers, network, security-groups
--ssh-public-key string SSH public key to use (deprecated: use kops create secret instead)
--target string Target - direct, terraform, cloudformation (default "direct")
--yes Actually create cloud resources
Expand Down
11 changes: 10 additions & 1 deletion upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ func (c *ApplyClusterCmd) Run() error {
l.WorkDir = c.OutDir
l.ModelStore = modelStore

stageAssetsLifecycle := lifecyclePointer(fi.LifecycleSync)
iamLifecycle := lifecyclePointer(fi.LifecycleSync)
networkLifecycle := lifecyclePointer(fi.LifecycleSync)
clusterLifecycle := lifecyclePointer(fi.LifecycleSync)
stageAssetsLifecycle := lifecyclePointer(fi.LifecycleSync)

switch c.Phase {
case Phase(""):
Expand All @@ -490,6 +490,10 @@ func (c *ApplyClusterCmd) Run() error {
iamLifecycle = lifecyclePointer(fi.LifecycleIgnore)
clusterLifecycle = lifecyclePointer(fi.LifecycleIgnore)

case PhaseSecurityGroups:
// TODO create securityGroupLifecycle
return fmt.Errorf("not implemented yet - phase %q", c.Phase)

case PhaseCluster:
if c.TargetName == TargetDryRun {
stageAssetsLifecycle = lifecyclePointer(fi.LifecycleExistsAndWarnIfChanges)
Expand All @@ -500,6 +504,11 @@ func (c *ApplyClusterCmd) Run() error {
iamLifecycle = lifecyclePointer(fi.LifecycleExistsAndValidates)
networkLifecycle = lifecyclePointer(fi.LifecycleExistsAndValidates)
}

case PhaseLoadBalancers:
// TODO create loadBalancerLifecycle
return fmt.Errorf("not implemented yet - phase %q", c.Phase)

default:
return fmt.Errorf("unknown phase %q", c.Phase)
}
Expand Down
25 changes: 21 additions & 4 deletions upup/pkg/fi/cloudup/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,30 @@ package cloudup

import "k8s.io/apimachinery/pkg/util/sets"

// Phase is a portion of work that kops completes.
type Phase string

const (
PhaseIAM Phase = "iam"
PhaseNetwork Phase = "network"
PhaseCluster Phase = "cluster"
// PhaseStageAssets uploads various assets such as containers in a private registry
PhaseStageAssets Phase = "assets"
// PhaseIAM creates IAM profiles and roles
PhaseIAM Phase = "iam"
// PhaseNetwork creates network infrastructure. Does not include load balancers.
PhaseNetwork Phase = "network"
// PhaseSecurityGroups create firewall rules and security groups.
PhaseSecurityGroups Phase = "security-groups"
// PhaseCluster creates the servers.
PhaseCluster Phase = "cluster"
// PhaseLoadBalancers creates loadbalancers.
PhaseLoadBalancers Phase = "load-balancers"
)

var Phases = sets.NewString(string(PhaseIAM), string(PhaseNetwork), string(PhaseCluster), string(PhaseStageAssets))
// Phases are used for validation and cli help.
var Phases = sets.NewString(
string(PhaseStageAssets),
string(PhaseSecurityGroups),
string(PhaseIAM),
string(PhaseNetwork),
string(PhaseCluster),
string(PhaseLoadBalancers),
)

0 comments on commit adccaad

Please sign in to comment.