How can I restart only one service by using skaffold?

Viewed 875

I use skaffold for k8s based microservices app. I enter skaffold dev and skaffold run to run and skaffold delete to restart all microservices.

If I need to restart only one service, what must I do?

2 Answers

According to the docs:

  • Use skaffold dev to build and deploy your app every time your code changes,
  • Use skaffold run to build and deploy your app once, similar to a CI/CD pipeline

1. Deploy your services:

    skaffold run --filename=skaffold_test_1.yaml

(in addition you can have multiple workflow configurations).

2. Change your skaffold workflow configuration and run:

skaffold delete --filename=skaffold_test2.yaml

Using this approach your deployments will be not removed like in the skaffold dev command after stopping skaffold.

Basically managing the content of the skaffold workflow configuration (by adding or removing additional entries allows you to deploy or remove particular service).

apiVersion: skaffold/v1
kind: Config
.
.
.

deploy:
  kubectl:
    manifests:
    - k8s-service1.yaml
#   - k8s-service2.yaml    

You can use skaffold dev's --watch-image flag to restrict the artifacts to monitor. This takes a comma-separated list of images, specified by the artifact.image.

Related