How to Deploy production grade Jenkins server? - amazon-web-services

I want to deploy Jenkins on AWS but I don't know what is the best way to deploy it.
I watched videos and read articles and below are some possible solutions.
1- Jenkins as a docker container, bind the volume and expose it with ELB or Nginx reverse proxy.
2- Jenkins on EKS or unmanaged K8s cluster and expose it via ELB.
3- Install as a regular application via an apt-get command in EC2 and expose it via Nginx reverse/ELB.
I don't know what is the best way to deploy in production.
P.S: next plan is to deploy our Nexus and Sonarqube servers as well.
Thanks in advance :)

Well it completely depends on many factors such as:
Cost
Number of users (High availability)
If cost isn't a big issue, you can use Amazon EKS cluster to deploy highly available Jenkins server.
Checkout this guide on how to do it on EKS.

Related

Deploying a web application for Selenium testing on AWS EC2

I have a web application that uses Selenium in backend to run few scripts when invoked by user. I want to deploy this web app on AWS.
Here are my findings so far:
I can have a windows EC2 instance created and then I can install tomcat, firefox and all the necessary stuff. Then using putty or any other client, I can deploy my war and start tomcat.
I can directly make use of Elastic Beanstalk and deploy my war file there itself but then, there is no windows EC2 available for beanstalk and I don't know how to install firefox there and make my application work.
What is the best way to achieve this and what steps should I follow. I want to install a specific firefox version to be able to make it run with my selenium scripts.
There are two separate things here:
Deployment of web application on AWS cloud
Run the selenium tests against your web application
According to me, you should first think of deploying a web application to AWS cloud. There are many ways by which you can get it deployed to AWS cloud with below services:
Spin a new AWS EC2 instance, install all required software and deploy the web application.
Use AWS elastic beanstalk service with either with tomcat or docker.
Use AWS ECS if you prefer docker
According to me, second option will be quick for you with tomcat environment option. If you select tomcat environment, then your platform will be Tomcat 8 Java 8 on 64bit Amazon Linux.
Now, here comes the second part. You can have below options for your browser environments.
Spin a new separate AWS EC2 instances with correct AMI and install your specific browsers on these instances.
If you prefer SaaS, then you can take a look at browserstack or SauceLabs for remote environment.
If you have CI(jenkins/travis/Circle CI), then make use of that infrastructure to luanch your tests with either option from the above.

Recommendation: Deploy Docker application to AWS

I got a local Docker stack running Node.js, MongoDB and Nginx.
It runs perfectly using docker-compose up --build.
Now it's time to deploy my application to a production environment.
I have considered EC2 Container Service and EC2, but can you recommend an easier approach? The learning curve is steep!
For MongoDB -
Use AWS quick start MongoDB
http://docs.aws.amazon.com/quickstart/latest/mongodb/overview.html
http://docs.aws.amazon.com/quickstart/latest/mongodb/architecture.html
For rest of the docker stack i.e NodeJS & Nginx -
Use the AWS ElasticBeanstalk Multi Container Deployment
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html
Elastic Beanstalk supports Docker, as documented here. Elastic Beanstalk would manage the EC2 resources for you so that you, which should make things a bit easier on you.
You can install Kontena to AWS and use that to deploy your application to production environment (of course other cloud providers are also supported). Transition from Docker Compose is very smooth since kontena.yml uses similar syntax and keys as docker-compose.yml.
With Kontena you will have private image registry, load balancer and secret management built-in that are very useful when running containers in production.

Hosting web services project in Amazon

Hi We have built a java based web services project with using jboss server. How do I host this application with Amazon cloud? This web services act as back end for a mobile android app.
I am looking for PaaS option of Jboss server and Postgres database. I could create a postgres database. But could not find Jboss server.
My understanding is in PaaS, Jboss and Postgres should be able to scale up itself as per demand.
Another option provided by Amazon is EC2 as far as I have understood. But if I go with EC2, I will have install and set up jboss and postgres on my own. Then does it scale up by itself as per demand?
Please guide.
If you want to deploy your web application to AWS and ensure its scalability, you have basically two options:
EC2 instance [IaaS] - The disadvantage is, as you mentioned in your question, that you have to configure everything manually. Some external mechanism for scaling has to be used. Amazon provides its AutoScaling service which can be configured to launch new EC2 instances based on utilization or some other metric.
Elastic Beanstalk [PaaS] - This service has the auto-scaling already built in and manages the EC2 instances with your application on its own (it takes care about launching them, deploying the app etc). The disadvantage is that JBoss server is not support at the moment (you would have to switch to Tomcat).
There is a way, how to make JBoss work on Elastic Beanstalk, however. ELB has newly added the support for Docker so if you make your JBoss API run in Docker, you can deploy it to ELB and scale it without much effort and configuration.
As for the database, mentioned in your question, Amazon has plenty of choices, Postgres included, in their RDS service.

How to connect to specific instance behind Elastic Load Balancer

I'm deploying my app via Elastic Beanstalk, which creates and Elastic load balancer and puts all my instances behind it (3 or more).
Is there a way to contact each of these instances directly? I want to trigger a specific command on each instances (git pull command to synchronize with the latest code in my remote repo).
I have the list of IP address and public DNS of the instances from PHP SDK but since the firewalls rules restricts the source of IP address to the elastic load balancer IP on port 80, I can't seem to access them directly.
Is there a way around it?
P.S. The SSH port seems to open for all traffic, but how can I create a trigger with that? I'm hoping to create a PHP script to automate this with a webhook on the remote repo.
I highly suggest you use the EB CLI with git integration for all deployments, no matter how small. It is great because you can map a git branch to an environment with eb use YOUR_ENV then when you run eb deploy with that branch checked out it will deploy to that environment.
There is a lot of work involved in ensuring multiple servers pull the correct code and everything is working as expected. What if a server is in the processes of spinning up but is not ready for SSH so your script skips it and it does not get the new code?
Also, what happens when a new server spins up but it is using the old application because that's what is in EB? You could have your kickstart do a git pull but then what happens when you are not ready to push, a new server starts and is alone with the new code?
I could probably find 5 more edge cases without breaking a sweat. Look into eb deploy, you will be happy you did.
You need to setup a CI (or make a simple web service) and create a webhook in your repository. Your CI need to get all instances under your Elastic Beanstalk environment and then call git pull via SSH.
Or, just create a cron job in your all instances via .ebxensions script.
I thought it's not a good practice in Elastic Beanstalk to run git pull in order to synchronize your app with your git repo. Because, it misused the Application Version semantic meaning. Sometimes, you can't determine which app version are in your instances from Application Version. It's better to create a new Application Version in Elastic Beanstalk to deploy a new app version.
If you host your repo in Github, you can take a look into CodeDeploy.

AWS ElasticBeanstalk in a production environment

I wonder about the choice of AWS Elastic Beanstalk as an environment for the production system. Do you have some experience in this regard?
More info as I have been using EB for more than 8 months...
So far so good, elastic beanstalk has its limitation though.
It is designed for service handling, but when you just want a processing unit, you need to do something additional for ELB and autoscaling.
Fixed in latest release: No VPC yet, so your Elastic Beanstalk is still exposed to the internet., but VPC support is limited and need manually config through config files.
Fixed in latest release: Not easy to customize the webserver (e.g. tomcat) you have to use your own images.
Limited tuning option on the webserver parameter.
From my experience, reliability is OK not great, the main problem is the EB automation scripts sometime can stuck you environment.
But overall I like it.
We deployed our Java webapplication (all three environments) Beta, Staging and live on ElasticBeanStalk. They are doing well, so far we haven't faced any issues with Elastic Beanstalk.