Saturday, January 1, 2022

How to install Ubuntu 20.04 LTS Guest OS on Hyper-V

 

Pre-Requisites:

1.     1.  Verify the Machine is Enabled with Virtualization or not

2.  If Virtualization is in “Disabled” state, we must enable in BIOS Setup

Steps to Enable Hyper-V

1.  Search for “Turn Windows features on or off” 

2. Select Hyper-V and select both the Hyper-V Management Tools and Hyper-V Platform options

        
3. 3. Type “Hyper-V”  from Windows Search and select or double click on Hyper-V

4.4.  Follow the (self-explanatory) instructions from the below images 




Once OS installation completed, we need to install the OpenSSH Server to access from outside servers.

OpenSSH is a connectivity tool for remote login that uses the SSH protocol.

$ sudo apt-get update

$ sudo apt-get install -y openssh-server

How to push Docker images to AWS Elastic Container Registry (ECR)

 As an initial step to loading of docker images in Amazon ECR, Host machine installed with Docker and AWS CLI or AWSCLIV2

Docker on Ubuntu: https://devops-learner.blogspot.com/2019/10/how-to-install-and-setup-docker-in.html

Docker on AWS EC2: https://devops-learner.blogspot.com/2021/11/how-to-install-docker-on-amazon-ec2.html


Step 1: Let`s create dockerfile with a customized Apache httpd server 



Step 2: Type the following command to build the Docker image using dockerfile

 $ docker build -t apache-server -f httpd-Dockerfile .



Step 3: It will create a docker image, and you can check it by typing:

 $ docker images



Step 4: Just for testing purposes, let's run a docker container using this docker image to check if everything works fine at the local host! We will run this container at port 9091 of localhost. Type the following command for that :

 $ docker run -it --name apache-server -p 9091:80 httpd:latest








Now, since our docker image named “httpd” is been already created, it's time to move that image to AMAZON ECR!

 Step 5: Log in to your amazon aws console and search for an ECR service to get started:








Step 6: Now, our repository named “apache-server” is been created to save all our docker images! ON the upper right corner, you can see the “View push commands” named tab. You need to click on that and you will see something like this:


Just to cross-check the created repository have any images 


Step 7: Now go to your local OS( in my case it's Ubuntu 20.04 LTS ) where your docker image is saved and follow the above instructions! But before that you need to type the following two commands to configure your AWS account first :

AWS CLI Installation steps from the below links

AWS CLIV2 on Windows: https://devops-learner.blogspot.com/2021/11/how-to-install-aws-cli-in-windows-10-64.html

AWS CLIV2 on Linux: https://devops-learner.blogspot.com/2022/01/how-to-install-aws-cli2-on-linux-ubuntu.html

Note: Login as the root user

 Step 8: Once you type aws configure, it will ask the whole set of information to configure your account, like "access key", "secret access key", "region name" etc.Provide all the details and make sure your AWS user has permission to access AMAZON ECR service.

$ aws configure 


Note: In the case of Ubuntu 20 LTS ".docker" directory is not created by default, you need to create the directory manually using "mkdir .docker" and create a file called "vi config.json" inside the .docker directory.
$ mkdir .docker

$ vi config.json

Step 9: Once the ".docker" and "config.json" were created then update the necessary AWS ECR login credentials in the config.json file.











 Step 10:  once you get "Login succeeded", you are good to send your images to AWS ECR. Now you need to tag the image before you push it to the repo. Since our image is already created by <name>:<tag> i.e. apache-server:latest, let us tag this image, but here is the catch


docker tag <local_image>:<local_image_tag> <AWS_ECR_repository_url>:<image_Tag_you_wanna_proivde_in_ECR>

Once it is tagged successfully, we can check by using the "docker images" command to verify the tagged image



Step 11: Time to push the newly tagged image to the ECR repository and later Login to aws console and check ECR service if our image is pushed successfully!

$ docker push <AWS_12_DIGIT_USER_ID>.dkr.ecr.us-west-2.amazonaws.com/apache-server:latest

Before Image pushing to Repository :

After Image Pushed to AWS ECR Repository:


Hurray !!! We have pushed our custom image successfully to AWS ECR Repository ...



How to install AWS CLI2 on Linux (Ubuntu 20.04 LTS) Environment

AWS CLIV2  Installation instructions :

 1. Use the curl command to download the "awscliv2.zip" 

  $ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

  


  Note: if curl not available in your OS : sudo apt-get install curl -y 




 2. Unzip the installer

  $ unzip awscliv2.zip



 3. Run the install program. The installation command uses a file named install in the newly unzipped aws directory.by default files are all installed to /usr/local/aws-cli, and symbolic link is created in /usr/local/bin 

  $ sudo ./aws/install or ./aws/install -i 

  




  Optional: export PATH=/usr/local/bin/aws:$PATH

 

 4. Use the which command to find your symlink and Use the ls command to find the directory that your symlink points to

  $ which aws



  $ ls -l /usr/local/bin/aws



 5. Confirm the installation

  $ aws --version

How to install and setup Kubernetes cluster using kOps in AWS environment

  Kops: Kops is also known as Kubernetes Operations, it is an open-source project which helps you to create, upgrade, destroy, and maintain ...