spring-cloud / spring-cloud-deployer-kubernetes

The Spring Cloud Deployer implementation for Kubernetes
Apache License 2.0
157 stars 98 forks source link

Executing a shell command #439

Closed canerkoseren closed 3 years ago

canerkoseren commented 3 years ago

Hi all,

I am triggering a task over scdf dashboard by using deployer properties. I want to execute a shell command right after the pod creation, before the application initialization.

I looked at the spring-cloud-dataflow-docs/configuration-kubernetes, but I could not find a proper property. Is it possible to execute a shell command as I mentioned?

the version of spring-cloud-data-flow 2.5.0.

Thanks :)

canerkoseren commented 3 years ago

Hi all,

An update: I have upgraded the version to 2.8.0-SNAPSHOT.

With these version, I started to deploy a side-car container by using the property deployer.appl.kubernetes.additional-containers .

With these approach, the side-car container should be deployed before the application container. The application container should be started after side-car container is in ready state.

I considered to trigger a task by adding initContainer property, but in this case an image which I did not want would be deployed.

How can I sort the deployments of these containers?

dturanski commented 3 years ago

The recommended way to do this is using Lifecycle Hooks https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/. I am working on an enhancement to expose postStart and preStop exec handlers. httpGet and tcpSocket will be deferred for now.

canerkoseren commented 3 years ago

Hi @dturanski,

I read the documentation you referenced and it seems that 'postStart' handler will fix my issue.

But there is one thing I wanted to ask. I am using 'shell' as entry point style. Will I be able to use 'shell' entry point style with these hooks?

dturanski commented 3 years ago

Hi @dturanski,

I read the documentation you referenced and it seems that 'postStart' handler will fix my issue.

But there is one thing I wanted to ask. I am using 'shell' as entry point style. Will I be able to use 'shell' entry point style with these hooks?

I expect it to work. LMK if you have any issues.