Thursday, August 12, 2021

Kubernetes Integration with Python-CGI

 What is Kubernetes?

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

The name Kubernetes originates from Greek, meaning helmsman or pilot. K8s as an abbreviation results from counting the eight letters between the "K" and the "s". Google open-sourced the Kubernetes project in 2014. Kubernetes combines over 15 years of Goggle's experience running production workloads at scale with best-of-breed ideas and practices from the community.

What is Python?

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python's simple, easy-to-learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse.


What is CGI?



The common gateway interface (CGI) is a standard way for a Web server to pass a Web user’s request to an application program and to receive data back to forward to the user or in laymen terms it allows to use a web page such as HTML in front-end and programming language like python, java in the back-end part.


What is Python CGI?

Python CGI stands for Common Gateway Interface. An HTTP server invokes a Python CGI script so it can process user input that a user may submit through an HTML <FORM> or <ISINDEX> element. Such a script usually lives in the server's special CGI-bin directory. Python CGI module handles situations and helps debug scripts.


How to run a CGI program in Python?

Name your script with a .cgi file extension ( example.cgi ).

Configure Apache to recognize and allow the .py file extension as a CGI script.

<< Provide Your own YAML file. Get access to all commands.


  • $kubectl get nodes
  • $kubectl get deployments
  • $kubectl get pods
  • $kubectl get ns

<< Commands in Web UI



Codes of CGI files




Thank you for your valuable time reading my article...

Use Case of JavaScript

 Task 7.2 :

>>Write a blog explaining the ‘use case’ of ‘JavaScript’ in any of your favorite industries.


According to the reports, There were meaningful differences across industries in how and why people use JavaScript.


  • tech: 45%
  • finance: 7%
  • advertising and marketing: 5%
  • education: 5%
  • entertainment: 5%
  • business support and logistics: 4%
  • healthcare: 4%
  • retail: 3%
  • government: 2%
  • manufacturing: 2%
JavaScript developers look to React Native framework for this type of development.
As an open-source framework, React Native can be used for building cross-platform native apps. When used in combination with JavaScript, React Native applications are indistinguishable from apps built using other languages such as Swift, Java, and Objective-C.

What is JavaScript used for?



1. Web Applications

2. Web Development

3. Mobile Applications

4. Game

5. Presentations

6. Server Applications

7. Web Servers



</> LinkedIn :



LinkedIn relies on NodeJS for its mobile site. A few years back, LinkedIn used Rails for its mobile site. As with other large Rails applications, it was slow, monolithic, and it scaled poorly.

LinkedIn switched over to NodeJS to solve its scaling problems. Node’s asynchronous capabilities allowed the LinkedIn mobile site to perform more quickly than before while using fewer resources. Node also made data sharing and building APIs easier for LinkedIn developers.
After switching to node.js the Linkedin development team realized the advantages.

  1. Much better performance and lower memory overhead than other tested options, running up to 20x faster in some scenarios
  1. Programmers could leverage their JavaScript skills.
  1. Frontend and backend mobile teams could be combined into a single unit.
  1. Servers were cut to 3 from 30. Enough headroom remains to handle 10x current levels of resource utilization.
  1. The development could focus more on application development than firefighting.
JavaScript is Everywhere!

Wednesday, August 11, 2021

Python CGI with Docker (Task 7)

 In this project, I have integrated python with Docker !!

Python is one of the most popular languages nowadays and Docker is used for containerization.

What is python CGI?

A CGI script is invoked by an HTTP server, usually to process user input submitted through an HTML <FORM> or <ISINDEX> element.

Most often, CGI scripts live in the server’s special cgi-bin directory. The HTTP server places all sorts of information about the request (such as the client’s hostname, the requested URL, the query string, and lots of other goodies) in the script’s shell environment, executes the script, and sends the script’s output back to the client.

For now info visit :

https://docs.python.org/3/library/cgi.html

Whats is docker?

Docker is a set of platform as a service (PaaS) products that uses OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and therefore use fewer resources than virtual machines.

Now starting with my project,

Step 1:For this firstly I installed docker engine on my red hat 8 using command

# yum install docker -ce --nobest

Step 2: Then I started docker services using

#systemctl start docker

Step 3: Then I made one directory for my project using #mkdir doc_project and in this directory, I made my one file try.py which will have my code related to python CGI which is made using html, CSS, and python 3.

Step 4: In the same directory I will make one more file named Dockerfile which is used to make my own docker image and the configuration inside this file will be like shown in the figure below :



In this we have installed one apache server and python 3 . Then copied my try.py file into the root directory of apache server for cgi related fields root directory is /var/www/cgi-bin/ and for other purposes root directory of apache will be /var/www/html/.

So after I copied this file I have given executable permissions to this file using chmod command

And then as I normal os, we can start httpd services by using #systemctl start httpd but this will not work inside Docker so for starting httpd services i have used the last command.

Step 5:Then I will build my image using this Dockerfile and the command used for this will be

# docker build -t any_name

For e.g., :


Step 6: After making this image i will run this using command :

#docker run -i -d -t -p any_free_port:port_of_httpd --name any_name image_name

For e.g.,:


Step 7: Now our container is ready to work on. Now I will put my IP address of base os with the port I have given on any browser which is connected to same network

Thursday, June 24, 2021

Face Recognizer

Hello Fellas!!!

This post a task given by Mr. Vimal Daga sir during my summer internship program.  

Task Description ๐Ÿ“„


❄️ Create a program that perform below mentioned task upon recognizing a particular face.

๐Ÿ“Œ When it recognize your face then -
๐Ÿ‘‰ It send mail to your mail id by writing this is face of your_name.
๐Ÿ‘‰ Second it send whatsapp message to your friend, it can be anything.

๐Ÿ“Œ When it recognize second face, it can be your friend or family members face.
๐Ÿ‘‰ Create EC2 instance in the AWS using CLI.
๐Ÿ‘‰ Create 5GB EBS volume and attach it to the instance.


Create Face Dataset :

First we need to create face dataset. The data set will contain 100 image sample of a face.


Importing Face Dataset:

Now we need to import the face dataset that we have created.


Email Function:

Here we will define a function for sending email. The email will contain the information of the face owner that is recognized by our module. 


WhatsApp Message Function:

Now we will define a function that will automatically send a message to a number containing the details of the face owner.


AWS EC2 Launch Function:

Here we will create a function to create a EC2 instance and attach a 5GB EBS volume to it. 


Final Code:

Now we will create a program that will run the above created functions. This is the final step.


So finally, we have successfully created a python program that detects our face using opencv and automatically sends a WhatsApp message, an email and launches a AWS EC2 instance and attach a 5GB EBS volume to the instance.

Thank you for your valuable time reading this article. Do comment as your review matters a lot... Until then see you next time.

Friday, April 9, 2021

ARTH TASK - 10

๐Ÿ’ฅ Task Description →


๐Ÿ‘‰ Write an Ansible PlayBook that does the
following operations in the managed nodes:

  • Configure Docker
  • Start and enable Docker services
  • Pull the httpd server image from the Docker Hub
  • Run the docker container and expose it to the public
  • Copy the html code in /var/www/html directory and start the web server

    Firstly, I had installed Ansible on the top of Rhel 8 OS. Considering
that you know the installation of ansible I am directly jumping to the
use-case part that we have to perform.

    So, you can see the inventory file which is named as ip.txt, in this file
I had provided the target node IP so that we can connect to the
target node we have with us. Also, you can see the configuration file
of ansible in which I had given the path of the inventory file I had and
some other default values. The location of configuration file is inside
the /etc/ansible directory.

    You can take the help of ansible-doc file to see the syntax and
keywords used for the particular things you want to configure and
then you can apply those syntax accordingly in your yml file.

Refer to the figure given below :--


    On the left side, we have our Managed Node on which we have to
make a directory and then create a .yml format file in which we have
to write the ansible code. On the right side, we have the Target Node
on which we have to apply all the features that has been asked.
Command which is used to compile or run the yaml file is

#ansible-playbook -v <name of yml file>

Where, v is used for the verbose.

    Coming on to the task part we have to firstly install the Docker
software in our operating system.
To install the docker module we need to configure yum first, as you
can see in the code below that I had automated the yum
configuration under yum_repository.
    
    Then I had used the command module to install the docker-ce in
Target Node.

    In this part I had configured the docker services in the Target Node
with the help of ansible playbook.

    On the left side of the picture you can see the code that I had used in
docker.yml file. This code has been written with the help of ansible-
doc file.

    In this part I had installed the Python SDK of Docker and also I had
pulled a httpd image from the DockerHub.

    In this image as you can see I had created a workspace or the
directory named as wsp and then in next part I had created the
web.html file given the input of the content inside it.

    In this image as you can see I had setup the httpd webserver for docker container, exposed the ports and given the volumes. On the left side you side the compilation of yml file.


    Now in the Target Node by the inspect command you can see the IP
of the docker webserver IP

    Going on to the firefox just copy the webserver IP and then the
webserver file name.

    You will get the desired output or the content that you had given in
the web.html file.

Thank you learners for your precious time reading this post. Hope you like the integration of Ansible and Docker.

Tuesday, March 23, 2021

ARTH - Task 6

 Task Description

>> Create High Availability Architecture with AWS CLI 

>> The architecture includes -

- Web server configured on EC2 Instance

- Document Root(/var/www/html) made persistent by

mounting on EBS Block Device.

- Static objects used in code such as pictures stored in S3

- Setting up Content Delivery Network using CloudFront and

using the origin domain as S3 bucket.

- Finally place the Cloud Front URL on the webapp code for

security and low latency.

Step1: Download the Aws_cli

https://aws.amazon.com/cli/

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html


Step 2: Install the aws_cli and setting_up the
env_variable








SET THE ENV PATH FOR AWS_CLI






To download the packages inside the directory use “terraform init

Step 3: configuring the aws_cli


AFTER SUCCESSFULLY COMPLETE THE ABOVE PRACTICAL NOW CREATE A USER IN
AWS AND CONFIGURE THE AWS CLI USING “aws configure” and further passing the
secret key,access-key ,zone and format as(‘json’)













C:\Users\user>cd Desktop/cloud
C:\Users\user>aws ec2 create-key-pair --key-name mykey1111






C:\Users\user>aws ec2 create-security-group --group-name MySecurityGroup
--description "My security group" --vpc-id vpc-028b6e67c7a953d6d
{
"GroupId": "sg-0575c309c404208e6"
}




C:\Users\user>aws ec2 authorize-security-group-ingress --group-id
sg-0575c309c404208e6 --group-name MySecurityGroup --protocol tcp --port 22
--cidr 0.0.0.0/0




C:\Users\user\Desktop\cloud>aws ec2 run-instances --image-id
ami-0447a12f28fddb066 --instance-type t2.micro --count 1 --subnet-id
subnet-d7ead0bf --security-group-ids sg-08ede0983c0034902 --key-name
mykey1111
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-0447a12f28fddb066",
"InstanceId": "i-04631b57139072206",
"InstanceType": "t2.micro",
"KeyName": "mykey1111",
"LaunchTime": "2020-06-01T21:31:37+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "ap-south-1a",
"GroupName": "","Tenancy": "default"
},
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7",
"ProductCodes": [],
"PublicDnsName": "",
"State": {
"Code": 0,
"Name": "pending"
},
"StateTransitionReason": "",
"SubnetId": "subnet-d7ead0bf",
"VpcId": "vpc-15f8e57d",
"Architecture": "x86_64",
"BlockDeviceMappings": [],
"ClientToken": "49daca14-b0ef-4e35-ab24-536e5527d2ae",
"EbsOptimized": false,
"Hypervisor": "xen",
"NetworkInterfaces": [
{
"Attachment": {
"AttachTime": "2020-06-01T21:31:37+00:00",
"AttachmentId": "eni-attach-00bf4144bdf312034",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"Status": "attaching"
},
"Description": "",
"Groups": [
{
"GroupName": "launch-wizard-1",
"GroupId": "sg-08ede0983c0034902"
}
],
"Ipv6Addresses": [],
"MacAddress": "02:18:87:f7:6a:fc",
"NetworkInterfaceId": "eni-0009f73471ec18b1e",
"OwnerId": "410914255776",
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7","PrivateIpAddresses": [
{
"Primary": true,
"PrivateDnsName": "ip-172-31-40-7.ap-south-1.compute.internal",
"PrivateIpAddress": "172.31.40.7"
}
],
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-d7ead0bf",
"VpcId": "vpc-15f8e57d",
"InterfaceType": "interface"
}
],
"RootDeviceName": "/dev/xvda",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "launch-wizard-1",
"GroupId": "sg-08ede0983c0034902"
}
],
"SourceDestCheck": true,
"StateReason": {
"Code": "pending",
"Message": "pending"
},
"VirtualizationType": "hvm",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
},
"CapacityReservationSpecification": {
"CapacityReservationPreference": "open"
},
"MetadataOptions": {
"State": "pending",
"HttpTokens": "optional",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled"}
}
],
"OwnerId": "410914255776",
"ReservationId": "r-06cad74b9a0efc348"
}
C:\Users\user>aws s3api create-bucket --bucket avi12345678 --region ap-south-1
--create-bucket-configuration LocationConstraint=ap-south-1
{
"Location": "http://avi12345678.s3.amazonaws.com/"
}


C:\Users\user\Desktop\cloud>ssh -l ec2-user 13.235.24.83 -i mykey1111.pem
The authenticity of host '13.235.24.83 (13.235.24.83)' can't be established.
ECDSA key fingerprint is
SHA256:AiIuVm0N9gv+phh9lashkjsbUHTW/wY5Hu/lDRDcLNQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '13.235.24.83' (ECDSA) to the list of known hosts.
__| __|_ )_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-40-7 ~]$ whoami
ec2-user
[ec2-user@ip-172-31-40-7 ~]$ sudo su - root
[root@ip-172-31-40-7 ~]# fdisk -l
Disk /dev/xvda: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0D7E094F-1C63-43F2-AC82-3316E992075B
Device
Start
End Sectors Size Type
/dev/xvda1 4096 16777182 16773087 8G Linux filesystem
/dev/xvda128 2048 4095 2048 1M BIOS boot
Partition table entries are not in disk order.
Disk /dev/xvdf: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@ip-172-31-40-7 ~]# fdisk /dev/xvdf
Welcome to fdisk (util-linux 2.30.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x427d49e5.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): pPartition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151):
Created a new partition 1 of type 'Linux' and of size 1023 MiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ip-172-31-40-7 ~]# mkfs.ext4 /dev/xvdf1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 261888 blocks
13094 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@ip-172-31-40-7 ~]# mount /dev/xvdf1 /var/www/html




Hadoop WebApp Automation

  Abstract : Today is an era of Technology and with the increase of technology the amount of data it produces increases every second even no...