Scripts2026年4月14日·1 分钟阅读

Skaffold — Fast Kubernetes Development Workflow from Google

Skaffold handles the inner-loop build-push-deploy cycle for Kubernetes apps. Edit code, and Skaffold rebuilds images, updates manifests, and redeploys to a cluster in seconds — ideal for local dev and CI/CD.

Introduction

Skaffold, from Google, solves the "I edited one line, now I have to rebuild Docker, push to registry, and kubectl apply" pain. Run skaffold dev once: it watches files, rebuilds images, pushes (or sideloads to minikube/kind/k3d), updates manifests, and streams logs in real time.

With over 15,000 GitHub stars, Skaffold is widely adopted for Kubernetes inner-loop development. It works with any builder (Docker, Buildpacks, Bazel, Jib, Kaniko), any manifest tool (kubectl, Helm, Kustomize, kpt), and any cluster (minikube, kind, GKE, EKS, etc.).

What Skaffold Does

Skaffold reads skaffold.yaml — which builders to use, what images to produce, which manifests to deploy, and how to port-forward or tail logs. In dev mode it runs a continuous loop: file change → rebuild → sync or redeploy → stream logs. run does one pass; debug adds language debugger attachments.

Architecture Overview

skaffold.yaml
    |
 +--+------------------+------------------+
 |                     |                  |
[Builder]          [Deployer]        [File Sync]
 Docker, Buildpacks,   kubectl,       direct copy
 Bazel, Jib, Kaniko    Helm, Kustomize  to running pod
    |                     |                  |
  Image(s) ---> pushed to registry
                    |
                 [k8s apply]
                    |
               [Port forward]
                    |
               [Log stream]

Self-Hosting & Configuration

# skaffold.yaml
apiVersion: skaffold/v4beta11
kind: Config
build:
  artifacts:
    - image: myorg/api
      context: services/api
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: "src/**/*.py"
            dest: /app

deploy:
  helm:
    releases:
      - name: api
        chartPath: charts/api
        valuesFiles: [charts/api/values.dev.yaml]
        setValueTemplates:
          image.repository: "{{.IMAGE_REPO_myorg_api}}"
          image.tag: "{{.IMAGE_TAG_myorg_api}}"

portForward:
  - resourceType: service
    resourceName: api
    port: 8080
    localPort: 8080

profiles:
  - name: prod
    deploy:
      helm:
        releases:
          - name: api
            valuesFiles: [charts/api/values.prod.yaml]

Key Features

  • Watch + redeploy — edits trigger rebuild and redeploy in seconds
  • File sync — small changes synced directly into running pods (no image rebuild)
  • Multi-builder — Docker, Buildpacks, Bazel, Jib, Kaniko, custom scripts
  • Multi-deployer — kubectl, Helm, Kustomize, kpt
  • Profiles — dev/staging/prod variants of builds and deploys
  • Debug mode — attach Java/Node/Python/Go debuggers
  • CI/CD friendlyskaffold build / skaffold render for pipelines
  • Remote-to-local devskaffold dev against GKE/EKS clusters

Comparison with Similar Tools

Feature Skaffold Tilt DevSpace Draft Telepresence
Watch + redeploy Yes Yes Yes Yes Partial
File sync Yes Yes Yes Limited Via mount
Builders Many Many Many Limited N/A
Deployers Many Custom DSL Helm-focused Helm N/A
Local->cluster dev Yes Yes Yes Yes Bidirectional
Learning curve Moderate Moderate (Tiltfile) Moderate Low Moderate
Best For Polyglot k8s dev Multi-service k8s dev Helm-centric dev Simple charts Exotic debug cases

FAQ

Q: Skaffold vs Tilt? A: Both target the same problem. Skaffold is YAML-configured and backed by Google; Tilt uses a Tiltfile (Python-like) and is great for complex multi-service setups. Skaffold integrates cleanly with Helm/Kustomize natively.

Q: Do I need a local cluster? A: No — Skaffold works with any Kubernetes: minikube, kind, k3d, GKE, EKS, AKS. For fast dev cycles, a local cluster avoids image push latency.

Q: Can Skaffold work without Docker Desktop? A: Yes. Use the Kaniko builder (runs in-cluster) or Buildpacks. Works on any machine that can talk to a Kubernetes cluster.

Q: Is Skaffold used in CI? A: Yes. skaffold build is common in CI pipelines to produce images + tags consistent with dev. skaffold render outputs manifests for GitOps flows.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产