You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f.BoolVar(&force, "force", false, "Force the generation of the Skaffold config")
61
62
f.StringVar(&composeFile, "compose-file", "", "Initialize from a docker-compose file")
63
+
f.StringVar(&defaultKustomization, "default-kustomization", "", "Default Kustomization overlay path (others will be added as profiles)")
62
64
f.StringArrayVarP(&cliArtifacts, "artifact", "a", nil, "'='-delimited Dockerfile/image pair, or JSON string, to generate build artifact\n(example: --artifact='{\"builder\":\"Docker\",\"payload\":{\"path\":\"/web/Dockerfile.web\"},\"image\":\"gcr.io/web-project/image\"}')")
63
-
f.StringArrayVarP(&cliKubernetesManifests, "kubernetes-manifest", "k", nil, "a path or a glob pattern to kubernetes manifests (can be non-existent) to be added to the kubectl deployer (overrides detection of kubernetes manifests). Repeat the flag for multiple entries. E.g.: skaffold init -k pod.yaml -k k8s/*.yml")
65
+
f.StringArrayVarP(&cliKubernetesManifests, "kubernetes-manifest", "k", nil, "A path or a glob pattern to kubernetes manifests (can be non-existent) to be added to the kubectl deployer (overrides detection of kubernetes manifests). Repeat the flag for multiple entries. E.g.: skaffold init -k pod.yaml -k k8s/*.yml")
64
66
f.BoolVar(&analyze, "analyze", false, "Print all discoverable Dockerfiles and images in JSON format to stdout")
`skaffold init` will walk your project directory and look for any `Dockerfiles`
20
20
or `build.gradle/pom.xml`. Please note, `skaffold init` skips files that are larger than 500MB.
21
21
22
-
If you have multiple `Dockerfile` or `build.gradle/pom.xml` files, Skaffold will provide an option
23
-
to pair an image with one of the file.
22
+
If you have multiple `Dockerfile` or `build.gradle/pom.xml` files, Skaffold will prompt you to
23
+
pair your build config files with any images detected in your deploy configuration.
24
24
25
-
E.g. For a multi-services [microservices example](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/microservices)
25
+
E.g. For an application with [two microservices](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/microservices):
26
26
27
27
```bash
28
28
skaffold init
@@ -31,15 +31,15 @@ skaffold init
31
31
32
32
33
33
{{< alert title="Note" >}}
34
-
You can choose <code>None (image not built from these sources)</code> in case none of the suggested
35
-
options are correct. <br>
36
-
You will have to manually set up build config for this artifact
34
+
You can choose <code>None (image not built from these sources)</code> if none of the suggested
35
+
options are correct, or this image is not built by any of your source code.<br>
36
+
If this image is one you want Skaffold to build, you'll need to manually set up the build configuration for this artifact.
37
37
{{</alert>}}
38
38
39
-
`skaffold` init also recognizes a maven or gradle project and will auto-suggest [`jib`]({{<relref "/docs/pipeline-stages/builders#/local#jib-maven-and-gradle">}}) builder.
40
-
Currently `jib` artifact detection is disabled by default, you can turn it on using the flag `--XXenableJibInit`.
39
+
`skaffold` init also recognizes Maven and Gradle projects, and will auto-suggest the[`jib`]({{<relref "/docs/pipeline-stages/builders#/local#jib-maven-and-gradle">}}) builder.
40
+
Currently `jib` artifact detection is disabled by default, but can be enabled using the flag `--XXenableJibInit`.
41
41
42
-
You can try it this out on example [jib project](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/jib-multimodule)
42
+
You can try this out on our example [jib project](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/jib-multimodule)
In case you want to configure build artifacts on your own, use `--skip-build` flag.
52
-
53
51
## Deploy Config Initialization
54
-
`skaffold init` currently supports only [`kubectl` deployer]({{<relref "/docs/pipeline-stages/deployers#deploying-with-kubectl" >}})
55
-
Skaffold will walk through all the `yaml` files in your project and find valid kubernetes manifest files.
52
+
`skaffold init` support bootstrapping projects set up to deploy with [`kubectl`]({{<relref "/docs/pipeline-stages/deployers#deploying-with-kubectl" >}})
53
+
or [`kustomize`]({{<relref "/docs/pipeline-stages/deployers#deploying-with-kubectl" >}}).
54
+
For projects deploying straight through `kubectl`, Skaffold will walk through all the `yaml` files in your project and find valid Kubernetes manifest files.
56
55
57
56
These files will be added to `deploy` config in `skaffold.yaml`.
58
57
@@ -64,15 +63,60 @@ deploy:
64
63
- leeroy-web/kubernetes/deployment.yaml
65
64
```
66
65
66
+
For projects deploying with `kustomize`, Skaffold will scan your project and look for `kustomization.yaml`s as well as Kubernetes manifests.
67
+
It will attempt to infer the project structure based on the recommended project structure from the Kustomize project: thus,
68
+
**it is highly recommended to match your project structure to the recommended base/ and overlay/ structure from Kustomize!**
69
+
70
+
This generally looks like this:
71
+
72
+
```
73
+
app/ <- application source code, along with build configuration
74
+
main.go
75
+
Dockerfile
76
+
...
77
+
base/ <- base deploy configuration
78
+
kustomization.yaml
79
+
deployment.yaml
80
+
overlays/ <- one or more nested directories, each with modified environment configuration
81
+
dev/
82
+
deployment.yaml
83
+
kustomization.yaml
84
+
prod/
85
+
...
86
+
```
87
+
88
+
When overlay directories are found, these will be listed in the generated Skaffold config as `paths` in the `kustomize` deploy stanza. However, it generally does not make sense to have multiple overlays applied at the same time, so **Skaffold will attempt to choose a default overlay, and put each other overlay into its own profile**. This can be specified by the user through the flag `--default-kustomization`; otherwise, Skaffold will use the following heuristic:
89
+
90
+
1) Any overlay with the name `dev`
91
+
2) If none present, the **first** overlay that isn't named `prod`
92
+
93
+
*Note: order is guaranteed, since Skaffold's directory parsing is always deterministic.*
67
94
68
95
## Init API
69
-
`skaffold init` also exposes an api which tools like IDEs can integrate with via flags.
96
+
`skaffold init`also exposes an AP:I which tools like IDEs can integrate with via flags.
70
97
71
98
This API can be used to
72
99
73
100
1. Analyze a project workspace and discover all build definitions (e.g. `Dockerfile`s) and artifacts (image names from the Kubernetes manifests) - this then provides an ability for tools to ask the user to pair the artifacts with Dockerfiles interactively.
74
101
2. Given a pairing between the image names (artifacts) and build definitions (e.g. Dockerfiles), generate Skaffold `build` config for a given artifact.
75
102
103
+
The resulting `skaffold.yaml` will look something like this:
--compose-file='': Initialize from a docker-compose file
666
+
--default-kustomization='': Default Kustomization overlay path (others will be added as profiles)
666
667
-f, --filename='skaffold.yaml': Path or URL to the Skaffold config file
667
668
--force=false: Force the generation of the Skaffold config
668
-
-k, --kubernetes-manifest=[]: a path or a glob pattern to kubernetes manifests (can be non-existent) to be added to the kubectl deployer (overrides detection of kubernetes manifests). Repeat the flag for multiple entries. E.g.: skaffold init -k pod.yaml -k k8s/*.yml
669
+
-k, --kubernetes-manifest=[]: A path or a glob pattern to kubernetes manifests (can be non-existent) to be added to the kubectl deployer (overrides detection of kubernetes manifests). Repeat the flag for multiple entries. E.g.: skaffold init -k pod.yaml -k k8s/*.yml
669
670
--skip-build=false: Skip generating build artifacts in Skaffold config
670
671
671
672
Usage:
@@ -680,6 +681,7 @@ Env vars:
680
681
*`SKAFFOLD_ANALYZE` (same as `--analyze`)
681
682
*`SKAFFOLD_ARTIFACT` (same as `--artifact`)
682
683
*`SKAFFOLD_COMPOSE_FILE` (same as `--compose-file`)
684
+
*`SKAFFOLD_DEFAULT_KUSTOMIZATION` (same as `--default-kustomization`)
683
685
*`SKAFFOLD_FILENAME` (same as `--filename`)
684
686
*`SKAFFOLD_FORCE` (same as `--force`)
685
687
*`SKAFFOLD_KUBERNETES_MANIFEST` (same as `--kubernetes-manifest`)
0 commit comments