I am a newbee in Kubernetes.
I have a Jenkins pipeline to deploy microservices [Spring Boot] into Kubernetes cluster [ EKS ]. It is in working condition and able to deploy into EKS cluster successfully.
For first time [ when Deployment / Service / Pod is not present in EKS ] application is deploying and displaying the content properly, but after that Application is deploying into cluster but not showing the updated content, it is showing the old content.
If i remove the existing Deployment , Service and Pod, then it is deploying and displaying the new content.
Any clue if i am missing something.
Check if you are using "latest" tag image in your POD specification. If yes, you can do either of 2 things -
kubectl patch deployment <deploymentName> -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"
date +'%s'\"}}}}}"
Let me know if that resolves your issue.
`
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<to>
<repository>docker.io/repo</repository>
<tag>${project.version}</tag>
</to>
</configuration>
</plugin>
` Let me know if this plugin tag helps.
Please check the image tag is the same? If yes then provide different for each build.
If you need the same image tag then change imagePullPolicy to Always.
https://kubernetes.io/docs/concepts/containers/images/
If the problem still persists check deployment rollout.
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Share your YAML file, if still not able to fix it.
There is a trick .. you have to use a pattern in pom and deployment yaml file that pattern need to be replaced using sed command in jenkins file
in pom
<image>registry.hub.docker.com/xxxx/yyyy:#BUILD_NUMBER</image>
In deloyment.yaml file
image: registry.hub.docker.com/xxxx/yyyy:#BUILD_NUMBER
and in jenkins file
sh "sed -i 's/#BUILD_NUMBER/${BUILD_NUMBER}/g' pom.xml"
sh "sed -i 's/#BUILD_NUMBER/${BUILD_NUMBER}/g' kubedeploy.yaml"