We are currently using Kustomize to manage deployments in Kubernetes with Jenkins as ci/cd. As Kustomize build the manifests and then kubectl take the output and apply them, when there is a Job and the Job already exists, the api_server throws an error and so the deploy fails. I would like to avoid to create a complex Jenkinsfile that parse yaml files to look for a Job kind spec and then take further actions, this should make too complex the Jenkinsfile logic. Does anyone is using the same tools and is facing the same problems? Which could be the best way to achieve a job deployment in a pipeline without make Jenkins aware of the manifests kind?
KUSTOMIZE : Shared Library in Jenkins Pipeline
You might want to use https://jenkins.io/doc/book/pipeline/shared-libraries/ Shared libraries and open source your specs.
That would greatly aid the Public community
Alternatives
Alternatively one might want to also consider