Sunday, July 26, 2020

Connecting to AWS Windows machine with the help of password

In this blog, I will show you on how to create the password for windows machine based on Key pair and use that password to login into your windows instance.

Open the EC2 instance dashboard and select the windows instance that you want to connect to. 
EC2 instance page

In my case, I have only one windows machine and I have selected the same. Now click on the Actions option, now you can see an option to Get Windows password.

Actions and Get Windows password
Now you can see that the Key Pair name which is connected to this instance, upload the PEM file or Key pair file using the choose file option, this will upload the PEM content. Now click on Decrypt password.
Upload the PEM file

If the file is a valid one, then it will decrypt and shows you the password of that instance.
windows password info

Now open RDTP software on your computer and fill the given details and you would log in into to the Windows machine.

Create an Windows EC2 machine on Amazon Web Services

AWS(Amazon Web Services) is one of the popular cloud service providers with many services ranging from infra to Machine learning. Below are the simple steps that will help you to invoke your own Windows machine in the AWS environment. 

        Create your AWS account and open your AWS console and select the EC2 service section. If you don't see it on the main page, you can search the keyword EC2.
AWS EC2 search
Below is the landing page of the EC2 Dashboard page, where you can see the different information like how many instances are running, Elastic IP addresses, Dedicated hosts, Load Balancers, everything related to computing infra with security groups and Key pairs as well. Now in order to create an instance, we have to open the running instance's option. 
Elastic Cloud Computing
You will be directed to a dashboard where you can see the EC2 machines available under this account. In my situation, I don't have any so it will be blank.
EC2 machine page
 Now click on Launch Instance Option, this will redirect to the first step of EC2 creation that is the AMI selection. The AMI refers to Amazon Machine Image, it is basically an OS image that is provided by the Amazon, I am going to select Windows Free tier AMI as an example.
Windows Image
Next step is to select our CPU capacity, currently, this machine is just for educational purpose, so I am gonna stick with free tier option with 1 GB ram and a single CPU core called as t2.micro.
t2 micro instance type
Next step is to configure instance details like you can give the number of instances that you want to create with this step, this feature is useful for corporate where they have to create multiple instances with same configuration by simply specifying the number of instances value. Currently, our target is only 1 with default settings.
AWS instance Details
Add the required amount of memory(Hard disk Memory), you have an option to add as partitions as well. Currently, I will go with the default memory size that is 30 GB.
Storage space

The step is adding tags, this is another useful feature which helps us to identify the instance usage, so if you are planning for multiple instances, you can tag each of those with the respective value. And of course, this is an option.
AWS EC2 tags

Next is the security group step, this is the critical step which if not configured properly will mess with the access issues. You have two options one is to use an existing security group or create a new one, as this is a separate instance I would like to create one. Now I have given the Source IP as 0.0.0.0/0 because I want to access this machine from everywhere instead from one machine. If your requirement is to only access it from your machine, then you can specify your IP, this helps you to prevent other machines to access your instance.
AWS EC2 Security Group
Now all the steps are done, now its time to review the configurations once more and launch your instance.
Review instance info
After you are good with the configurations, you will be asked with the crucial part that is the login details, in AWS terms we call it Key Pairs. You have two options, one is to create a new pair or to use the existing pair. Currently, I don't have available pairs so I will go with creating a new pair option. Once you have given the Key pair name, the AWS service will generate a PEM file and associates that PEM file to your instances. We have to download this PEM file and store it for future purpose. This PEM file is very important so better store it in a secure place.
Key Pair AWS EC2

Once the instance is successfully created you will get a success message and after a few minutes you can see your new instance state as running in EC2 Instance page

Instance success message

Instance running


Now you can connect to this machine using the password which can be generated with the downloaded pem file(You can follow this blog post for the same)

Saturday, July 11, 2020

Installing Kubernetes on Bare Metal(Ubuntu) using the command line interface


 

  1. First of all install kubelet, kubeadm, kubectl, docker.io in all machines both master and slave 

Update the repository details of the Linux/Ubuntu 

apt-get update && apt-get install -y apt-transport-https 

Using the curl add and accept the certificate of the Kubernetes URL to the machine 

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add  

  1. Add the Kubernetes repository to the list to facilitate the download of the Kubernetes components (Kubectl, kubeadm, docker and kubelet) 

cat <<EOF >/etc/apt/sources.list.d/Kubernetes.list 

deb http://apt.kubernetes.io/ Kubernetes-xenial main 

EOF 

Update the repo details of the Linux so that the Kubernetes URL will be added  

apt-get update 

 

apt-get install -y kubelet kubeadm kubectl docker.io 

 

NOTE: Minimum requirement is 2 CPU cores in the machines 

  1. Once all the requirements got installed, go to the master and initiate the kubeadm 

sudo kubeadm init 

  1. Now this command will create a folder with all the manifest files and everything that is needed in the Kubernetes master. You will also get the kube admin join command once we initiate the kubeadm  init 
  2. To start using your cluster, you need to run the following as a regular user: 

mkdir -p $HOME/.kube 

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 

sudo chown $(id -u):$(id -g) $HOME/.kube/config 

  1. Now using the captured join the command we can add the nodes to the cluster. 

Just login into the node machine and enter the join command. 

Example: 

 kubeadm join 10.160.0.4:6443 --token 6w4vni.jgvtu4s85ojbxgrm --discovery-token-ca-cert-hash <token generated by master> 

 In some cases, we might want to add a new node to an existing cluster, if we have the join token with usthen it is ok, but if we don’t have that information we can get it by executing

kubeadm token create –print-join-command  on master 

  1. Now to verify whether the nodes are connected just by running the 

 sudo kubectl get nodes 

  1. Sometimes the internal kube-proxy may throw some error and might not be useful, this state will block the node or master to be ready for execution operations. To get out of this situation we can install a Network Policy Provider, we can use Weave Net for Network Policy. Below is the command to add it to our cluster, 

 

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')

 

After a few seconds, a Weave Net pod should be running on each Node and any further pods you create will be automatically attached to the Weave network.