67% found this document useful (3 votes)
1K views33 pages

Devops Lab Manual

The document provides details about experiments to be conducted in a DevOps lab manual. It includes 10 experiments related to tools like Jenkins, GitHub, Git, Chef, Ansible, Linux commands, Terraform, CloudFormation, OpsWorks and AWS CodeStar/Fargate. The first experiment involves installing and configuring Jenkins on Windows or Oracle VM and creating Jenkins jobs. The second focuses on hands-on with GitHub and Git operations. The third uses Chef Solo on Linux for AWS configuration management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
67% found this document useful (3 votes)
1K views33 pages

Devops Lab Manual

The document provides details about experiments to be conducted in a DevOps lab manual. It includes 10 experiments related to tools like Jenkins, GitHub, Git, Chef, Ansible, Linux commands, Terraform, CloudFormation, OpsWorks and AWS CodeStar/Fargate. The first experiment involves installing and configuring Jenkins on Windows or Oracle VM and creating Jenkins jobs. The second focuses on hands-on with GitHub and Git operations. The third uses Chef Solo on Linux for AWS configuration management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

DEVOPS LAB MANUAL

CP08-IV-SEMESTER

DEVOPS
LAB MANUAL

Prepared by:-
Ranjitha M
Approved by:
Program Manager – CP08
DEVOPS LAB MANUAL

SNo Experiments Hrs


(80)

1.0 Getting Started with Jenkins on Windows (Hyper or Oracle VM box) 8

1.1 Build the server on Hyper or Oracle VM box on on-premise machine

1.2 Install and configure a Jenkins server

1.3 Add plugins and create Jenkins jobs

1.4 Run Jenkins jobs and examine outputs and results

2.0 Hands on with GitHub & Git 8

2.1 Creating new free GitHub account online.

2.2 Creating new repository and commit the codes to newly created repository

2.3 Importing the codebase from different Github account to your Github account

2.4 Understanding different operations on Github

3.0 Using Chef Solo on Linux for AWS 8

3.1 Configure a Chef node in AWS using Chef Solo

3.2 Write Chef cookbooks and recipes

3.3 Use Chef attributes and templates to generalize your cookbooks

3.4 Create Chef roles to define Chef node functions

4.0 Software provisioning and configuration management with Ansible 8

4.1 Introduction to Ansible hands-on

4.2 YAML and Hands-on Exercises

4.3 Build Ansible Inventory Files and modules

4.4 Automate provisioning and web server deployment

5.0 Linux Command Line Byte Session 8

5.1 Understand what the Linux command line

5.2
Directory Manipulations commands
DEVOPS LAB MANUAL

5.3 Use common commands for working with files and directories

5.4
Installing Software in Linux CLI
5.5
Sending E-mails
6.0 Create AWS Resources with Terraform 8

6.1 Install Terraform on Linux

6.2 Configure Terraform providers

6.3 Create AWS resources with Terraform

7.0 Deploy Wordpress using CloudFormation 8

7.1 Create your first cloud infrastructure using Amazon CloudFormation

7.2 Use CloudFormation to launch an EC2 (Linux) instance

7.3 Create the Stack and choose template for launching instance

7.4 Perform Wordpress full installation in the instance

8.0 Build your first OpsWorks stack 8

8.1 Build the infrastructure and automate code deployment for a PHP application with
OpsWorks

8.2 Registering the Instance (Linux) in OpsWorks

8.3 Deploying Apps- Deploy test PHP application

8.4 Execute other commands – Undeploy, Rollback, Start Web Server, Stop Web
Server, Restart Web Server

9.0 Develop and Deploy an Application with AWS CodeStar 8

9.1 Create AWS CodeStar projects

9.2 Monitor project activity

9.3 Develop and deploy code using AWS CodeStar

9.4 Manage teams inside of AWS CodeStar projects

10.0 Use AWS Fargate for Serverless Deployment of Container Applications 8


DEVOPS LAB MANUAL

10.1 Use application source files to create Docker container images and place them in
Amazon ECR
10.2 Create an Amazon ECS cluster

10.3 Use the Amazon ECR images to create ECS task definitions and services

10.4 Implement the services in ECS by using AWS Fargate enjoying the advantages of
serverless
10.5 Register ECS tasks with an Application Load Balancer (ALB) target group
DEVOPS LAB MANUAL

1.0 Getting Started with Jenkins on Windows (Hyper or Oracle VM box)

1.1 Build the server on Hyper or Oracle VM box on on-premise machine

1.2 Install and configure a Jenkins server

1.3 Add plugins and create Jenkins jobs

1.4 Run Jenkins jobs and examine outputs and results

Instruction to install Jenkins on Ubuntu server

 Build the Ubuntu instance on AWS and here we are trying to access the AWS instance over
SSH.

ssh -i "Prem_Jenkins.pem" [email protected]

Try to execute below commands on remote location via SSH(Putty or MobaXterm)

Test Instance - ubuntu@ip-172-31-18-58:~$

Prerequisites

We should ensure JDK installed, before we install Jenkins on the server.

Install Java:

Since Jenkins is a Java application, the first step is to install Java. Update the package index
and install the Java 8 OpenJDK package with the following commands
sudo apt update
sudo apt install openjdk-8-jdk

Add the Jenkins Debian repository


DEVOPS LAB MANUAL

 Debian package repository of Jenkins to automate installation and upgrade.


 Import the GPG keys of the Jenkins repository using the following wget command:
 What is wget? Wget is a command line utility for downloading files from the web.
With Wget, you can download files using HTTP, HTTPS, and FTP protocols.
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo
apt-key add

When the key is added, the system will return OK. Next, we'll append the Debian package
repository address to the server's

echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee


/etc/apt/sources.list.d/jenkins.list

Jenkins installation begins:

Once the Jenkins repository is enabled, update the apt package list and install the latest version of
Jenkins by typing:

sudo apt update

sudo apt install jenkins


DEVOPS LAB MANUAL

Jenkins service will automatically start after the installation process is complete. You can verify it by
printing the service status:

systemctl status jenkins

Output:

Jul 29 09:27:32 ip-172-31-18-58 systemd[1]: Starting LSB: Start Jenkins at boot time...

Jul 29 09:27:32 ip-172-31-18-58 jenkins[9488]: Correct java version found

Jul 29 09:27:32 ip-172-31-18-58 jenkins[9488]: * Starting Jenkins Automation Server jenkins

Jul 29 09:27:32 ip-172-31-18-58 su[9534]: Successful su for jenkins by root

Jul 29 09:27:32 ip-172-31-18-58 su[9534]: + ??? root:jenkins

Jul 29 09:27:32 ip-172-31-18-58 su[9534]: pam_unix(su:session): session opened for user jenkins by
(uid=0)

Jul 29 09:27:32 ip-172-31-18-58 su[9534]: pam_unix(su:session): session closed for user jenkins

Jul 29 09:27:33 ip-172-31-18-58 jenkins[9488]: ...done.

Jul 29 09:27:33 ip-172-31-18-58 systemd[1]: Started LSB: Start Jenkins at boot time.

-----

Since systemctl doesn't display output, we'll use its status command to verify that it started
successfully:
sudo systemctl status Jenkins

Output:-

ubuntu@ip-172-31-35-128:~$ sudo systemctl status jenkins

● jenkins.service - LSB: Start Jenkins at boot time

Loaded: loaded (/etc/init.d/jenkins; generated)

Active: active (exited) since Fri 2019-08-16 14:35:18 UTC; 8min ago

Docs: man:systemd-sysv-generator(8)

Tasks: 0 (limit: 1152)

CGroup: /system.slice/jenkins.service

Aug 16 14:35:17 ip-172-31-35-128 systemd[1]: Starting LSB: Start Jenkins at boot time...

Aug 16 14:35:17 ip-172-31-35-128 jenkins[19914]: Correct java version found

Aug 16 14:35:17 ip-172-31-35-128 jenkins[19914]: * Starting Jenkins Automation Server jenkins


DEVOPS LAB MANUAL

Aug 16 14:35:17 ip-172-31-35-128 su[19960]: Successful su for jenkins by root

Aug 16 14:35:17 ip-172-31-35-128 su[19960]: + ??? root:jenkins

Aug 16 14:35:17 ip-172-31-35-128 su[19960]: pam_unix(su:session): session opened for user jenkins
by (uid=0)

Aug 16 14:35:17 ip-172-31-35-128 su[19960]: pam_unix(su:session): session closed for user jenkins

Aug 16 14:35:18 ip-172-31-35-128 jenkins[19914]: ...done.

Aug 16 14:35:18 ip-172-31-35-128 systemd[1]: Started LSB: Start Jenkins at boot time.

ubuntu@ip-172-31-35-128:~$

What does Jenkins package do after successful installation?

Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.

The 'jenkins' user is created to run this service.

Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting
Jenkins.

/etc/default/jenkins will capture configuration parameters for the launch like e.g JENKINS_HOME

By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.

Allowing 8080 port on Firewall By default, 8080 port is not allowed on firewall.

Click on “Description” on AWS instance (where you have created the instance).

Under Security Groups”launch-wizard-5”

Then click on “Inbound tab” Edit

Add a new rule with the “Custom TCP rule” and the range “8080”save

Try to access the public ip with :8080 port on the browser.


DEVOPS LAB MANUAL

Make sure you access the “initialAdminPassword “ file with root permission.

root@ip-172-31-35-128:~# sudo su

root@ip-172-31-35-128:~# cd /var/lib/jenkins/secrets/

root@ip-172-31-35-128:/var/lib/jenkins/secrets# nano initialAdminPassword

------------------------------------------------------------END--------------------------------------------------------------------

2.0 Hands on with GitHub & Git

2.1 Creating new free GitHub account online.

2.2 Creating new repository and commit the codes to newly created repository

2.3 Importing the codebase from different Github account to your Github account

2.4 Understanding different operations on Github

Steps to Install Git on Windows


DEVOPS LAB MANUAL

Download Git for windows from https://gitforwindows.org/

Double click on the Git installer. The installer gets save on the machine as per the Windows OS
configuration.

 Accept “GNU General Public License”

You may like to keep the installation to another folder, so here is the chance to do so. I just want to
keep it in the suggested default folder in my Program Files\Git

Make sure ,we select “Git Bash Here and Git GUI Here”.
DEVOPS LAB MANUAL

This is the option to store the shortcut of the Git under the Program Menu.

This is asking your choice that whether you like to Git from the Windows Command Prompt or you
like to use some other program like Git Bash. As of now just select the Windows Cmd for simplicity
of the tutorial, later we will cover Git Bash and other as well.
DEVOPS LAB MANUAL

If you have PuTTY/TortoiseSVN installed, you may see this screen, otherwise just ignore
this. Regardless, use OpenSSL to make things easy.

If you have PuTTY/TortoiseSVN installed, you may see this screen, otherwise just ignore
this. Regardless, use OpenSSL to make things easy.
DEVOPS LAB MANUAL

Again, just go with default selection and move forward.

Just go with default selections, as we will cover the details in later advance chapter.

Now, its all done. This will just take few minutes to complete the installation as per your machine
speed.
DEVOPS LAB MANUAL

Let’s just verify if the installation went well for Git. Go to cmd and type git and press enter. you
should get the following output on the screen.

git –version

git –help

------------------------------------------------------------END--------------------------------------------------------------------
DEVOPS LAB MANUAL

3.0 Using Chef Solo on Linux for AWS

3.1 Configure a Chef node in AWS using Chef Solo

3.2 Write Chef cookbooks and recipes

3.3 Use Chef attributes and templates to generalize your cookbooks

3.4 Create Chef roles to define Chef node functions

Chef solo installation

Chef-Solo is an open source tool that runs locally and allows to provision guest machines using Chef

cookbooks without the complication of any Chef client and server configuration. It helps to execute

cookbooks on a self-created server.

Install Git – Since we are going to fetch the cookbooks from Git repo.

sudo apt install git

Install chef from opscode website

sudo apt install curl

sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash

Install Chef dk

wget https://packages.chef.io/files/stable/chefdk/3.2.30/ubuntu/18.04/chefdk_3.2.30-

1_amd64.deb

Use your distribution’s package manager to install ChefDK:

For ubuntu dpkg

dpkg -i chefdk_3.2.30-1_amd64.deb

Check the Chef version installed.

root@ip-172-31-41-229:~# chef --version

Chef Development Kit Version: 3.2.30

chef-client version: 14.4.56

delivery version: master (6862f27aba89109a9630f0b6c6798efec56b4efe)

berks version: 7.0.6


DEVOPS LAB MANUAL

kitchen version: 1.23.2

inspec version: 2.2.70

root@ip-172-31-41-229:~#

sudo mkdir chef_Repo

Change the directory cd chef_Repo

Create a ruby file with file extension .rb – since we are recipe on ruby.

nano hello.rb

file 'HelloChef' do

content 'Hello Ruby'

end

Save the hello.rb

chef-apply hello.rb

Once we run this chef-apply command.

We should have a 'HelloChef' file created with content 'Hello Ruby'

----------------------------------------------------------------END----------------------------------------------------------------

4.0 Software provisioning and configuration management with Ansible

4.1 Introduction to Ansible hands-on

4.2 YAML and Hands-on Exercises

4.3 Build Ansible Inventory Files and modules

4.4 Automate provisioning and web server deployment

Ansible installation
Prerequisites

Two or more Ubuntu 18.04 servers. One of these will be used as our Ansible server
DEVOPS LAB MANUAL

While another server will be used as your Ansible hosts.

Each should have a non-root user with sudo privileges, and a basic firewall configured.

SSH keys generated for the non-root user on your Ansible server.

Ensure to create same username on both control server and node server.

Ex:- ansiadmin

adduser ansiadmin

# set ansiadmin to never expire

passwd -x -1 <username>

Step 1 — Installing Ansible

To get the latest version of Ansible for Ubuntu, you can add the project's PPA (personal
package archive) to your system, you should first ensure that you have the software-properties-
common package installed.

[software-properties-common]- It allows you to easily manage your distribution and


independent software vendor software sources.

[apt-get update] - Downloads the package lists from the repositories and "updates" them to
get information on the newest versions of packages and their dependencies. It will do this for all
repositories and PPAs.

 sudo apt update


 sudo apt install software-properties-common

Then add the Ansible PPA by typing the following command:

 sudo apt-add-repository ppa:ansible/ansible

Next, refresh your system's package index once again so that it is aware of the packages available in
the PPA:

 sudo apt update

Begin with ansible installation

 sudo apt install ansible

Step 2 — Configuring SSH Access to the Ansible Hosts

Ansible primarily communicates with client computers through SSH.

On our Ansible server, use the cat command to print the contents of your non-root user’s
SSH public key file to the terminal’s output: <Copy the public key to node to estimate the
connection with password>

cat ~/.ssh/id_rsa.pub
DEVOPS LAB MANUAL

If we get output with “ cat: /home/ubuntu/.ssh/id_rsa.pub: No such file or directory”

Following below steps to create a SSH key

ssh-keygen

Since Ansible uses Python interpreter located at /usr/bin/python to run its modules, you’ll need to
install Python on the host for Ansible to communicate with it.

Python installation

sudo apt update

sudo apt install python

To do

Server on root user

adduser ansiadmin

passwd -x -1

Node on root user

adduser ansiadmin
DEVOPS LAB MANUAL

passwd -x -1

Setup SSH key on server under <ansible user>

su ansiadmin

ssh-keygen

cat ~/.ssh/id_rsa.pub

Above public key ,we have copy into authorized_keys file.

Setup SSH key on Node under <ansible user>

su ansiadmin

Let’s install small package from control server to node system via ansible.

Inventory file refers to following path by default

cd /etc/ansible/

nano hosts

Following script for changing the ownership to file,<On root user>

Chown -R asadmin:asadmin /etc/ansible/

File looks like below,


DEVOPS LAB MANUAL

Ansible host file:

All the host entries either hostname or ip address will update in this host, with following
format.

[group name]

Host1

Host2

Command Ex:

ansible [groupname] -m ping

ansible [groupname] -m copy -a “src = <Path> dest= <Path>” -s


DEVOPS LAB MANUAL

It contains the following sections - Ansible Playbooks

Every playbook starts with 3 hyphens ‘—‘

Host or target section – Defines the target machines on which the playbook should run. This is based
on the Ansible inventory file.

Variable section – This is optional and can declare all the variables needed in the playbook.

Tasks section – This section lists out all the tasks that should be executed on the target machine. It
specifies the use of Modules. Every task has a name which is a small description of what the task will
do and will be listed while the playbook is run.

Example 1: Create the file on the target machines or servers as mentioned in the inventory file and
the webserver's group, save the below code with .yml extension and run the playbook.

- hosts: webservers

become: true

tasks:

- name: Create a file

file: path=/home/ansible/nec.txt state=touch

we have used the file module to create the file.

Example 2: Create a directory with the mode as 775 and owner/group as Ansible.

---

- hosts: webservers

become: true

tasks:

- name: Create directory

file: path=/home/ansible/niranjan state=directory mode=775 owner=ansible group=ansible

ansible-doc -l | more

----------------------------------------------------------------END-----------------------------------------------------
DEVOPS LAB MANUAL

5.0 Linux Command Line Byte Session

5.1 Understand what the Linux command line

5.2
Directory Manipulations commands
5.3 Use common commands for working with files and directories

5.4
Installing Software in Linux CLI
5.5
Sending E-mails

Linux Command Line Byte Session

ls

The ls command - the list command - to show all the major directories filed under a given file system.

For example, the command:

ubuntu@ip-172-31-35-128:~$ ls
ubuntu@ip-172-31-35-128:~$ mkdir Test
ubuntu@ip-172-31-35-128:~$ ls
Test
ubuntu@ip-172-31-35-128:~$

cd

The cd command - change directory - will allow the user to change between file directories.

mv

The mv command - move - allows a user to move a file to another folder or directory. Just like dragging a
file located on a PC desktop to a folder stored within the "Documents" folder, the mv command functions in
the same manner.

man

The man command - the manual command - is used to show the manual of the inputted command.

Man mkdir
DEVOPS LAB MANUAL

mkdir

The mkdir - make directory - command allows the user to make a new directory. Just like making a new
directory within a PC or Mac desktop environment, the mkdir command makes new directories in a Linux
environment.

mkdir testdirectory

rmdir

The rmdir - remove directory - command allows the user to remove an existing command using the Linux
CLI.

rmdir testdirectory

rm
The rm command - remove - like the rmdir command is meant to remove files from your Linux OS.
Whereas the rmdir command will remove directories and files held within, the rm command will delete
created files. An example of the rm command:

rm testfile.txt

sudo apt update

apt-get update downloads the package lists from the repositories and "updates" them to get information on
the newest versions of packages and their dependencies.

sudo apt install

apt-get install command is usually to be prepended by sudo, which essentially means that you need to run
the command with elevated privileges as root or superuser.

Ex: sudo apt install openjdk-8-jdk

systemctl command

Linux systemctl command. The systemctl command is a new tool to control thesystemd system and
service.

----------------------------------------------------------------END-----------------------------------------------------
DEVOPS LAB MANUAL

6.0 Create AWS Resources with Terraform

6.1 Install Terraform on Linux

6.2 Configure Terraform providers

6.3 Create AWS resources with Terraform

Terraform is distributed as a tarball on Github. Check the latest release on Terraform


releases page before downloading below.

As of the writing of this article, the latest release is v0.12.9. Download it like below:

Ensure wget and unzip are installed

# Ubuntu
sudo apt-get install wget unzip

# CentOS
sudo yum install wget unzip

Then download the terraform archive.

export VER="0.12.9"

wget
https://releases.hashicorp.com/terraform/${VER}/terraform
_${VER}_linux_amd64.zip

Once downloaded, extract the archive:

$ unzip terraform_${VER}_linux_amd64.zip

Archive: terraform_0.12.9_linux_amd64.zip

inflating: terraform

This will create a terraform binary file on your working directory. Move this file to the
directory/usr/local/bin.

sudo mv terraform /usr/local/bin/


DEVOPS LAB MANUAL

This will make the tool accessible to all user accounts.

$ which terraform
/usr/local/bin/terraform

Confirm the version installed

$ terraform -v

Terraform v0.12.9

Now that terraform is installed, let’s create a test project.

$ mkdir projects

$ cd projects

Create Terraform main configuration file.

touch main.tf

I’m doing a Test with AWS Provider but you can use other Providers for your
projects. My terraform configuration provider section is as below.

$ vim main.tf

# Provider

provider "aws" {

access_key = ""

secret_key = ""

region = "us-west-1"

}
DEVOPS LAB MANUAL

Paste your AWS Access Key and Secret Key


inside the access_key and secret_keysections respectively. You can also
configure your AWS access credentials with AWS CLI tool.

When done, run terraform init to initialize a Terraform working directory.

$ terraform init

$ terraform plan

Finally build your Infrastructure with Terraform using terraform apply.

$ terraform apply

----------------------------------------------------------------END-----------------------------------------------------

7.0 Deploy Wordpress using CloudFormation

7.1 Create your first cloud infrastructure using Amazon CloudFormation

7.2 Use CloudFormation to launch an EC2 (Linux) instance

7.3 Create the Stack and choose template for launching instance

7.4 Perform Wordpress full installation in the instance

Deploy Wordpress using CloudFormation

Procedure

STEP 1: login to AWS account

STEP 2 :click on services

STEP 3:Click on cloudformation


DEVOPS LAB MANUAL

STEP 4:Select designer

STEP 5:In resource type select S3 and drag and drop on designer

STEP 6: Go to properties & select Json and click on create stack

STEP 7:Use sampe template – Select IAMP stack

STEP 8: Give next

STEP 9: Give stack name, database name

STEP 10: Go to EC2 instance and connect using mobaxterm

STEP 11: Type the following command in mobaxtrem

mysql –h localhost –P 3306 –u root -p

STEP12 : create database ra;

Use ra;

STEP 13: Copy the public IP address Of the instance

Paste it in new tab

The new PHP test page will open

----------------------------------------------------------------END-----------------------------------------------------

8.0 Build your first OpsWorks stack

8.1 Build the infrastructure and automate code deployment for a PHP application with
OpsWorks

8.2 Registering the Instance (Linux) in OpsWorks

8.3 Deploying Apps- Deploy test PHP application

8.4 Execute other commands – Undeploy, Rollback, Start Web Server, Stop Web Server,
Restart Web Server

Build your first OpsWorks stack


DEVOPS LAB MANUAL

OPSWORK :

AWS OPSWORK is a configuration management service that helps you configure & operate
applications in a cloud enterprise by using puppet & chef .AWS OPSWORK stack & AWS
OPSWORK for chef automate lets you use chef cookbooks & solutions for configuration management
while OPSWORK for puppet enterprise lets you configure a puppet enterprise master server in AWS
puppet offers a set of tools for enforcing the desired state of your infrastructure & automating on
demand tasks.

STEP 1 :Open AWS management console

STEP 2: In EC2 search for OPSWORK

STEP 3 : Click on OPSWORK

STEP 4 : In the dashboard click on stack

STEP 5 : click on add stack

STEP 6 : click on simple stack

STEP 7 : click on create stack

STEP 8: Select the explore sample stack

STEP 9: Select to start instance

STEP 10 : click on + symbol for instance creation

STEP 11: Select size as t2.micro

STEP 12 : go to actions

STEP 13: click on start

STEP 14:It will take some time to start

STEP 15: It will show as online

STEP 16: In dashboard select deployment

STEP 17:Click on deploy an app

STEP 18 : It shows comment box

In that enter some text line

Type ->Sample app for today

STEP 19: click on deploy

STEP 20: It shows status as successful


DEVOPS LAB MANUAL

STEP 21:click on network and security in same page

STEP 22: Copy the public IP address

STEP 23: Paste it in new tab

STEP 24: It opens a web page

STEP 25:It shows OPSWORK content on that page.

----------------------------------------------------------------END-----------------------------------------------------

9.0 Develop and Deploy an Application with AWS CodeStar

9.1 Create AWS CodeStar projects

9.2 Monitor project activity

9.3 Develop and deploy code using AWS CodeStar

9.4 Manage teams inside of AWS CodeStar projects

Develop and Deploy an Application with AWS CodeStar

Step 1: Go to services for Codestar click on it

Step 2: It opens the prompt box, click on start a project

Step 3: It shows to create a service role. Click yes ,create role

Step 4: Select the template.

Step 5: It shows a dashboard in that select, application category as web application , programming
language as Node JS , AWS service as Amazon EC2

STEP 6 : In the main page choose a project template as Node JS

STEP 7 : Create a project on AWS codestar

1.) Project name

2.) Project ID
DEVOPS LAB MANUAL

3.) Select responsibility as AWS code commit.

Step 8 : Click on next

STEP 9: It opens a tool page , click on create a project

Step 10 : It shows a page called Amazon EC2 key pair Select key pair or create a new key pair

By clicking on EC2 management console.

STEP 11: Click on acknowledge to access private key

STEP 12 : Click on create project

STEP 13 : Click on skip

STEP 14: It shows project created successfully

Step 15 : Scroll down

In application end points

Click on below link

Ec2-33-222-45-195.us-west-2 compute amazonaws.com

STEP 16 : It shows application output “Congratulations”

----------------------------------------------------------------END-----------------------------------------------------

10.0 Use AWS Fargate for Serverless Deployment of Container Applications

10.1 Use application source files to create Docker container images and place them in Amazon
ECR
10.2 Create an Amazon ECS cluster

10.3 Use the Amazon ECR images to create ECS task definitions and services

10.4 Implement the services in ECS by using AWS Fargate enjoying the advantages of serverless

10.5 Register ECS tasks with an Application Load Balancer (ALB) target group
DEVOPS LAB MANUAL

Create Docker container images and place them in Amazon ECR


1. Install Docker desktop for Windows and AWS CLI
Verify and confirm that each version has been installed properly (see below):
 docker (dash dash)version
 aws (dash dash)version

2. Authentication to AWS
Open Power Shell interface with administration privileges and enter the following commands:
 aws configure
 Access key: ****
 Secret key: ****

The region name and output format information are not mandatory.
The data above can be found from the IAM service on AWS console management.

3. Log in to AWS elastic container registry


Use the get-login command to log in to AWS elastic container registry and save it to a text file (see
below):
 aws ecr get-login (dash dash)region eu-west-3 > text.txt

4. Authenticate Docker to AWS elastic container registry


Replace the aws account id provided into the text file saved previously and specify the password:
 docker login -u AWS https://aws_account_id.dkr.ecr.eu-west-3.amazonaws.com
 Password: *****

5. Download the CentOS image


Use the pull command to download the CentOs image:
 docker pull centos:6.6

6. Create a repository
 aws ecr create-repository (dash dash)repository-name centos

The repository has been created successfully into Amazon Elastic Container Registry (see below):
DEVOPS LAB MANUAL

Before proceeding to the next step, make sure that the following requirements are met:
 Docker version must be greater or equal to 1.7
 The repository is created and that the user has sufficient privileges to access it
 The Docker authentication is successful

7. List the images stored into Docker and tag them


 docker images

 docker tag centos:6.6 aws_account_id.dkr.ecr.eu-west-3.amazonaws.com/centos:6.6 (replace


the aws_account_id by your account id)
Verify that the image has been tagged:
 docker images

8. Push the CentOS image into Amazon ECR


Use the push command to move the centos image into Amazon elastic container registry:
 docker push aws_account_id.dkr.ecr.eu-west-3.amazonaws.com/centos:6.6 (replace the
aws_account_id by your account id)
From the Amazon management console, verify that the image has been pushed properly into
Amazon elastic container registry (see below):

If you are in a test environment, to avoid extra costs, make sure to delete the image and the
repository from Amazon elastic container registry.
Use the following command to delete the image:
 aws ecr batch-delete-image (dash dash)repository-name centos (dash dash)image-ids
imageTag=6.6
Use the following command to delete the repository:
 aws ecr delete-repository (dash dash)repository-name centos

To create a cluster
1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.
2. From the navigation bar, select the Region to use.
3. In the navigation pane, choose Clusters.
4. On the Clusters page, choose Create Cluster.
DEVOPS LAB MANUAL

5. For Select cluster compatibility, choose one of the following options and then choose Next Step:
 Networking only– With this option, you can launch a cluster of tasks using the Fargate launch type.
The Fargate launch type allows you to run your containerized applications without the need to
provision and manage the backend infrastructure. When you register your task definition, Fargate
launches the container for you.
 EC2 Linux + Networking– With this option you can launch a cluster of tasks using the EC2 launch
type and Linux containers. The EC2 launch type allows you to run your containerized applications on
a cluster of Amazon EC2 instances that you manage.
 EC2 Windows + Networking – With this option you can launch a cluster of tasks using the EC2 launch
type using Windows containers. The EC2 launch type allows you to run your containerized
applications on a cluster of Amazon EC2 instances that you manage. For more information,
see Windows Containers.

If you chose the Networking only cluster template, continue with the following steps.

Using the Networking only cluster template

1. On the Configure cluster page, enter a Cluster name. Up to 255 letters (uppercase and lowercase),
numbers, hyphens, and underscores are allowed.
2. In the Networking section, configure the VPC for your cluster. You can keep the default settings, or
you can modify these settings with the following steps.
a. (Optional) If you choose to create a new VPC, for CIDR Block, select a CIDR block for your VPC. For
more information, see Your VPC and Subnets in the Amazon VPC User Guide.
b. For Subnets, select the subnets to use for your VPC. You can keep the default settings, or you can
modify them to meet your needs.
3. In the Tags section, specify the key and value for each tag to associate with the cluster. For more
information, see Tagging Your Amazon ECS Resources.
4. In the CloudWatch Container Insights section, choose whether to enable Container Insights for the
cluster. For more information, see Amazon ECS CloudWatch Container Insights.
5. Choose Create.

----------------------------------------------------------------END-----------------------------------------------------

You might also like