Skip to content

Support pre-post hooks for build, deploy and sync #1441

Closed
@adrienjt

Description

Hi, in my workflow, I need to run some commands before I run skaffold. In CI/CD, I wrapped skaffold in a script, but it's a pain for developers to remember to run a script before running skaffold run or skaffold dev or for me to maintain a wrapping CLI (EDIT: and skaffold dev doesn't work, see use case below). The developer experience would be improved if skaffold supported pre-build/pre-deploy hooks (and post-build/post-deploy hooks).

Suggestion:

apiVersion: skaffold/v1...
kind: Config
hooks:
  preBuild:
    exec:
      command: ["python", "my-pre-build-hook.py"]
  postBuild:
    exec:
      command: ["./my-post-build-hook.sh"]
  preDeploy:
    exec:
      command: ["terraform", ...]
  postDeploy:
    exec:
      command: ["curl", ...]
...

Details on my use case:

  • I have a Python monorepo of microservices and shared libraries. I don't want to use the root of the repo as a microservice's Dockerfile context, because of the performance hit (breaks caching, huge context to send to docker daemon or kaniko), so before I build a microservice image, I copy the required shared libraries temporarily in the microservice subfolder / Dockerfile context, and remove them afterward (Docker doesn't follow symlinks if you wonder).
  • kustomize doesn't support build-time variables, so I generate overlays to label, prefix and change namespaces depending on, e.g., the pull request number or the developer name.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions