Init  alpha 

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
  2. Jib

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

skaffold init

microservices

skaffold init also recognizes a maven or gradle project and will auto-suggest jib 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

skaffold init --XXenableJibInit

jib-multimodule

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 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.

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. Dockerfiles) 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
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

skaffold init --analyze | jq

will give you a json output

{
  "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.

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

apiVersion: skaffold/v1
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
Last modified November 6, 2019: re-org with pivot as builder typeS (6cab7f473)