Saturday, December 19, 2020

Docker Networking Notes for DCA

 In this post, I will share a few notes which I prepared for the DCA exam. These notes are not complete to cover Docker Networking. But you can use these as reference for quick revision

Host Networking:

1) Container does not get its own IP-address allocated. If you run a container that binds to port 80 and you use host networking, the container’s application is available on port 80 on the host’s IP address.

 2) Host mode networking can be useful to optimize performance. 

3) The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server 

4) You can also use a host network for a swarm service, by passing --network host to the docker service create command.

Bridge Network: 

Bridge network is a Link Layer device that forwards traffic between network segments. Advantage of user-defined bridge network: 

1) User-defined bridges provide better isolation.: Related containers can communicate with each other bypassing --network command while creating service. 

2) During a container’s lifetime, you can connect or disconnect it from user-defined networks on the fly. To remove a container from the default bridge network, you need to stop the container and recreate it with different network options. 

4) Each user-defined network creates a configurable bridge.



Overlay Network: 

Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other

You can also use overlay networks to facilitate communication between a swarm service and a standalone container, or between two standalone containers on different Docker daemons.


Port to open for overlay network: 

TCP port 2377 for cluster management communications 

TCP and UDP port 7946 for communication among nodes 

UDP port 4789 for overlay network traffic 

none: For this container, disable all networking. Usually used in conjunction with a custom network driver.none is not available for swarm services.

Macvlan networks:

1) Macvlan networks are best when you are migrating from a VM setup or need your containers to look like physical hosts on your network, each with a unique MAC address.

2) The macvlan driver is the newest built-in network driver and offers several unique characteristics. It’s a very lightweight driver because rather than using any Linux bridging or port mapping, it connects container interfaces directly to host interfaces. 

3) Scope of Macvlan network is local.


Faqs: 

1) When the container starts, it can only be connected to a single network, using --network. However, you can connect a running container to multiple networks using docker network connect 

2) You can override the hostname using --hostname

Create Service with Custom Overlay Network: 

docker service create --name myoverlay --network mynetwork --replicas 3 nginx 

Verify Networks: 

docker network ls 

Find the IP of Container docker container inspect [CONTAINER-NAME] 

Connect to Container and Install Ping 

docker container exec -it [CONTAINER-NAME] 

apt-get update && apt-get install iputils-ping ping [IP] 

Securing Overlay Network: 

docker network create --opt encrypted --driver overlay 

Saturday, April 18, 2020

Kibana installation on AWS EC2

This post is in continuation to my last post on ElasticSearch, Filebeat and Kibana installation on AWS EC2 where I discussed installation details for elastic search. Also, Please refer to my last post to find configuration details of EC2 instance.

I will continue with details on how to install Kibana on AWS EC2 instance in this post.

1) Import elastic search GPG key
# sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

2) Create a file named kibana.repo under /etc/yum.repos.d/ and paste below content and save the file. # cd /etc/yum.repos.d/
# vi kibana.repo

[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

3) Install kibana
#yum install kibana

4) Go to /etc/kibana/ and edit Kibana.yml
# vi /etc/kibana/kibana.yml

elasticsearch.hosts: ["http://localhost:9200"]
elasticsearch.requestTimeout: 90000
server.host: "0.0.0.0"

5) Start Kibana service
# sudo service kibana start

6) Add kibana as service to start automatically on EC2 instance statup
#sudo chkconfig --add kibana

7) Kibana should be up and running on default port 5601. Hope you have added inbound rules on your EC2 instance for port 5601, so that Kibana is accessible with your elastic IP on 5601.

Sunday, April 12, 2020

ElasticSearch, Filebeat and Kibana installation on AWS EC2



Recently, I installed ELK(7.6.2) along with File beat on Amazon Web Service. I will share my experience with details of steps and issues faced during installation.

Configuration of EC2 instance:

1) Create a AWS EC2 instance of Amazon Linux AMI (and not Amazon Linux 2 AMI), instance type smaller than this will create space issues and other issues.



2) Instance type as t2.medium

3) With Minimum storage size of 16 GB

4) Set inbound ec2 rules on port 9200(default port of elasticsearch) and 5601 (default port of kibana)
5) Associate elastic IP to this instance.

While restarting instance after elasticsearch and Kibana installation, 1 check out of 2 (Instance Status check: These checks monitor your software and network configuration for this instance.) failed and an instance got terminated automatically. So, my suggestion is to create an instance with minimum configuration as recommended above.

Below series of ec2 instances shows the structure of how the setup was configured.

1) EC2 instance of small size - Java 8, and tomcat8 along with tomcat manager was installed. This was considered a dev server where developers used to create a war file of microservice/Rest end point locally and then deploy a war file on it tomcat manually.
Filebeat was installed so that logs can be sent to elasticsearch server on other EC2 instance.


2) EC2 instance of medium size - Java 8, Apache Maven, Jenkins and tomcat along with tomcat manager was installed. Here deployment used to happen using jenkins job on tomcat server.
Jenkins Job was triggered automatically when developers used to commit code in AWS Code commit and changes were deployed on QA tomcat server.
Filebeat was installed so that logs can be sent to elasticsearch server on other EC2 instance.

3) AWS EC2 instance with size of medium and minimum 16 GB HDD: ElasticSearch and Kibana was installed on this instance.

Steps to install ElasticSearch on EC2 instance:

1) Import elastic search GPG key
#sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

2) Create a file named elasticsearch.repo under /etc/yum.repos.d/ and paste below content and save the file.
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Note: Adding 7.x will install the latest version of 7.x. You can mention 6.x to install the older version.
3) Install elasticsearch yum install elasticsearch
4) Goto cd /etc/elasticsearch/ and edit elasticsearch.yml
#vi elasticsearch.yml
cluster.name:
node.data : true
network.host : 0.0.0.0
discovery.seed_hosts : ["localhost", "127.0.0.1", "<elastic-ip of your EC2 instance on which ElasticSearch is installed>"]

5) Run this to start elasticsearch automatically while starting ec2 instance.
# sudo chkconfig --add elasticsearch

6) Start elasticsearch service
# sudo -i service elasticsearch start
7) Run http://<elastic-ip of your EC2 instance on which ElasticSearch is installed>:9200/ and you will get a response. 

Please follow my upcoming post for Kibana and Filebeat installation.

Saturday, January 26, 2019

JPMorgan Interview Questions

Face-To-Face: June 2018
Exp Level: 5-7 Years

Round 1:
a=10 a=20
b=30 b=40
c=40 c=30
d=20 d=10
Swap without using third variable

Concurrent modification exception
ConcurrentHashMap,
 and details
minor and major exception
Garbage collection algo
classloaders, bootstrap classloader and use
"     Utsav Garg.     "- trim without using trim function
Write Iterator on Hashmap
Why we cannot create object of abstract class
Can we create constructor of abstract class.
Difference between interface and abstract class
Find duplicate values using sql query in column
What is error and give example
Exception hierarchy
Aggregation and composition
How we create threads
Types of memory in java
String pool in java
Write customised exception example.
What is SQL Joins and example
example of marker interface and its benefit

Round 2
Features of Java 8
Functional interface vs interface vs abstract class
Lambda expression and write example of it.
Critical section in threads
What is synchronization
Volatile variable
Given 5 lifts and people want to use lift. Whats the optimised approach so that people can reach respective floors quickly
What is atomic variable.
What is thread pool
What is executor framework and its interfaces.

Round 3
About your experience
There is a search box and user is searching something and result is too slow. How will you find root cause. Possible root cause and approach to solve it.
Find duplicate in a column using SQL queries.

Monday, December 18, 2017

DXC Technology Java Interview Questions

Telephonic: Nov 2017
Exp Level: 5-7 Years

Interview Time: 45 min

What is stored procedure?
JDK Vs JRE Vs JVM
What is singleton design pattern and how to break that.
What is static block in java?
Which webservice you have worked on?
What is difference between Rest and SOAP webservice?
What is SOAP UI and when you use it.
How is SOAP webservice consumed?
Which collection to used for insertion and deletion in large number?
Volatile keyword in java and its working?
Memory leak and scenario where it can happen and how to fix it?
How to create user defined muttable class. What if we remove final keyword from class.
Overloading vs Overriding
What is covariant in java?
LAZY fetching in Hibernate.
What do you understand by L3 and L2 Support.
What you do when you get a production issue.

For Oracle Financial Interview Questions Click Here

For Bidgely Technologies Interview Questions Click Here

Wednesday, December 13, 2017

GoodWorkLabs Java Interview Questions



Telephonic: Nov 2017
Exp Level: 5-7 Years

Interview Time: 45 min

Rest Vs SOAP
Callable vs Runnable
What is indexing in Database. What is hashing in Database.
What is blocking queue. Any when it is used. Explain in detail.
Explain Consumer producer problems.
What if you have multiple producer and consumer in producer consumer problem.
Design patterns used in default jar files of Java
Factory Vs Abstract factory pattern
What is Singleton Design Pattern and How we implement it in multithreaded environment.
Annotations used in SOAP webservice Server.
Cache level in hibernate and explain first level and second level cache. Benefits of it.
Interface Vs Abstract Class
OOPS concepts
Can we overload/Override static method. Why?
Which design patterns you have used?
While returning a object from webservice call if you don't want to share all values to client how to do that?
Which annotation is used to convert response to XML format in SOAP webservice?
How you consume webservice?
Overloading vs Overriding
Can we have static class in java. What is static class in java?

For Oracle Financial Interview Questions Click Here

For Bidgely Technologies Interview Questions Click Here

Genpact Capital Markets Java Interview Questions

Telephonic: Dec 2017
Exp Level: 5-7 Years

1) What is Queue in Data Structure. Explain various function in queue.
2) What is Stack in Data Structure. Explain various function in Stack and How you will Implement them.
3) What is Binary Trees and its properties.
4) How do we search in Binary trees.
5) Explain various OOP's Java Concepts.
6) What is Comparable and Comparator in Java. Explain in detail with differences.
7) Can we create a static class in java. If yes, then how.
7) What is Union in SQL and How it is different from Union All.
8) What is IN in SQL.
9) What is Group By, Having clause in SQL.
10) What is view in SQL and how do we create it.
11) There is a Employee class and we want to sort based on Employee id and Employee Name. How to do that.

This is the list of question which I can recall while posting. There were many more questions which were asked. Interview went for around 50 minutes.

For Oracle Financial Interview Questions Click Here

For Bidgely Technologies Interview Questions Click Here