admin

Nov 112019
 

In docker world to play around where have docker for mac and docker for windows in k8s we have minikube. Minikube will give a master and a node as a vm and then it will also give a container runtime

Now lets install minikube you can download it from here

https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/windows/amd64/kubectl.exe

before you install minikube make sure that the hyper-v is enabled in BIOS. Once you install mini kube these are the step to be

Get the version of the kubernetes

C:\WINDOWS\system32>kubectl version –client

Client Version: version.Info{Major:”1″, Minor:”10″, GitVersion:”v1.10.11″, GitCommit:”637c7e288581ee40ab4ca210618a89a555b6e7e9″, GitTreeState:”clean”, BuildDate:”2018-11-26T14:38:32Z”, GoVersion:”go1.9.3″, Compiler:”gc”, Platform:”windows/amd64″}

So at this point I have the minikube installed I have the kubenetes install

Now I need to start the minikube and to so that I am running the following command

I have used this link to start the minikube but it didn’t work and I found the problem

https://medium.com/@JockDaRock/minikube-on-windows-10-with-hyper-v-6ef0f4dc158c

the problem was that the minikube didn’t started when the firewall was active to I stopeed the firewall started the minikube and then run the command

>kubectl get nodes

To get the nodes. This will get the nodes for the active context you can see all the context in .kube/config file that are available

Now what I want to see is where my kubectl is pointing so to see that I need to see the current context. The following command will show me the context

<kubectl config current-context

And then you can keep on playing with the minikube to try out K8s locally and see how it works on your dev environment.

 Posted by at 2:37 pm
Nov 112019
 

To understand Kubernetes better let’s discuss an example of football. On a football field, the coach decides where each player will stand and with what qualities. Let’s say the person who is good with goalkeeping will be a goal keeps, the person who is good with attaching will be playing forward. All this orchestration of the player is done by either the coach. Kubernetes is exactly the same where the Kubernetes act as an orchestrator to manage the docker containers.

Kubernetes makes sure that all the required containers are available and suppose to be there to do their job. IN Kubernetes we tell the framework that these are the number of nodes that we want and the rest is handled by Kubernetes itself. It makes sure all the specified number of nodes are up and running. If any of the nodes go down or a scale-up is required k8s takes care of that.

K8s have some basic topic that we need to know before moving forward. These topics recalled K8s objects. In this post, I will stick to the definition and won’t be able to go into more detail.

Pods:

Pod is the basic execution unit of K8s application. The pod encapsulates the application, storage, network and other strategies that govern the containers. The pod can have one or more than one containers. The objective of the Pod is to run the single instance of the given application if you want multiple instances of the application then you need to add more pods.

Service:

An object that acts as an abstraction in running the set of pods a network service. The service is responsible in ensuring that all the network is available between them for proper communication but that decoupling is also enabled.

Namespace:

K8s provide multiple namespaces through which we can classify different resources based on the similar features they have. The namespace is a way to divide the cluster resource between multiple users.

To connect to k8s

1. Before you do that you need to PIM if you have that otherwise, it won’t work

2. Get the configuration from az and to do that you need to run this command. This command will get the config from the az and populate that in the config file as a context. So that, later on, you can switch the context in power shell and connect to it. The name of the resource group should be the same as where you created the culture

az aks get-credentials –resource-group myResourceGroup –name myAKSCluster

 

3. Once you are done that you can see if the configuration is updated or not (which it will be but we will just look at it to get more information). You can also verify it by running the command to get the current context. The command is as follows

Kubectl config current-context

4. Now if you want to connect to the host you need to first open a proxy with the kubectl. The command to do that is

Kubeclt proxy

5. After that, you can open any browser and type this

http://localhost:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/overview?namespace=_all

 

6. To get a list of all the context the command is

Kubectl config get-contexts

7. kubectl exec -it {containerid} -n {namespace} powershell (to access the power shell)

 Posted by at 2:35 pm
Nov 112019
 

Coming back after a few days I totally forgot where I was in the processes and what have I learned so I started by opening the command and started looking at the command to run and the I remember that the first that we run is the docker version to see if the docker is installed properly or not and when I run it I got this message back

  • docker version

docker1

Now here is an error mentioned here which I have no clue how to solve so I will start by ripping that apart.

“error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.”

Th restart didn’t work so I am going to reset it to factory setting

Ok I may have missed something but the command works now so this is what I see

docker2

 

Now I am going to

  • docker run hello-world

The client is going to check if the image exists locally or not and it does so what it will do it’s going to fetch the image form the daemon via the API calls and its going to check the local store and its not there  so its going to go to docker hub and in the public registry. And now when I run it again I will see the hello from the docker message from the container. So it was running showed the message and then existed.

Now to show the container who have been running and existed I need to run a different command. Now when I run this command I will be able to see this

  • docker ps -a

docker3

 

To see the image that is already placed I just go to

  • docker images

And I see this

docker4

 

To remove a docker image us this command sometimes you have to force the delete so for that I am going to use this command

  • docker rmi -f image_id

The terminology goes like this the

Images are stopped containers but the containers are running images.

 

So here I can run the try from the code that I ave from the plural site and for that I can run this command

  • docker run -d –name web -p 90:8080 nigelpoulton/pluralsight-docker-ci

Now in this command as you can see it’s going to make a web container the internal port is outer port to access docker host on port 90 but inside the container, its port is 8080. Once I finish running that command the image is pulled to my local directory.

Now I can check if the container is running or now by running

  • docker ps

In that you can see that the container is running now you have to open the browser and browse to localhost:90 and then you can see that you will be able to access it. Now if you stop the container and browse again you will not be able to access it

 

 

The container lifecycle is not that complex. It include only three states.

docker5

Other common dockers commands are

  • Docker start
  • Docker stop
  • Docker rm conatiner
 Posted by at 2:30 pm
Nov 112019
 

A container is a standard unit to package software. Containers were a product to answer the complex business problems and the application you run those complex business applications. To facilitate the one app and server application infrastructure. Lastly to avoid the expensive cost of the hard and maintained.

conventionally we were using VM to run multiple apps on one server. So image a scenario where you have an application that is divided into three tiers.

Backend application, frontend application, database.

In a conventional VM ware case You can run multiple apps on one server by using this scenario

what is container1

Now in this scenario you can that we have hypervisor is installed which is managing all the VMs each VM will have its OS to maintain and on top of those OS the app is installed we can have one backend application on one VM, one front application on the other VM and lastly the database on the last VM.

In this case you have to manage all the OS on our own, we have to worry about the patches and all the os related problem. We also have to maintain all the licenses for the OS as well which will be expensive. The scaling is not fast either in this use case as we have to kick a new VM image a new OS and then we have to start the scalable application.

In case of containers  we will have something like this

what is conatiner2

Now in this scenario we have the server on top of that we only have one OS and the container are running on top of that. The container is a image of the application director to run on the a specific OS. The upside it manageable number of licenses. In this case the scaling is quite fast as we don’t have to start a new VM image a new OS and run the app instead we just need to spin up a new container and that’s it.

 Posted by at 10:16 am
Nov 112019
 

Today I want to talk about the place where we spend almost eight hours every day or at least from Monday to Friday. There is off course there are some people who work from home but for most of the guys who are doing full time jobs they are normally at their workplace. While staying at work we are mostly working but every now and then we communicate with people around us. Every day we do work discussions, tell jokes, ask for upcoming or previous plans and communicate in many ways.

With all of this constant commination between the work colleagues we make a social or work relation with those people at work even though we are not related or living with our colleagues.

Happiness is working with great people

I am working in Teleopti Sweden (A Calabrio Company) as a Cloud Developer. We have a pretty good amount of people who are in office apart from those who are either travelling for work or working from home. But in the summer the number of people at office decreases substantially due to summer vacations. I am one of the few who are working in those long silent and relaxed sunny summers when most of the office is on vacation. Its not many people around and I would say it’s the best time working at the office. Not many people are around and the one that are around you get the chance to communicate with them. The work environment is less stressful and more quiet. You get more focus on work and self-evaluation. Though both self-evaluation and work are a constant thing that we are doing all the time but during those working days one could take a step back to have more focus.

We are a Team

We are not a team just because we are physically located at one place and working together. We are team because we communicate, we trust, we share jokes, have fun activities and we respect each other. It like having another family at your workplace. We do have a lot of work-related discussions and augments on different things and in the we agree on the common grounds. This is almost like those childhood fight-arguments with our siblings and the next day start without any grudges. This off course gives you the chance to develop that comfort zone which helps you excel.

The Fika policy

‘Fika’ is Swedish is defined as a coffee break. I think this is another healthy tradition that we have at the Swedish work environment. Fika are informal coffee breaks near the kitchen are or the common area. Where you could have work chat to personal chat to mingle more. You normally discuss your weekend, plans for weekend or things in general

With all these things combined I think routine that you have at work in invaluable. It gives you the confidence at drive to work with your team and the people around the office.

 Posted by at 10:08 am
Nov 042019
 

I have a friend who is working as a Principle Developer. He has a fun job responsibility to work with the normally helps start-ups to boot up and when they are done he moves to the next start-up. He has mentored many start-ups and helped them in terms of technology and processes. I had the curiosity to ask him about the famous questions that we normally have in our minds. So I asked him some questions and this was his reply.

 

 

Q- What development process is followed by most startups

Most of the start-ups follow extreme programming. The reason is that they have a limited amount of amount to practice mature organizational processes. That does a lot of pair programming and relies heavily on TDD. One of the most important things that they do is they do pair rotation on a single story which is a must.

Q- How is the risk planned

There is a process of risk estimation in which we identify and migrate as early. If this process is not followed then they proceed anyway by considering risk as a known factor.

Q- How to they scope the prototype and is it always successful

The scoping of the prototype is based on the pain and gains of the user. We try to focus on the most important need/problem solvers. The prototype is always successful (not in terms of its adaption) as we gain knowledge on what user requires and want from the prototype and what are the next changes that can be foreseen. It’s more of the mindset thing.

Q- How careful do they select the technology

For a prototype, the aim is always to fail fast, recover fast. So, we choose the technology that serves this need in the quickest possible way. But we always apply best software practices while development so that prototype can be extended to a production-ready environment with no additional effort

Q- Do they estimate-foresee the technology cost

To some degree, yes. As I mentioned before, everything starts with the prototype to understand the learnings and the technology can be switched afterward to some extent as well.

Q- How often are the successful

If we are talking about adoption, then I would say out of every 3, 2 would be failing. But in other situations its really hard to figure it out.

Q- What is the most common mistake that the Start-up make

There are many and they are not seasonal but some of the most common ones that could be highlighted are

  • Not doing enough user research and understanding the pains and needs of the customer.
  • Starting with a solution without validating assumptions

Q- How is the quality of the end product

Its almost always production ready material as we are doing rapid prototyping development so the ultimate aim is to deliver production ready material

Q- How well are they aware of the business

They invest a lot of effort into understanding it. It’s a bit hard to measure this but I estimate that 8 out of 10 have strong market research and know the business.

Q- What are the channels where they prove their business ideas

I would say that depends on the idea. Some ideas can be pre validated using social media to figure out the interests of the users or businesses. You can also do ‘pre-sale’ and sell out a feature that is not development. This normally guarantees good business. In some cases, the Business idea is proven with the help of a prototype and then it is circulated to customers to be validated.

Q- How is a successful relationship linked with pitching

Pitching is more towards showing the capability to be able to achieve something while giving benefits to stakeholders/investors as well. As long as the benefit is clear, the pitch is almost always successful.

 Posted by at 9:14 am
Dec 302018
 

Its been almost one year now since I am part of Pakistan Sweden Business Counsel as board member. Our aim is to increase bilateral trade between Sweden and Pakistan and to bridge the business and consumer community both the countries. On November 2018 we organized an event where we invited companies from Pakistan to show case their products and services to Swedish discussion makers. More than 80 people joined us from different IT companies extending to different business domain and in the end there were around 8 different business deals signed off.

Some of the leading companies from Pakistan joined us incuding QorData, Digital dividend, Digital soft, Mercurial Minds, Wanara enterprises, Synavos, DPL and Content Archade.

I think it was a really good networking opportunity and I get to meet people from different companies and different cultures. Here are some of the clicks from the event.

john@guthed.se

john@guthed.se

john@guthed.se

WhatsApp Image 2018-11-28 at 19.59.23

 Posted by at 6:52 pm
Oct 142018
 

If you have created a table in Microsoft SQL and along with a table you have a column with a default value, then the name of the constraint will be generate by the SQL framework unless given. This will be will have some random GUID which will keep it hard to know when you want to drop a column. There could be certain sitations where you want to directly delete the column and there are situations where the column should be dropped without having the knowldge of constaint name.

You can acheive that by using the following sql

 

 

 

 

 Posted by at 10:49 pm
Oct 022018
 

If you are not familiar with the blockchain key concepts i would suggest this previous article.

Blockchain is a technology that enables us to move resources on the provided decentralize database. Now those resources could be anything that provides us value. Its is transparent among the parties or nodes that are involved which makes it more trusted system.

Concept of Blockchain:

The concept of blockchain was introduced in 1991 by a group of scientists who proposed  to timestamp documents digitally in order to validate them. Once a document was timestamp a hash of the complete document was calculated. This hash was used to validate the document. Any tiny change in the document will change the hash and it will invalidate the document. But unfortunately it was not practiced that much until 2009 by Satoshe Nakamoto.  He created the crypto currency Bitcoin using blockchain technology.  

concept of bc

Now that a very important point here about a very general and common misconception  between Bitcoin and blockchain that they’re one of the same things but they’re not.  Bitcoin is a digital currency where as blockchain is a technology used by the bitcoin. 

 

Case study:

In this case study we’re going to discuss a very basic example of money transfer.  The Scenario is where we  want to transfer money from one point to another. Lets say A is in Sweden and wants to transfer 5 dollars to B in Pakistan. As there is no direct line so A will have to use a third party service. The 5 dollars will be transferred via the third party who will transfer the money to B in  Pakistan. Lets say the third party charge some fee and the transfer is done in 2 days.  Now during those two days you don’t have any transparency on what the third part is doing with your money or is the money transferred or not.

case study 1

 

So we have three general problems here that we want to discuss the fee, the time that the third party took and transparency of the third party process. Now lets address these problem in more detail by consider another example. 

 

Long transaction time:

So we have three person A, B and C.  In the very beginning we say that A has 10 dollars. We are going to maintain this in a record which will be our open ledger.. The very first block of the blockchain is called the genesis block.  B has 7 dollars and C has 5 dollars.  Lets say A wants to transfer 7 dollars to B. The address of A B and C are basically the public keys on which the money is transferred. This will be added as a transaction to the ledger and the transaction is performed. B want to transfer 5 dollars to C which will also be added to the ledger and so will our last transaction which is C transfer 5 dollars to A. Now if you see this open ledger is actually the transfer which is done instantly. This open ledger here is called the blockchain  So we have fixed the problem with the long transaction time by instantly maintaining the record in an open ledger but our solution is still like the third party where our ledger is hosted an one place which could be a single point of failure.

 

Transparency:

To address this problem we will distribute the ledger to each node that is involved in the network.  So now we have a distributed block chain. By doing that we eliminated the problem of trust less ledger in fact now its more visible to all the parties and they can validate the ledger at any time. As we have solved the problem by distributing blockchain. we have now another problem of synchronizing the ledger so that is updated on each node on the network. The problem here is that A can say that C transferred 10 dollars to A and add it to its block chain so how will the other nodes know that it was an invalid transaction. 

To understand this part of the system where we will have to look at another example. Lets say this is our network and this the block chain for that network. Lets say A wants to transfer 2 dollars to C. When the transaction occurs a block in created but not yet validated. The difference between creation and validation of block is that anyone can create a block but it has to be validated before it could enter to all the blockchain.  When the block is created it will distributed to these special nodes in the network that will perform validation. These special nodes are called miner. Miner are just ordinary nodes except that have provided high computation speed to compute the validation of the block. Once they validate a block they are rewarded with a small amount. 

validation

For our block we have to calculate the hash of the block which some could say is a really quick operation so why this high computational power is needed. Usually there are some blockchain rules that are enforced on the block validation that the hash of the block should start with 5 zero. This is called the difficulty of the block. I will discuss these topics in detail in my later videos. Lets get back to our block so once our intended block is published to the nodes all the miners will pick up the block and start computing the hash the block. Let say B was able to generate the hash before D so B will add the key that it used to generate the hash, add it to its local block chain and broadcast it to the network.  When A receives the block it will validate the hash by using the same key in the block and once validated A will add the block to its block chain and wait for the next block. 

 

The reward system for the miners is very complex and very important part of the block because it contributes to your currency. I hope you all understand the concept. We touched these concept which I will explain in more detail in my later lectures. 

 Posted by at 2:15 pm
Sep 282018
 

As I mentioned more in my previous blogs about Blockchain lets take it apart and discuss it in a bit more detail. Consider this as a single block of BC. As you can see there are multiple dimensions of this block.  

block

A block in Blockchain:

One of the dimension is the data block which will hold the data part of the Blockchain. This could be any type of data it could list of transactions it could be a document that you could sign or it could be any other business related data.  The second part of the block is the hash part which holds the hash of the block data.  the hash of the data along with the timespan is calculated and the resulting hash is stored in the hash part of the block. The third part of the block is the hash of the previous block. By adding that we ensured that block is connected with its peer block and also it knows the authenticity of the previous block so if anyone tempers with the previous block the hash of the previous block will be changed and we will have inconsistent block hashes. 

In the process of forming a Blockchain the first block of the Blockchain is called the Genesis block Genesis block is the very first block in ever block chain. In the structure of the genesis block the  previous block field is empty as there is no former block.  

forming a blockchain

Genesis Block:

The formalization of the blockchain not only require the genesis block but it also need some rules to obey to add a block to the chain. This is called the consensus protocol. The consensus protocol of the Blockchain dictates how the block is processed which means how we are  going to calculate hash of the block. If any block is tempered than the rest of the blocks in the block chain will be invalid. The only way to invalidate a whole chain is to temper with a block and recalculate all the later blocks .While we are talking about genesis block  here is the Genesis block of Bitcoin as you can see this is the first block of Bitcoin there is no previous block with no transactions to calculate. There is also a reward to calculate the hash in this block which is 50 BTC. It’s a very good way of contributing to the currency that is more explained in concept of mining

 btc block

Now that we know about the BC what if someone tempers with the BC so there will be an invalid BC for all the nodes. To deal with this problem the concept of distributed BC is introduced. So each node in the network will have its own copy of the BC and every change in one of the BC will be authenticated and synced with all the BC within the network. The distributed blockchain is still vulnerable with one famous security problem. So if you invalidate more than 50% of the BC nodes than you have successfully performed the control of the network. You can rewrite the consensus protocol. You can manipulate the transaction history.  But to do that action is not that easy it is really performance intense to perform such an attack on more than half of the network at the same time so for now its really hard to achieve that. If you have control of the more than 50% of the network then you have successfully performed a 51% attack. 

51% Attack:

Now let’s discuss the 51% attack in more detail. Consider that you have a network with multiple nodes. Let us divide the nodes in two colors red and blue. The blue nodes are the good nodes and each of the good nodes have their own copy of the blockchain. The red nodes are the bad nodes or the malicious nodes and they also have a good valid copy of the blockchain as well.  The bad node  then publishes a malicious block to the network and synchronously do that will all the local of the bad nodes. This will in return publish the same block to all the nodes on the network. 

 

 Now the good nodes will also get the same malicious block and there is a chance that they will invalidate the block tagging it as malicious block. But if we have more number of bad nodes on the network so the major nodes in the network will accept the malicious block to be part of the valid Blockchain. The good nodes will think there block chain is invalid as they are less in number and they will sync with the bad Blockchain. So now the whole network is infected resulting in a successful 51% attack. 

Proof-of-Work:

The 51% attack looks really simple to conduct as all you have to do is re-calculate the hashes of the Blockchain and then you can invalidate the whole chain with enough CPU power. To address this problem there is something called Proof-of Work. The proof-of-work dictates that you can calculate the hash but there are certain rules that are applied on a hash. The hash should have some particular number of zeros or it should start with at least ‘x’ number of characters or  numbers.  By intruding such rules the process is generating the hash becomes more difficult and requires more CPU-time.  So you try different key combinations until you reach an acceptable block and then you publish that key with the block so that the other nodes in network can validate your work. The rules for proof of work are different in different currencies or domains. For example Bitcoin accepts 1 block in every 10 minutes, Intense coin accepts 1 block after every 30 seconds. There is another part call the difficulty that is included in the proof of work rules. The more the difficulty is the harder it is to conduct a 51% attack.  

Mining:

let’s say if I am one of the node contributing my processing power to calculate hashes what will I get in return for the  processing power  that I m contributing. There are special nodes who contribute in the processing of the blockchain called the mining nodes. The concept is called mining in blockchain where the nodes receives a published block, calculates hash on that block using a random key until it reach the difficulty and once it has successfully calculated the hash then we can say that we have  successfully mined the block and then its publish to other nodes in the network.  The node will get reward in return of mining which is also in the form of the currency which helps building the blockchain and also it contributes to the currency . Mining is  a process of running the blockchain rules which keeps the Network’s stable safe and secure by processing validating and invalidating Blocks. But the problem with that is that it doesn’t have bright future. In many currencies because it takes too much electricity it takes too much power to calculate the hash  so maybe mining is not the future. There are different solutions alternate Solutions available which I will discuss later.

Summary:

So in this blog i have touched the concept of blocks in blockchain, proof of work, mining and 51% Attack.

 Posted by at 11:29 am