On 9/18/18 9:12 AM, Tristan FAURE wrote:
> Hello all my previous message with edit :
> Thank you to both of you for your answers. I was thinking about creating
> services but my db is created then deleted during the build I was not
> sure it was a good practice (and if it is possible) to create
> dynamically (and delete then) a service directly from the jenkinsfile yaml.
>
> I will try
> *EDIT : I did not find how to declare the service in the yaml in my
> jenkinsfile (syntax error). All the containers in one pod works but I
> have resource limitations and I would prefer having them separated*
I don't think you've said so, but I assume you're using the Jenkins
plugin called simply "kubernetes", which is documented at:
https://github.com/jenkinsci/kubernetes-plugin/blob/master/README.md
AFAICT, that plugin has no built-in way to create Kubernetes service
objects. This is why I recommended using kubectl, which allows to
create, delete and query any Kubernetes object. You will need to make
sure the Docker container image contains a kubectl binary of a version
appropriate for your Kubernetes cluster. You will also need to make sure
that kubectl can authenticate itself. I haven't tried it, but the
"Kubernetes CLI Plugin" may be a good option:
https://wiki.jenkins.io/display/JENKINS/Kubernetes+CLI+Plugin
--
Jonathan Rogers