Skip to content

Commit 1c4780f

Browse files
author
Priya Wadhwa
committed
Add --force flag when deploying with kubectl
The --force flag will delete and redeploy a deployment if 'kubectl apply' doesn't work because a field is immutable. Updated the skaffold deploy Dockerfile to reflect this change, added a note in the docs that kubectl > 1.12.0 is recommended, and added a check in the kubectl deployer for the version.
1 parent b80c9f3 commit 1c4780f

File tree

7 files changed

+9
-11
lines changed

7 files changed

+9
-11
lines changed

deploy/skaffold/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RUN apt-get update && \
1818
apt-get install --no-install-recommends --no-install-suggests -y \
1919
python-dev
2020

21-
ENV KUBECTL_VERSION v1.10.0
21+
ENV KUBECTL_VERSION v1.12.0
2222
RUN curl -Lo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
2323
chmod +x /usr/local/bin/kubectl
2424

docs/concepts.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ tools for deployment, for example `kubectl` or `helm`.
2828
Each deployment type has parameters that allow you to
2929
define how you want your app to be installed and updated.
3030

31+
_Note: kubectl version 1.12.0 or greater is recommended for use with skaffold._
32+
3133
=== Artifact
3234
Artifacts are the outputs of the build phase.
3335
Artifacts are created by running a set of steps on some

examples/test-dev-job/skaffold.yaml renamed to integration/examples/test-dev-job/skaffold.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: skaffold/v1alpha2
1+
apiVersion: skaffold/v1alpha4
22
kind: Config
33
build:
44
artifacts:

integration/run_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,17 @@ func TestDev(t *testing.T) {
221221
testCases := []testDevCase{
222222
{
223223
description: "delete and redeploy job",
224-
dir: "../examples/test-dev-job",
224+
dir: "examples/test-dev-job",
225225
args: []string{"dev"},
226226
setup: func(t *testing.T) func(t *testing.T) {
227227
// create foo
228-
cmd := exec.Command("touch", "../examples/test-dev-job/foo")
228+
cmd := exec.Command("touch", "examples/test-dev-job/foo")
229229
if output, err := util.RunCmdOut(cmd); err != nil {
230230
t.Fatalf("creating foo: %s %v", output, err)
231231
}
232232
return func(t *testing.T) {
233233
// delete foo
234-
cmd := exec.Command("rm", "../examples/test-dev-job/foo")
234+
cmd := exec.Command("rm", "examples/test-dev-job/foo")
235235
if output, err := util.RunCmdOut(cmd); err != nil {
236236
t.Fatalf("creating foo: %s %v", output, err)
237237
}
@@ -243,7 +243,7 @@ func TestDev(t *testing.T) {
243243
jobValidation: func(t *testing.T, ns *v1.Namespace, j *batchv1.Job) {
244244
originalUID := j.GetUID()
245245
// Make a change to foo so that dev is forced to delete the job and redeploy
246-
cmd := exec.Command("sh", "-c", "echo bar > ../examples/test-dev-job/foo")
246+
cmd := exec.Command("sh", "-c", "echo bar > examples/test-dev-job/foo")
247247
if output, err := util.RunCmdOut(cmd); err != nil {
248248
t.Fatalf("creating bar: %s %v", output, err)
249249
}
@@ -256,7 +256,7 @@ func TestDev(t *testing.T) {
256256
return originalUID != newJob.GetUID(), nil
257257
})
258258
if err != nil {
259-
t.Fatalf("original UID and new UID are the same, redeploy failed")
259+
t.Fatalf("redeploy failed: %v", err)
260260
}
261261
},
262262
},

pkg/skaffold/deploy/kubectl.go

-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,3 @@ func (k *KubectlDeployer) readRemoteManifest(ctx context.Context, name string) (
187187

188188
return manifest.Bytes(), nil
189189
}
190-
191-
func checkKubectlVersion() error {
192-
193-
}

0 commit comments

Comments
 (0)