Saturday, 31 August 2019

How to Setup Kubernetes cluster in AWS ec2 instance by using KOPS Kubectl?

First we have to launch ubuntu 18.04 & login through putty
then enter root 
--------------------------------------------------------------------------------------------------
Configure awscli by these commands
--------------------------------------------------------------------------------------------------
    1  curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip
    2  apt install unzip python
    3  ls
    4  unzip awscli-bundle.zip
    5  ls -l
    6  ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
    7  aws
-------------------------------------------------------------------------------------------------
After this install kubernetes
-------------------------------------------------------------------------------------------------
   12  curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s
         https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
   13  chmod +x ./kubectl
   14  sudo mv ./kubectl /usr/local/bin/kubectl
-----------------------------------------------------------------------------------------------------------------
Create 1 s3 bucket & iam role & give s3full & ec2full & route53 & iam full Acesss to the role
-----------------------------------------------------------------------------------------------------------------
   15  aws s3 ls
   16  aws configure
   17  aws s3 mb s3://devdas.k8s.valaxy.in    === s3 bucket name should be unique
   22  aws s3 ls
   23  export KOPS_STATE_STORE=s3://dev.k8s.valaxy.in
   24  ssh-keygen
========================================================================                                            These are the commands by which i got errors 
========================================================================
   25  kops create cluster --cloud=aws --zones=us-east-1a --name=prati.k8s.valaxy.in --dns-
         zone=valaxy.in --dns private
   26  kops create cluster --cloud=aws --zones=us-east-1a --name=prati11.k8s1.valaxy1.in --dns-
         zone=valaxy.in --dns private
   27  kops create cluster --cloud=aws --zones=us-east-1b --name=prati11.k8s1.valaxy1.in --dns-
         zone=valaxy.in --dns private
   28  aws s3 mb s3://dev1.k8s.valaxy.in
   29  aws s3 mb s3://pratyusha
   30  kops create cluster --cloud=aws --zones=us-east-1b --name=prathyusha --dns-zone=valaxy.in --dns private
   31  kops create cluster --cloud=aws --zones=us-east-1b --name=pratyusha --dns-zone=valaxy.in --dns private
   32  aws s3 mb s3://devdas.k8s.valaxy.in
   33  kops create cluster --cloud=aws --zones=us-east-1b --name= devdas.k8s.valaxy.in --dns-zone=valaxy.in --dns private
   34  export AWS_DEFAULT_PROFILE=<your_aws_credentials_profile_name>
   35  export AWS_DEFAULT_PROFILE=<naredrareddym2002>
   36  export AWS_DEFAULT_PROFILE=naredrareddym2002
   37  export AWS_SDK_LOAD_CONFIG=1
   38  kops create cluster --cloud=aws --zones=us-east-1b --name=devdas.k8s.valaxy.in --dns-zone=valaxy.in --dns private
   39  kops create cluster --name=SOME_CLUSTER_NAME --state=s3://SOME_BUCKET --node-count=3 --authorization=RBAC --zones=us-west-2a,us-west-2b,us-west-2c --master-zones=us-west-2a,us-west-2b,us-west-2c --node-size=m5.large --master-size=r4.large --master-count=3 --networking=weave --topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0 --target=terraform -v 100
   40  kops create cluster --name=SOME_CLUSTER_NAM --state=s3://devdas.k8s.valaxy.in --node-count=3 --authorization=RBAC --zones=us-east-1a,us-east-1b,us-east-1c --master-zones=us-east-1a,us-west-2b,us-west-2c --node-size=m5.large --master-size=r4.large --master-count=3 --networking=weave --topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0 --target=terraform -v 100
   41  kops create cluster --name=privateclus --state=s3://devdas.k8s.valaxy.in --node-count=2 --authorization=RBAC --zones=us-east-1a,us-east-1b,us-east-1c --master-zones=us-east-1a --node-size=t2.micro --master-size=r4.large --master-count=3 --networking=weave --topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0 --target=terraform -v 100
   42  cat ~/.aws/config
   43  kops create cluster --name=privateclus.valaxy.in --state=s3://devdas.k8s.valaxy.in --node-
         count=2 --authorization=RBAC --zones=us-east-1a,us-east-1b,us-east-1c --master-zones=us-
         east-1a --node-size=t2.micro --master-size=r4.large --master-count=3 --networking=weave --
         topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0
         target=terraform -v 100
   44  kops create cluster --name=valaxy.in --state=s3://devdas.k8s.valaxy.in --node-count=2 --   
         authorization=RBAC --zones=us-east-1a,us-east-1b,us-east-1c --master-zones=us-east-1a -- 
         node-size=t2.micro --master-size=r4.large --master-count=3 --networking=weave
         topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0 --                       target=terraform -v 100
   45  top
   46  kops update cluster devdas.k8s.valaxy.in --yes
   47  export KOPS_STATE_STORE
   48  kops create cluster --name=valaxy.in --state=s3://devdas.k8s.valaxy.in --node-count=2 --
         authorization=RBAC --zones=us-east-1a,us-east-1b,us-east-1c --master-zones=us-east-1a --                 node-size=t2.micro --master-size=r4.large --master-count=3 --networking=weave --               
         topology=private --ssh-public-key=/root/.ssh/id_rsa.pub --kubernetes-version=1.10.0 --                       target=terraform -v 100
   49  kops create cluster --cloud=aws --zones=us-east-1c --name=devdas.k8s.valaxy.in --dns-                       zone=valaxy.in --dns private
   50  kops create cluster --cloud=aws --zones=us-east-1c --name=devdas.k8s.valaxy.in --dns-     
         zone=valaxy.in --dns private export KOPS_STATE_STORE
========================================================================
Remove errors in this command, we have given --state flag in which s3 bucket all the files should enter
-------------------------------------------------------------------------------------------------------------------------
   51  kops create cluster --cloud=aws --zones=us-east-1c --name=devdas.k8s.valaxy.in
         --state=s3://devdas.k8s.valaxy.in --dns-zone=valaxy.in --dns private
--------------------------------------------------------------------------------------------------
   55  export KOPS_STATE_STORE=s3://devdas.k8s.valaxy.in
   56  ls
--------------------------------------------------------------------------------------------------
To get details of the kubernetes cluster
--------------------------------------------------------------------------------------------------
   57  kops update cluster devdas.k8s.valaxy.in
--------------------------------------------------------------------------------------------------
To create a cluster
--------------------------------------------------------------------------------------------------
   58  kops update cluster devdas.k8s.valaxy.in --yes
   59  kops validate cluster
--------------------------------------------------------------------------------------------------
To get node details
--------------------------------------------------------------------------------------------------
   60  kubectl get nodes
--------------------------------------------------------------------------------------------------
To get configuaration details
--------------------------------------------------------------------------------------------------
   66  vi ~/.kube/config
--------------------------------------------------------------------------------------------------
To enter into the master   (ssh  -i .ssh/id_rsa admin@ipv4-public-ip-of-master)
--------------------------------------------------------------------------------------------------
   69  ssh  -i .ssh/id_rsa admin@3.82.160.192
   70  cd .ssh
   71  ls
   72  ssh -i id_rsa admin@3.82.160.192
--------------------------------------------------------------------------------------------------
After entering into master we check nodes status
--------------------------------------------------------------------------------------------------
admin@ip-172-20-53-221:~$
    2  kubectl get nodes
    5  kubectl get pods
    6  kubectl --help
    7  ls -la
    8  cd .ssh
    9  ls
   10  cd ..
   11  sudo -i
   12  exit
   13  kubectl get nodes
--------------------------------------------------------------------------------------------------
We need to create pods in the nodes:
POD - write a code to deploy like web servers -tomcat /nginx
--------------------------------------------------------------------------------------------------
   14  kubectl run sample-nginx --image=nginx --replicas=2 --port=80
   15  kubectl get pods
   16  kubectl get deployments
   17  kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer
   18  ls
   19  kubectl get services -o wide
   20  kubectl get services
   21  kubectl get pods
   22  kubectl describe pod sample-nginx-594488f9c5-gvlqx
admin@ip-172-20-53-221:~$ exit
logout
Connection to 3.82.160.192 closed.

Friday, 30 August 2019

How to install JAVA-8 and JENKINS in AWS EC2 REDHAT Linux Instance?

Launch a REDHAT Linux instance in AWS andlog into it
----------------------------------------------------------------------
JAVA8 is the prerequisite to install jenkins server
----------------------------------------------------------------

INSTALLING JAVA-8 IN AWS EC2 INSTANCE:

1. cd /opt/
2. wget --no-cookies --no-check-certificate --header "Cookie:     
    gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie"
    "http://download.oracle.com/otn-pub/java/jdk/8u131- 
    b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz"
3. tar xzf jdk-8u131-linux-x64.tar.gz
4. ls
5. cd jdk1.8.0_131
6. ls
7. alternatives --install /usr/bin/java java /opt/jdk1.8.0_131/bin/java 2
8. alternatives --config java
9. alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_131/bin/jar 2
10. alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_131/bin/javac 2
11. alternatives --set jar /opt/jdk1.8.0_131/bin/jar
12. alternatives --set javac /opt/jdk1.8.0_131/bin/javac
13. export JAVA_HOME=/opt/jdk1.8.0_131
14. export JRE_HOME=/opt/jdk1.8.0_131/jre
15. export PATH=$PATH:/opt/jdk1.8.0_131/bin:/opt/jdk1.8.0_131/jre/bin
16. java -version

--------------------------------------------------------------------------------------------------------------------------
INSTALLING JENKINS IN AWS REDHAT LINUX EC2 INSTANCE:


After installing JAVA8 , then from here copy these three commands and paste it in putty


1. sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
2. sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
3. yum install jenkins

service jenkins status

service jenkins start---------------- (It will show like this)
Starting jenkins (via systemctl):                          [  OK  ]
--------------------------------------------------------------------------------------------------------------------------

After starting jenkins go to aws ec2 dashboard and copy instance ip adress and paste it in the browser

immediately jenkins server will ask adminstrator password

then we have to copy /var/lib/jenkins/secrets/initialAdminPassword

and paste it in putty command :- cat /var/lib/jenkins/secrets/initialAdminPassword

Then a password will generate and copy and paste it in jenkins server


Monday, 26 August 2019

INSTALLATION OF CENTOS7 ON ORACLE VIRTUAL MACHINE

HOW  TO INSTALL CENTOS7 ON ORACLE VIRTUAL MACHINE?

Installing CentOS 7 on VirtualBox

1. Download and install VirtualBox from its official website, and make sure that you had downloaded the latest version.
2. Also download the official CentOS ISO from the official website, the latest CentOS build is  7.
3. Run your VirtualBox after you had installed it on your computer and located its icon on the desktop and click on “New“.
4. Give your new OS name and set your RAM memory, and also select the version to be “Red Hat (64-bit).
5. On the Hard Disk step, select “Create a virtual hard drive now” and then click Create.
6. Select VDI “VirtualBox Disk Image” and click Next, and then select “Dynamically allocated” and click Next then Create.
7. From the Setting click on Storage, and then add the ISO file to the optical drive to install the operating system.
8. You had successfully configured your CentOS well, power on your virtual machine by clicking on Start.
9. From the boot menu select “Install CentOS Linux 7” and press Enter.
10. Select your language and press on Continue.
11. Setup your time settings, location, network, and then click “Begin Installation”.
12. During the installation, you set the root and the user account.
 After the installation is completed, press on Reboot.

Summary

Now you had installed CentOS 7 on a virtual machine successfully.
If you have any inquiry regarding this guide please comment below.

HOW TO CREATE AWS COMPUTING OF EC2?

AWS COMPUTING OF EC2


Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.
Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment. Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing you to quickly scale capacity, both up and down, as your computing requirements change. Amazon EC2 changes the economics of computing by allowing you to pay only for capacity that you actually use. Amazon EC2 provides developers the tools to build failure resilient applications and isolate them from common failure scenarios.

Benefits

ELASTIC WEB-SCALE COMPUTING

Amazon EC2 enables you to increase or decrease capacity within minutes, not hours or days. You can commission one, hundreds, or even thousands of server instances simultaneously. You can also use Amazon EC2 Auto Scaling to maintain availability of your EC2 fleet and automatically scale your fleet up and down depending on its needs in order to maximize performance and minimize cost. To scale multiple services, use AWS Auto Scaling.

COMPLETELY CONTROLLED

You have complete control of your instances including root access and the ability to interact with them as you would any machine. You can stop any instance while retaining the data on the boot partition, and then subsequently restart the same instance using web service APIs. Instances can be rebooted remotely using web service APIs, and you also have access to their console output.

FLEXIBLE CLOUD HOSTING SERVICES

You have the choice of multiple instance types, operating systems, and software packages. Amazon EC2 allows you to select a configuration of memory, CPU, instance storage, and the boot partition size that is optimal for your choice of operating system and application. For example, choice of operating systems includes numerous Linux distributions and Microsoft Windows.

INTEGRATED

Amazon EC2 is integrated with most AWS services such as Amazon Simple Storage Service (Amazon S3), Amazon Relational Database Service (Amazon RDS), and Amazon Virtual Private Cloud (Amazon VPC) to provide a complete, secure solution for computing, query processing, and cloud storage across a wide range of applications.

RELIABLE

Amazon EC2 offers a highly reliable environment where replacement instances can be rapidly and predictably commissioned. The service runs within Amazon’s proven network infrastructure and data centers. The Amazon EC2 Service Level Agreement commitment is 99.99% availability for each Amazon EC2 Region.

SECURE

Cloud security at AWS is the highest priority. As an AWS customer, you will benefit from a data center and network architecture built to meet the requirements of the most security-sensitive organizations. Amazon EC2 works in conjunction with Amazon VPC to provide security and robust networking functionality for your compute resources.

AWS NETWORKING OF VPC

VIRTUAL PRIVATE CLOUD


What Is Amazon VPC?

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

Amazon VPC Concepts


Amazon Virtual Private Cloud (Amazon VPC) lets you provision a logically isolated section of the AWS Cloud where you can launch AWS resources in a virtual network that you define. You have complete control over your virtual networking environment, including selection of your own IP address range, creation of subnets, and configuration of route tables and network gateways. You can use both IPv4 and IPv6 in your VPC for secure and easy access to resources and applications.

You can easily customize the network configuration for your Amazon VPC. For example, you can create a public-facing subnet for your web servers that has access to the Internet, and place your backend systems such as databases or application servers in a private-facing subnet with no Internet access. You can leverage multiple layers of security, including security groups and network access control lists, to help control access to Amazon EC2 instances in each subnet.

HERE IS THE VIDEO TUTORIAL HOW TO CREATE VPC WITH SINGLE SUBNET







HERE IS THE VIDEO TUTORIAL HOW TO CREATE VPC WITH PRIVATE AND PUBLIC SUBNETS






Features

MULTIPLE CONNECTIVITY OPTIONS

A variety of connectivity options exist for your Amazon VPC. You can connect your VPC to the Internet, to your data center, or other VPCs, based on the AWS resources that you want to expose publicly and those that you want to keep private.
  • Connect directly to the Internet (public subnets)– You can launch instances into a publicly accessible subnet where they can send and receive traffic from the Internet.
  • Connect to the Internet using Network Address Translation (private subnets) – Private subnets can be used for instances that you do not want to be directly addressable from the Internet. Instances in a private subnet can access the Internet without exposing their private IP address by routing their traffic through a Network Address Translation (NAT) gateway in a public subnet.
  • Connect securely to your corporate datacenter– All traffic to and from instances in your VPC can be routed to your corporate datacenter over an industry standard, encrypted IPsec hardware VPN connection.
  • Connect privately to other VPCs- Peer VPCs together to share resources across multiple virtual networks owned by your or other AWS accounts.
  • Privately connect to AWS Services without using an Internet gateway, NAT or firewall proxy through a VPC Endpoint. Available AWS services include S3, DynamoDB, Kinesis Streams, Service Catalog, AWS Systems Manager, Elastic Load Balancing (ELB) API, Amazon Elastic Compute Cloud (EC2) API, and SNS.
  • Privately connect to SaaS solutions supported by AWS Private Link.
  • Privately connect your internal services across different accounts and VPCs within your own organizations, significantly simplifying your internal network architecture.
  • Use Amazon VPC traffic mirroring to capture and mirror network traffic for Amazon EC2 instances

Use cases

HOST A SIMPLE, PUBLIC-FACING WEBSITE

You can host a basic web application, such as a blog or simple website in a VPC, and gain the additional layers of privacy and security afforded by Amazon VPC. You can help secure the website by creating security group rules which allow the webserver to respond to inbound HTTP and SSL requests from the Internet while simultaneously prohibiting the webserver from initiating outbound connections to the Internet. You can create a VPC that supports this use case by selecting "VPC with a Single Public Subnet Only" from the Amazon VPC console wizard.

HOST MULTI-TIER WEB APPLICATIONS

You can use Amazon VPC to host multi-tier web applications and strictly enforce access and security restrictions between your webservers, application servers, and databases. You can launch webservers in a publicly accessible subnet and application servers and databases in non-publically accessible subnets. The application servers and databases can’t be directly accessed from the Internet, but they can still access the Internet via a NAT gateway to download patches, for example. You can control access between the servers and subnets using inbound and outbound packet filtering provided by network access control lists and security groups. To create a VPC that supports this use case, you can select "VPC with Public and Private Subnets" in the Amazon VPC console wizard.

HOST SCALABLE WEB APPLICATIONS IN THE AWS CLOUD THAT ARE CONNECTED TO YOUR DATACENTER

You can create a VPC where instances in one subnet, such as web servers, communicate with the Internet while instances in another subnet, such as application servers, communicate with databases on your corporate network. An IPsec VPN connection between your VPC and your corporate network helps secure all communication between the application servers in the cloud and databases in your data center. Web servers and application servers in your VPC can leverage Amazon EC2 elasticity and Auto Scaling features to grow and shrink as needed. You can create a VPC to support this use case by selecting "VPC with Public and Private Subnets and Hardware VPN Access" in the Amazon VPC console wizard.

EXTEND YOUR CORPORATE NETWORK INTO THE CLOUD

You can move corporate applications to the cloud, launch additional web servers, or add more compute capacity to your network by connecting your VPC to your corporate network. Because your VPC can be hosted behind your corporate firewall, you can seamlessly move your IT resources into the cloud without changing how your users access these applications. You can select "VPC with a Private Subnet Only and Hardware VPN Access" from the Amazon VPC console wizard to create a VPC that supports this use case.

DISASTER RECOVERY

You can periodically backup your mission critical data from your datacenter to a small number of Amazon EC2 instances with Amazon Elastic Block Store (EBS) volumes, or import your virtual machine images to Amazon EC2. In the event of a disaster in your own datacenter, you can quickly launch replacement compute capacity in AWS to ensure business continuity. When the disaster is over, you can send your mission critical data back to your datacenter and terminate the Amazon EC2 instances that you no longer need. By using Amazon VPC for disaster recovery, you can have all the benefits of a disaster recovery site at a fraction of the normal cost.

Benefits

SECURE
Amazon VPC provides advanced security features, such as security groups and network access control lists, to enable inbound and outbound filtering at the instance level and subnet level. In addition, you can store data in Amazon S3 and restrict access so that it’s only accessible from instances in your VPC. Optionally, you can also choose to launch Dedicated Instances which run on hardware dedicated to a single customer for additional isolation.

SIMPLE

You can create a VPC quickly and easily using the AWS Management Console. You can select one of the common network setups that best match your needs and press "Start VPC Wizard." Subnets, IP ranges, route tables, and security groups are automatically created for you so you can concentrate on creating the applications to run in your VPC.

ALL THE SCALABILITY AND RELIABILITY OF AWS

Amazon VPC provides all of the same benefits as the rest of the AWS platform. You can instantly scale your resources up or down, select Amazon EC2 instances types and sizes that are right for your applications, and pay only for the resources you use - all within Amazon’s proven infrastructure.

Streamlining the usage of GITHUB

Streamlining the usage of Github with Commands 1. Start a new git repository under one directory locally In this step, we need to bui...