-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3149 from tejal29/add_init_docs
[docs] add init docs
- Loading branch information
Showing
15 changed files
with
182 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
--- | ||
title: "Init" | ||
linkTitle: "Init" | ||
weight: 1 | ||
--- | ||
|
||
`skaffold init` is an easy way to get your project up and running in seconds. | ||
|
||
Skaffold auto-generates `build` and `deploy` config for supported builders and deployers. | ||
|
||
|
||
## Build Config Initialization | ||
`skaffold init` currently supports build detection for two builders. | ||
|
||
1. [Docker]({{<relref "/docs/pipeline-stages/builders#dockerfile-locally-with-docker">}}) | ||
2. [Jib]({{<relref "/docs/pipeline-stages/builders#jib-maven-and-gradle-locally">}}) | ||
|
||
`skaffold init` will walk your project directory and look for any `Dockerfiles` | ||
or `build.gradle/pom.xml`. | ||
|
||
If you have multiple `Dockerfile` or `build.gradle/pom.xml` files, Skaffold will provide an option | ||
to pair an image with one of the file. | ||
|
||
E.g. For a multi-services [microservices example](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/microservices) | ||
|
||
```bash | ||
skaffold init | ||
``` | ||
![microservices](/images/microservices-init-flow.png) | ||
|
||
|
||
{{< alert title="Note" >}} | ||
You can choose <code>None (image not built from these sources)</code> in case none of the suggested | ||
options are correct. <br> | ||
You will have to manually set up build config for this artifact | ||
{{</alert>}} | ||
|
||
`skaffold` init also recognizes a maven or gradle project and will auto-suggest [`jib`]({{<relref "/docs/pipeline-stages/builders#jib-maven-and-gradle-locally">}}) builder. | ||
Currently `jib` artifact detection is disabled by default, you can turn it on using the flag `--XXenableJibInit`. | ||
|
||
You can try it this out on example [jib project](https://github.com/GoogleContainerTools/skaffold/tree/master/examples/jib-multimodule) | ||
|
||
```bash | ||
skaffold init --XXenableJibInit | ||
``` | ||
|
||
![jib-multimodule](/images/jib-multimodule-init-flow.png) | ||
|
||
|
||
In case you want to configure build artifacts on your own, use `--skip-build` flag. | ||
|
||
## Deploy Config Initialization | ||
`skaffold init` currently supports only [`Kubeclt` deployer]({{<relref "/docs/pipeline-stages/deployers#deploying-with-kubectl" >}}) | ||
Skaffold will walk through all the `yaml` files in your project and find valid kubernetes manifest files. | ||
|
||
These files will be added to `deploy` config in `skaffold.yaml`. | ||
|
||
```yaml | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- leeroy-app/kubernetes/deployment.yaml | ||
- leeroy-web/kubernetes/deployment.yaml | ||
``` | ||
## Init API | ||
`skaffold init` also exposes an api which tools like IDEs can integrate with via flags. | ||
|
||
This API can be used to | ||
|
||
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. | ||
2. Given a pairing between the image names (artifacts) and build definitions (e.g. Dockerfiles), generate Skaffold `build` config for a given artifact. | ||
|
||
**Init API contract** | ||
|
||
| API | flag | input/output | | ||
| ---- | --- | --- | | ||
| Analyze | `--analyze` | json encoded output of builders and images| | ||
| Generate | `--artifact`| "`=` delimited" build definition/image pair (for example: `=path1/Dockerfile=artifact1`) or <br>JSON string (for example: `{"builder":"Docker","payload":{"path":"Dockerfile"},"image":"artifact")`| | ||
|
||
|
||
### Analyze API | ||
Analyze API walks through all files in your project workspace and looks for | ||
`Dockerfile` files. | ||
|
||
To get all image names and dockerfiles, run | ||
```bash | ||
skaffold init --analyze | jq | ||
``` | ||
will give you a json output | ||
```json | ||
{ | ||
"dockerfiles": [ | ||
"leeroy-app/Dockerfile", | ||
"leeroy-web/Dockerfile" | ||
], | ||
"images": [ | ||
"gcr.io/k8s-skaffold/leeroy-app", | ||
"gcr.io/k8s-skaffold/leeroy-web" | ||
] | ||
} | ||
``` | ||
|
||
### Generate API | ||
To generate a skaffold `build` config, use the `--artifact` flag per artifact. | ||
|
||
For multiple artifacts, use `--artifact` multiple times. | ||
|
||
```bash | ||
microservices$skaffold init \ | ||
-a '{"builder":"Docker","payload":{"path":"leeroy-app/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-app"}' \ | ||
-a '{"builder":"Docker","payload":{"path":"leeroy-web/Dockerfile"},"image":"gcr.io/k8s-skaffold/leeroy-web"}' | ||
``` | ||
|
||
will produce an `skaffold.yaml` config like this | ||
```bash | ||
apiVersion: skaffold/v1beta15 | ||
kind: Config | ||
metadata: | ||
name: microservices | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/leeroy-app | ||
context: leeroy-app | ||
- image: gcr.io/k8s-skaffold/leeroy-web | ||
context: leeroy-web | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- leeroy-app/kubernetes/deployment.yaml | ||
- leeroy-web/kubernetes/deployment.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
docs/content/en/docs/workflows/getting-started-with-your-project.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: "Getting Started With Your Project" | ||
linkTitle: "Getting Started With Your Project" | ||
weight: 10 | ||
--- | ||
|
||
Skaffold requires a `skaffold.yaml`, but - for supported projects - Skaffold can generate a simple config for you that you can get started with. To configure Skaffold for your application you can run [`skaffold init`]({{<relref "docs/references/cli#skaffold-init" >}}). | ||
|
||
Running `skaffold init` at the root of your project directory will walk you through a wizard | ||
and create a `skaffold.yaml` with [build](#build-config-initialization) and [deploy](#deploy-config-initialization) config. | ||
|
||
```bash | ||
skaffold init | ||
``` | ||
|
||
![init-flow](/images/init-flow.png) | ||
|
||
## What's next | ||
You can further set up [File Sync]({{<relref "/docs/pipeline-stages/filesync" >}}) for source files | ||
that do not need a rebuild in [dev mode]({{<relref "/docs/workflows/dev">}}). | ||
|
||
Skaffold automatically forwards Kubernetes Services in [dev mode]({{<relref "/docs/workflows/dev">}}) if you run it with `--port-forward`. If your project contains resources other than services, you can set-up [port-forwarding]({{<relref "/docs/pipeline-stages/port-forwarding" >}}) | ||
to port-forward these resources in [`dev`]({{<relref "docs/workflows/dev" >}}) or [`debug`]({{<relref "/docs/workflows/debug" >}}) mode. | ||
|
||
|
||
For more understanding on how init works, see [`skaffold init`]({{<relref "/docs/pipeline-stages/init" >}}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.