Friday, January 28, 2022

Server Migration to Azure

Evaluating and Performing Server Migration to Azure

On Premises-Servers - VM, Windows & Linux


 

1. Azure Subscription

2  Which Region do we want to migrate? - South india, north india, us east, us central, us west, we need to understand in which region we need to migrate

  • Where are my users?
  • Are there any Govt. regulations requirements ? - some restriction like you cant put that application outside of India, or in these data centers like   china data-center etc, or only allow like particular locations.   
  • cost effective region ? - all region are not in same price, for any service like vms
  • Network latency to the existing data-center / Users access location?

why do i need to migrate to Azure ?
  •     My existing physical servers are 7 to 8 years old,
  •     No Support from Hardware Vendor
  •     All my servers are running Windows Server 2008 R2 - EOL
  •     Free upgrade option to Windows server 2019 - you dont need to pay for lic.
  •     Business decision - Will reduce the Hardware infrastructure in the On-prem,
  •     slowly migrate the servers/application to the cloud

    
What options available to migrate the applications/servers to Azure Cloud

1. option -

    1. create a new VM in Azure.
    2. deploy the application
    3. Take the backup of the application on the prem
    4. Restore the backup on the Azure VM
    5. Verify the application
    6. Change the DNS Records

    advantages -
  • fresh install / clean installation
  • easy to migrate
  • amount of data transfer from on-prem to Azure is very less - because you dont migrating the operating system etc, you just migrating the data transfer
    
    disadvantages:-
  • lot of patches being installed
  • lot of operating system setting being done
  • if window server lot of registry modification being done
  • lot of hardening being done inside the vm machine
  • lot of application patches being deployed
  • lot of application bugs are being fixed
    when everything running fine in your on prem but when you do fresh install on
    cloud the problem is here its not the same env 
  • Patches are missing 
  • application patches are missing
  • O/S configuration are missing
  • application configuration are missing
        
And because of this user experience is very bad, might be out level test success, regarding application running fine or not, but once user start using the application many functionality issues comes.

because user experience and bring the same state of the application on the cloud is bigger challenge, - its also depend on your user access count also
we can do the test or our current env is test env then its okay
and in case some server support going to expire like 2008 R2 or we deploying new version of the application.

    Windows server 2008 R2 - O/S -- Announced eol / eos
    Windows server 2019 - Test env

    Window Server 2016 O/s
    On the target -- Deploy newer version of the application
        V2.0 -- V3.0 (Wind 2019)

2. As its is - Migration

    Entire state of the server/ VM / Application is Migrated to the target (cloud)
        
    On-Prem:
        hardware sizes might be over sized
        VM is running at low performance
        
Proper Network is configured
What are the dependencies of the VM/Application
Proper Network connectivity b/w on-prem and Azure
    site2site VPN
    Express Route

 

Migration Phases




 

When planning for migration to Azure, consider the following phases:

Discover: gain better visibility of on-premises workloads and asses the optimal resource level to run them in Microsoft Azure.
  • Azure Migrate is the primary tool for this, and includes:
  • Automated server, app, and database discovery.
  • Intelligent workload right-sizing and costing for maximum ROI.
  • Workload configuration analyses and recommendations.

Migrate: move selected workloads to Azure.
  • Azure Site Recovery is the primary tool for this and includes:
  • Lifting and shifting of servers, apps, databases, and data.
  • Containerization of existing applications and infrastructure.
  • Modernization options for apps and databases.

Optimize: fine tune your Azure-based workloads and maximize your ROI.
there are many Microsoft partners to help you with backups, monitoring, security assessments, and cost managment.
 

Wednesday, January 12, 2022

AWS ECS/ECR deployment



 AWS ECS


1. create EC2 instance for docker local image creation and install docker on that.

2. create user and folders on it, assign S3FULL access and ECS role to EC2 machine

#IAM policy AmazonEC2ContainerRegistryFullAccess

#!/bin/bash

#useradd xxxx-user
#su - xxxx-user
mkdir Preventivecontrols
cd Preventivecontrols/
mkdir pc-tomcat-dinesh Preventive-control-UAT Preventive-control-DEV Preventive-control-PROD
cd pc-tomcat-dinesh/
aws s3 cp s3://man-xxxxxxxxxxxxx-user/arunk/war/local_docker_deploy_web.sh .
aws s3 cp s3://man-xxxxxxxxxxxxx-user/arunk/war/Dockerfile .

#####################################

Deployment to Dev(local)

---------------------------------------------------

Dockerfile

FROM tomcat:8.0-alpine
LABEL maintainer="deepak@softwareyoga.com"

ADD PreventiveControl.war /usr/local/tomcat/webapps/

EXPOSE 8080
CMD ["catalina.sh", "run"]
 

......................................................................................

 

 sh local_docker_deploy_web.sh v1

###########Assigning standard docker variables#########
DATE_TIME=`date "+%m-%d-%y%"`
IMAGE_NAME="preventivecontrol"
PORT="9095"
CONTAINER_NAME="preventive-control"

########## Remove old container##########
$1

docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME

######## Rename old WAR file #########

#mv /home/aexp-user/Preventivecontrols/Preventive-control-LOCAL/PreventiveControl.war PreventiveControl$DATE_TIME.war

######## COPY AtulWeb WAR FILE ##########

aws s3 cp s3://man-420244912485-user/arunk/war/sample.war PreventiveControl.war

###### Build the image with latest WAR FILE #######

docker build -t $IMAGE_NAME:$1 .

#######Run the container from the build########

docker run -d -p $PORT:8080 --name $CONTAINER_NAME $IMAGE_NAME:$1

-------------------------------------------

http://3.133.7.49:9095/PreventiveControl/



#Create repository on ECR -- **
aws ecr create-repository --repository-name preventive-control-uat --region us-east-2

#Next tagging a repository
docker tag preventivecontrol:v1 776499148221.dkr.ecr.us-east-2.amazonaws.com/preventive-control-uat

#login 1st login with aws configure from EC2 machine
aws ecr get-login-password | docker login --username AWS --password-stdin 776499148221.dkr.ecr.us-east-2.amazonaws.com/preventive-control-uat

#to push docker image to ecr
docker push 776499148221.dkr.ecr.us-east-2.amazonaws.com/preventive-control-uat:latest

#To delete
#aws ecr delete-repository --repository-name preventive-control-uat --region region --force

Deployment to UAT(ECS)

 --------------------------------------------------------------------------------

Dockerfile

Dockerfile

FROM tomcat:8.0-alpine
LABEL maintainer="deepak@softwareyoga.com"

ADD PreventiveControl.war /usr/local/tomcat/webapps/

EXPOSE 8080
CMD ["catalina.sh", "run"]

---------------------------------------------------------------------------------------------

sh docal_docker_deploy_web v1 ---UAT file
#/bin/bash
DATE_TIME=`date "+%m-%d-%y"`
IMAGE_NAME="776499148221.dkr.ecr.us-east-2.amazonaws.com/preventive-control-uat"
mv /home/aexp-user/Preventivecontrols/Preventive-control-UAT/PreventiveControl.war PreventiveControl.war.$DATE_TIME
cp /home/aexp-user/Preventivecontrols/pc-tomcat-dinesh/PreventiveControl.war /home/aexp-user/Preventivecontrols/Preventive-control-UAT/
docker build -t $IMAGE_NAME:$1 .
docker push $IMAGE_NAME:$1

-------------------------------------------------------------------------------------------------

After pushing image to ECR, Now go to Task definition

Create Task Defination




and create-Done

Now go to Cluster

create cluster - cloudprint-ec2


 


go to Run new Task



If get any error you can check as below:



If container running succesfully can see below:




Create Service: 

(Before create service you should have load-Balancer)
but in case if something happen and task die, there is no machnisiam to comback automatically, if you say high availablity, so in order to achive this We go and create a service