I have an artifact several services with no artifacts and simply have k8s definitions.
The services are things such as postgres and mongodb. Naturally I need these to be up and running prior to my applications but right now I have no way to define this since the postgres and mongodb don't have an artifact.
Is there a way to specify dependency requirement with no artifacts and based on a k8 service name like can be done using docker-compose?
apiVersion: skaffold/v2beta10
kind: Config
build:
local:
push: false
artifacts:
- image: nx2/my-server
context: ./src/server
docker:
dockerfile: Dockerfile
sync:
infer:
- '**/*.py'
deploy:
kubectl:
manifests:
- k8/apps/my-server*
- k8/services/postres*
Unfortunately none of the supported deployers in skaffold currently provide manifest ordering. You might try the kpt deployer, AFAIK it does some common sense ordering and also has a custom ordering feature in the works (https://github.com/GoogleContainerTools/kpt/issues/756)
Note that Skaffold is happy to deploy arbitrary workload objects as long as there's a single artifact. You can use an initContainer to delay your app container from starting, for example:
initContainers:
- name: init-db-ready
image: mongo:4
command: ['/bin/sh', '-c']
args:
- echo "Waiting for mongodb at python-guestbook-mongodb:27017 to go live before the BE...";
- until (mongo --host python-guestbook-mongodb:27017 >/dev/null) do echo "Waiting for connection for 2 sec."; sleep 2; done
Most helpful comment
Note that Skaffold is happy to deploy arbitrary workload objects as long as there's a single artifact. You can use an
initContainerto delay your app container from starting, for example: