Thursday, 4 August 2022

Importance of urandom egd in containers -> java -Djava.security.egd=file:/dev/urandom Importance

 In high distributed, scaled applications , One System/Server needs to connect another Downstream System/Server to establish session, certificates,

Here session/certificates are having random numbers,

Our java security pickup the random number from Linux/Window entropy pool.


What is entropy pool ?

         In any server, user hits the server through keyboard some other noises, Linux server capture those noises put them into entropy pool.


EGD - Entropy Gathered Device


our java security device -> java.security.egd=file:/dev/random


java.security.egd=file:/dev/random

      By default java8 and java11 this property is there in the java.security file, 

If entropy pool having full entries, file:/dev/random works fine,

If entropy pool having no entries, file:/dev/random will waits for long time, it is blocking the thread, it is hitting the performance.


Solution: Always use the java.security.egd=file:/dev/urandom in PCF/Kubernets/Virtual Server.


java.security.egd=file:/dev/urandom

      need to pass this argument in java argument.

If entropy pool having full entries, file:/dev/urandom works fine,

If entropy pool having no entries, file:/dev/urandom will not wait, it will genereate the random number hence it will improve the performance, no blocking of the thread.

Sunday, 26 July 2020

Book Review

React: For React js I had seen videos by experts, but not get clarity. But I had read very good book
"Learning React A Hands-On Guide to Building Web Applications Using React and Redux by Kirupa Chinnathambi" It's very good book.It's covered react fundamental very good way.

for redux storage below link given very good
https://chriscourses.com/blog/redux - react-redux

Spring Boot Auto-Configuration:

Kubernetes Administration certification:
Basically Kubernetes is wrapper around the docker container. 
Try to understand kubernetes components. Intention of each kubernets component.
While doing monitoring (logs & metrics) I had taken helm install those packages. Here important point
Metrics :- ( Kubernetes Components ) Level and Application ( Deployed application) Level, Don't confuse here.
First complete extra ordinary course kubernetes administration certification course.
then follow below book some more understanding
"Kubernetes Up and Running Dive Into the Future of Infrastructure by Brendan Burns Joe Beda Kelsey Hightower" best book for kubernetes administrators


Thursday, 25 June 2020

CISCO VPN - Docker Issue

Docker server means Docker Process alias Docker daemon. In the oracle vm docker daemon process is running.

Now from windows 10 ( Guest) Wants to talk with Docker Daemon process.  Now if you on cisco vpn then

Windows (10) Guest --> cisco vpn 

Now cisco vpn doesn't know who is the docker daemon process.

"Now we will use port forward technice like we are using in putty", now we will apply same technique through docker command style.

Now giving step by step process.

Click on docker quick start terminal > 

 Delete existing oracle vm instance default
1)  $docker-machine rm -f default

//Now we need create new docker instance (server)
2)  $docker-machine create default --virtualbox-no-vtx-check , if it's throwing error due to proxy then run below command

In case of proxy:
docker-machine create default --virtualbox-no-vtx-check \
--engine-env HTTP_PROXY=http://username:pwd@proxy-server:8080/ \
--engine-env HTTPS_PROXY=http://username:pwd@proxy-server:8080/ \
--engine-env NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24

//docker-env: This is very important step.
 3) $docker-machine env
     $eval $("C:\Softwares\Docker Toolbox\docker-machine.exe" env)

In case 3rd step failing, then you need manual enter below environment varialbes.
export DOCKER_HOST=tcp://192.168.99.101:2376
export DOCKER_TLS_VERIFY=auto
export DOCKER_TOOLBOX_INSTALL_PATH=C:\Softwares\Docker Toolbox
export DOCKER_CERT_PATH=C:/Users/rameshvanka/.docker/machine/machines/default

//check now docker is working or not
4) docker images

4th step not working means our vpn hero enter in the middle

cisco-vpn issue:
___________________

Reference: https://www.iancollington.com/docker-and-cisco-anyconnect-vpn/

$ export DOCKER_HOST="tcp://127.0.0.1:2376"
$ export DOCKER_CERT_PATH=C:/Users/rameshvanka/.docker/machine/machines/default

$ docker-machine stop default
$ VBoxManage modifyvm "default" --natpf1 "docker,tcp,,2376,,2376"
$ docker-machine start default

$ docker --tlsverify=false ps


$ alias docker='docker --tlsverify=false'

$ docker pull hello-world
pull giving error means then we need to follow below steps.

Reference : http://biercoff.com/fixing-docker-registry-io-timeout-issue-on-mac/

//Now connect oracle vm default through docker-machine:
$ docker-machine ssh default

****************NameServer update start******************************************
//change the nameserver
docker@default:~$ sudo vi /etc/resolv.conf
nameserver 8.8.8.8
****************NameServer update end*********************************************

****************profile update start******************************************
//If any proxy is there , configure the proxy details 
docker@default:~$ sudo vi /var/lib/boot2docker/profile

EXTRA_ARGS='
--label provider=virtualbox

'
CACERT=/var/lib/boot2docker/ca.pem
DOCKER_HOST='-H tcp://0.0.0.0:2376'
DOCKER_STORAGE=overlay2
DOCKER_TLS=auto
SERVERKEY=/var/lib/boot2docker/server-key.pem
SERVERCERT=/var/lib/boot2docker/server.pem

export "HTTP_PROXY=http://username:pwd@proxy-server:8080/"
export "HTTPS_PROXY=http://username:pwd@proxy-server:8080/"
export "NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24"

****************profile update end******************************************

//Now exit from docker default vm
docker@default:~$ exit

//Now restart docker default vm
$ docker-machine restart default

//Now check docker is working or not
$ docker pull hello-world


If you like my article, say yes in comments section.

Wednesday, 17 June 2020

OAUTH2

What is Oauth2 ?

I had went krutunga restaurant in my car. In the restaurant parking person is there, I will hand over my car keys to that hotel parking person. He will park my car into parking area.

Means ?

I am delegating my access to hotel parking person to park my car.

I ( Ramesh) - Resource Owner - User Context
Hotel Parking Person - Client - Client Context
Car - Resource

In the oauth2 means having 2 contexts 1) User Context 2) Client Context don't confuse.

Oauth2 id "Delegate Access Protocol"

OAuth2 having 4 main pillars
1) End User - Resource Owner
2) Client - Web application client/ any other
3) Authorization Server
4) Resource


Difference between Password Credentials and Authorization Code ?

In Password Credentials, EndUser (Ramesh) will give his credentials to Webapp Client, then Webapp Client will talk to (EndUser Credentials + Webapp Client Credentials) to Authorization Server.

In case Authorization code,
1) EndUser (Ramesh) will not share his credentials to Webapp Client,
Instead Authorization server will give login form, Enduser will enter his credentials login form, Authorization will evaluate it.

For Authorization code example:
https://www.linkedin.com/pulse/basic-oauth2-concepts-ramesh-vankayala-ramesh-vankayala/?published=t


I will update soon with diagrams to explain this concept.

Saturday, 9 May 2020

Permutations Program With Backtracking

Backtracking Programming - Check with all feasibles. Dynamic Programming we will choose optimal chosen.

These days in coding exams very popular. Even though you are talented, it will help sharp your skills and ask companies more salary.

If we take the (ABC) --> How many all possible ways to combination, This problem belongs to backtracking.

Backtracking with DFS approach I had taken. DFS (Stack) - means first we will one branch we will complete that branch means here (ABC,0,0) - We will complete all possibilites then we will choose (BAC,0,1) like this way.

For this type of try to understand conceptual logic, it's very tricky here combination of for loop with recursion. for loop --> sequence, recursion --> stack (DFS)

Forumula:
Deriving the recursive with for loop forumula, I am attaching image.




p(ABC,0,2) --> for loop (   (ABC,0,0)  (BAC,0,1)    (CAB,0,2) )
            p(ABC,1,2) --> for ( (swapped str, 1,1)  (swapped str,1,2)) like this

Mixing of recursion with for loop





package optumtest.permutation;

public class PermutationTest {

public static void main(String[] args) {
String str = "ABC";
        int n = str.length();
        PermutationTest permutation = new PermutationTest();
        permutation.permute(str, 0, n-1);
}

int ram = 0;


private void permute(String str, int start, int end) {
System.out.println("("+str+","+start+","+end+")");
if (start == end) {
System.out.println(str);
} else {
for (int i = start; i <= end; i++) {
  str = swap(str, start, i);
permute(str, start + 1, end);
str = swap(str, start, i);
}
}
}


public String swap(String a, int start, int end) {
char temp;
char[] charArray = a.toCharArray();
temp = charArray[start];
charArray[start] = charArray[end];
charArray[end] = temp;
return String.valueOf(charArray);
}

}








Saturday, 2 May 2020

JAVA Streams

Java streams main intension performance improvement.
State of stream - Sorted, distinct
ArrayList : characteristics
public int characteristics()
{ return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; }

HashSet : characteristics
public int characteristics() {
return (fence < 0 || est == map.size ? Spliterator.SIZED : 0) | Spliterator.DISTINCT; }

Stream - Characteristic
ORDERED ordermatters
DISTINCT No duplication possible
SORTED Sorted
SIZED The size is known
NONNULL No nullvalues
IMMUTABLE Immutable
CONCURRENT Parallelismis possible
SUBSIZED The size is known



employee.stream()
                .distinct() // returns a stream = intermediate method
                .sorted()   // the same as distinct()
                .forEach(System.out::println);

How streams will improve performance ?

distinct() and sorted() intermediate methods means until terminal methods forEach invoke no computation will not perfomed ? what it means ?
if stream call distinct() then it will update the state of distinct either 0 or 1.
if stream call sorted() then it will update the state of sorted either 0 or 1
Now terminal method forEach
1) Checks the state of streams in our case
if(distinct==1) { it will perform the distinct operation }
if(sorted == 1) { it will perform the sorted operation }
after that stream it will process each element in stream.

But where you got performance improvement here ?

// HashSet
HashSet<Employee> employee= ... ;
employee.stream()
          .distinct() // no processing is triggered
          .sorted()   // quicksort is triggered
          .forEach (System.out::println);

HashSet stream, HashSet will not allowed duplicated means in our distinct operation not requires.
distinct = 0
sorted = 1
Now forEach it will skip the distinct and perform the sorted so here little bit performance improved.


// SortedSet
SortedSet<Employee> employee= ... ;
employee.stream()
           .distinct() // no processing is triggered
           .sorted()   // no quicksort is triggered
           .forEach(System.out::println);
SortedSet stream - means SortedSet not allows duplicates and it's already sorted
hence
distinct - 0
sorted - 0
hence forEach it will skip the distinct and sorted operations.


We know stateful and stateless object ? What is Stateful and Stateless operation ?

I will explain
// call parallel on an existing stream
List<Person> people = ... ;
 people.stream()
            .parallel()
            .filter(person -> person.getAge() > 20)
            .sorted()
            .forEach(System.out::println);

Here In the filter operation/method, we don't need to remember any state.

// call parallel on an existing stream
List<Person> people = ... ;
people.stream()
          .parallel()
          .skip(2)
          .limit(5)
          .forEach(System.out::println);

We need to maintain one counter variable, remove 2, add 5 means we need to atomicLong instance variable in class level. This instance variable updated by multiple threads.

Here we are depend on counter variable state, this example stateful example.




















Friday, 1 May 2020