Jenkins CI/CD deployment to AWS EKS without Docker registry - docker

We are trying to setup a development CI/CD pipeline with Jenkins that builds the Docker Images and deploy that Directly to AWS EKS cluster. Is this even possible??
Our Existing system
Jenkins as CI to pick the Code from GitLab and Build Docker Image
After Build, Jenkins push the Image to Jfrog Artifactory(Professional)
We use Harness for CD, that picks the Image from Artifactory and deploy that
to AWS
Here, Artifiactory and Harness Incurs cost for us and we don't want to use that for Development builds. So, we have setup a Docker Registry with Soantype Nexus3 OSS(open source version).
I would like to know two Options here:
if I can use Jenkins to Build Docker Image and Push that to Nexus Docker Registry and Use Jenkins Itself for CD to deploy that to AWS EKS?
Build Docker images with Jenkins and directly deploy that to AWS EKS without even having to store it in a docker registry?
Any suggestions and help is highly appreciated!

the first option much better.
because one day may need roll-back docker image on Kubernetes. (even development environment)
or you can use AWS ECR. it's easier to use on EKS.
and I think ECR is cheaper than Nexus operation cost.

You may be happy to know that Harness has created a free software version of it's CD service, called Harness Continuous Delivery Community Edition, which should work nicely for your development builds.

Related

Auto deploy docker images on push

First, I'm noob with Continuous Deployement. I currently have a VPS running 3 docker containers (Flask, MongoDb, Nginx) that I'm pulling from DockerHub with a docker-compose. What I want to do is auto deploy those 3 containers when pushing some code in my github repo. I think It's possible with Ansible but I never used it.
Someone can explain me how to do it ?
Many thx !
Finally I will use Jenkins :)
That implies a webhook, as explained in "How to Integrate Your GitHub Repository to Your Jenkins Project" by Guy Salton
And that means your Jenkins server is accessible through an internet-facing public URL, which is not always obvious when working in a corporate environment.
GitHub Actions "Publishing Docker images" can help publishing the image to DockerHub, but you still need to listen/detect those events in order for your Jenkins to trigger job pulling said ppublished images.
For that, a regular sheduler Jenkins job using regclient/regclient can help checking the latest published SHA2 image ID has or has not changed.
See more with "Container Registry Management with Brandon Mitchell: DevOps and Docker (Ep 108)".

Automatically deploy new container to Google Cloud Compute Engine from Google Container Registry

I have a docker container which I push to GCR like gcloud builds submit --tag gcr.io/<project-id>/<name>, and when I deploy it on GCE instance, every time I deploy it creates a new instance and I have to remove the old instance manually. The question is, is there a way to deploy containers and force the GCE instances to fetch new containers? I need exactly GCE, not Google Cloud Run or other because it is not an HTTP service.
I deploy the container from Google Console using the Deploy to Cloud Run button
I'm posting this Community Wiki for better visibility. In the comment section there were already a few good solutions, however at the end OP wants to use Cloud Run.
At first I'd like to clarify a few things.
I have a docker container which I push to GCR like gcloud builds submit
gcloud builds submit is a command to build using Google Cloud Build.
Cloud Build is a service that executes your builds on Google Cloud Platform infrastructure. Cloud Build can import source code from Cloud Storage, Cloud Source Repositories, GitHub, or Bitbucket, execute a build to your specifications, and produce artifacts such as Docker containers or Java archives.
In this question, OP is referring to Container Registry, however GCP recommends to use Artifact Registry which soon will replace Container Registry.
Pushing and pulling images from Artifact Registry is explained in Pushing and pulling images documentation. It can be done by docker push or docker pull command, where earlier you have to tag an image and create Artifact Registry.
Deploying on different GCP products
Regarding deploying on GCE, GKE and Cloud Run, those are GCP products which are quite different from each.
GCE is IaaS where you are specifying the amount of resources and you are maintaining all the installation of all software (you would need to install Docker, Kubernetes, programming libs, etc).
GKE is like Hybrid as you mention the amount of resources you need but it's customized to run containers on it. After creation you already have docker, kubernetes and other software needed to run containers on it.
Cloud Run is a serverless GCP product, where you don't need to calculate the amount of needed resources, installing software/libs, it's a fully managed serverless platform.
When you want to deploy a container app from Artifact Registry / Container Registry, you are creating another VM (GCE and GKE) or new service (Cloud Run).
If you would like to deploy new app on the same VM:
On GCE, you would need to pull an image and deploy it on that VM using Docker or Kubernetes (Kubeadm).
On GKE you would need to deploy a new deployment using command like
kubectl create deployment test --image=<location>-docker.pkg.dev/<projectname>/<artifactRegistryName>/<imageName>
and delete the old one.
In Cloud Run you can deploy an app without concerns about resources or hardware, which steps are described here. You can create revisions for specific changes in the image. However Cloud Run also allows CI/CD using GitHub, BitBucket or Cloud Source Repositories. This process is also well described in GCP documentation - Continuous deployment
Possible solutions:
Write a Cloudbuild.yaml file that do that for you at each CI/CD pipeline run
Write a small application on GCE that subscribes to Pub/Sub notifications created by Cloud Build. You can then either pull the new container or launch a new instance.
Use Cloud Run with CI/CD.
Based on one of the OP's comments, as chosen solution was to use Cloud Run with CI/CD.

Is it possible to deploy a node.js server to minikube from local jenkins when any commit done to github?

I'm new to Jenkins...
Usually, we have a Jenkins CI/CD pipeline where it deploys code to kubernetes...
similarly, will I be able to have a deploy locally on minikube...?
if so pls guide me...
Kubernetes is running Deployments from Docker images, those images need to be hosted somewhere.
You can deploy a registry server and run it locally as a Docker container.
You can also follow this guide on how to Use your local registry with Kubernetes
Please, read the Kubernetes documentation for Images.
Also, here is a StackOverflow question on how to install Jenkins locally
If you have more questions, feel free to ask.

Deploying a SpringBoot into another server in a docker through Jenkins

I'm new to CI/CD process.
We have a model deploying a spring boot application through jenkins in docker in a same machine.
We was searching in internet how to deploy an application to another server, the only key which we have got is through SSH agent. I hope SSH is only for communicating.
Can we have a complete example how to deploy into another server and what are the other preventive measure to be taken into account.
Kindly guide us
In your Jenkins pipeline you need to define a stage for publishing the docker image and in your infrastructure you need a repository that stores your artifacts and docker images.
Repositories I know are Nexus or JFrog Artifactory.
So your server1, at the end of the pipeline, will upload the stable docker image to Nexus.
To execute the docker images in another server (not using an orchestrator) you may use Ansible.
On the net you can find a lot of sources, for example: https://www.codementor.io/mamytianarakotomalala/how-to-deploy-docker-container-with-ansible-on-debian-8-mavm48kw0

How to deploy/run a Docker image from a build server

Having built,run and executed tests against a docker image on a CI build server(TeamCity2017), how should we deploy it to further machines?
How, for example, if we push it to a Docker registry, would our CI server instruct the target machine to pull and run the image? I.e. where it an application we would use Octopus for this deployment step, but our Octopus server doesn't support Docker deployments as yet.
Any guidance appreciated.
Michael McD.
I would use Octo to deploy your images onto target machines. You'd need to use powershell scripts to have your machines run the images. Or you can use something like Rancher, which is a docker swarm manager. There is no feasible way to have TeamCity deploy your images. The software simply isn't built to be able to do deploys.
The Rancher solution would not be automated, at least not to my knowledge. You would have to trigger upgrades when a new image is pushed to the docker registry.

Resources