Currently I am trying to implement demo for CI/CD pipeline using SVN , Kubernetes and Jenkins. For kubernetes deployment, I created deployment and services.And for making deployment I am using kubectl apply -f
command for both deployment inside my Jenkins deployment step.
Like the following ,
stage ('Test Deployment')
{
steps
{
sh 'kubectl apply -f deployment/testdeployment.yaml'
sh 'kubectl apply -f deployment/testservice.yaml'
}
}
and service.
For each commit to my SVN repo will trigger this jenkins pipeline job and will execute the commands. After modifying any changes in code the same kubectl apply
command is executing.
Here my confusion is that ,
kubectl apply
command is for updating the existing deployment ?kubectl rollout restart
?For continuous deployment process in CI/CD pipeline implementation , Which command I need to use in my Jenkinsfile for updating the deployment when commit is made to SVN repository?
You can use the Kubectl apply command as long as the name of resources in the deployment and service file has not changed. From the Kubernetes book,
Apply is a command that will update a Kubernetes cluster to match state defined locally in files.
kubectl apply
Fully declarative - don't need to specify create or update - just manage files
The parameters relating to rolling deployment such as how many pods should be available and how many can be taken out of active deployment you can check this documentation.