Skip to content

Commit

Permalink
Merge pull request #1568 from corneliusweig/force-deploy
Browse files Browse the repository at this point in the history
Add `--force` command line option to run and deploy sub-commands
  • Loading branch information
nkubala authored Apr 18, 2019
2 parents 7ddbe57 + b566986 commit 6bd7080
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 237 deletions.
1 change: 1 addition & 0 deletions cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func FlagToEnvVarName(f *pflag.Flag) string {

func AddRunDeployFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&opts.Tail, "tail", false, "Stream logs from deployed objects")
cmd.Flags().BoolVar(&opts.Force, "force", false, "Recreate kubernetes resources if necessary for deployment (default: false, warning: might cause downtime!)")
cmd.Flags().StringArrayVarP(&opts.CustomLabels, "label", "l", nil, "Add custom labels to deployed objects. Set multiple times for multiple labels.")
}

Expand Down
4 changes: 4 additions & 0 deletions docs/content/en/docs/references/cli/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ Flags:
-d, --default-repo string Default repository value (overrides global config)
--enable-rpc skaffold dev Enable gRPC for exposing Skaffold events (true by default for skaffold dev)
-f, --filename string Filename or URL to the pipeline file (default "skaffold.yaml")
--force Recreate kubernetes resources if necessary for deployment (default: false, warning: might cause downtime!)
--images strings A list of pre-built images to deploy
--insecure-registry stringArray Target registries for built images which are not secure
-l, --label stringArray Add custom labels to deployed objects. Set multiple times for multiple labels.
Expand All @@ -354,6 +355,7 @@ Env vars:
* `SKAFFOLD_DEFAULT_REPO` (same as `--default-repo`)
* `SKAFFOLD_ENABLE_RPC` (same as `--enable-rpc`)
* `SKAFFOLD_FILENAME` (same as `--filename`)
* `SKAFFOLD_FORCE` (same as `--force`)
* `SKAFFOLD_IMAGES` (same as `--images`)
* `SKAFFOLD_INSECURE_REGISTRY` (same as `--insecure-registry`)
* `SKAFFOLD_LABEL` (same as `--label`)
Expand Down Expand Up @@ -517,6 +519,7 @@ Flags:
-d, --default-repo string Default repository value (overrides global config)
--enable-rpc skaffold dev Enable gRPC for exposing Skaffold events (true by default for skaffold dev)
-f, --filename string Filename or URL to the pipeline file (default "skaffold.yaml")
--force Recreate kubernetes resources if necessary for deployment (default: false, warning: might cause downtime!)
--insecure-registry stringArray Target registries for built images which are not secure
-l, --label stringArray Add custom labels to deployed objects. Set multiple times for multiple labels.
-n, --namespace string Run deployments in the specified namespace
Expand All @@ -542,6 +545,7 @@ Env vars:
* `SKAFFOLD_DEFAULT_REPO` (same as `--default-repo`)
* `SKAFFOLD_ENABLE_RPC` (same as `--enable-rpc`)
* `SKAFFOLD_FILENAME` (same as `--filename`)
* `SKAFFOLD_FORCE` (same as `--force`)
* `SKAFFOLD_INSECURE_REGISTRY` (same as `--insecure-registry`)
* `SKAFFOLD_LABEL` (same as `--label`)
* `SKAFFOLD_NAMESPACE` (same as `--namespace`)
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SkaffoldOptions struct {
SkipTests bool
CacheArtifacts bool
EnableRPC bool
Force bool
NoPrune bool
CustomTag string
Namespace string
Expand Down Expand Up @@ -82,3 +83,7 @@ func (opts *SkaffoldOptions) Labels() map[string]string {
func (opts *SkaffoldOptions) Prune() bool {
return !opts.NoPrune && !opts.CacheArtifacts
}

func (opts *SkaffoldOptions) ForceDeploy() bool {
return opts.Command == "dev" || opts.Force
}
5 changes: 5 additions & 0 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type HelmDeployer struct {
kubeContext string
namespace string
defaultRepo string
forceDeploy bool
}

// NewHelmDeployer returns a new HelmDeployer for a DeployConfig filled
Expand All @@ -58,6 +59,7 @@ func NewHelmDeployer(runCtx *runcontext.RunContext) *HelmDeployer {
kubeContext: runCtx.KubeContext,
namespace: runCtx.Opts.Namespace,
defaultRepo: runCtx.DefaultRepo,
forceDeploy: runCtx.Opts.ForceDeploy(),
}
}

Expand Down Expand Up @@ -190,6 +192,9 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates
} else {
args = append(args, "upgrade", releaseName)
args = append(args, h.Flags.Upgrade...)
if h.forceDeploy {
args = append(args, "--force")
}
if r.RecreatePods {
args = append(args, "--recreate-pods")
}
Expand Down
Loading

0 comments on commit 6bd7080

Please sign in to comment.