Geting started with blockchain technology

Overview

Blockchain is a shard immutable and deterministic ledger, a ledger in accounting system is a bookkeeping containing entries transaction and blances. in technical words a ledger is a key value system that follow a given data sracture

A shared ledger means that the instance of your key value system is running in debritued nodes managed by the blockchain comunituy with no single authority, every can become part of the blockchain community and host a node of a ledger.

Immutable leadger means that when the transaction is validated by the node, it is impossible the change it, it gives us the guartie that no one is going to alter your data, in blockchain system there is no update or delete, it is alwyas a new transaction.

Determinism means that all nodes participating in the network reach exactly the same state if they enact the same operational steps, in general determinsm in computer sience os the where the futur state of the system depends entirely of the pirior state.

Blockchain reach the determinsm by establishing a concensus mecanism.

Blockchain data structure

The structure of the block and links between different blocks in the chain can differ form one network to onther, but in general the structure of the block contains block number witch is the identifier of the block nonce witch is integer that will be used to solve challange Data is the content of the block the hash of the previous block and the hash of the current block witch will be calculated by concatenating all he the previous part of the block to validate the block a miner (a node of the blockchain network) must solve a computational challange, for example increment the nonce until the calcualted has of the block will meet the given creiteria (for example start with five zeros) this validation is called the proof of work, a miner will consume a power and compute to solve the challange and vallidate the state of the network, as a result of its job it will be rewarded (payment for the job)

image

It will take a couple of minutes to install a single node Kubernetes cluster

image

When Kubernetes icon turns green, your single node cluster is Saucerful installed

Install kubectl

To communicate with any Kuberenetes cluster including single node cluster we need to install cubicle witch is the Kubernetes CLI.

To install Kubectl to your desktop, please refer to the link below and choose the installation according to your operating system

Our first command aims to display all pods in the system namespaces, the system namespaces contains kubernetes system components

  kubectl get pod --namespace kube-system

The output of the command should be something like this

image

Kubernetes API Server

API Server is a RESTful API over http using json, it is the only way to interact with the cluster, kubectl CLI uses API server to interact with the cluster.

You can check the the http request made by kubectl command using -v6 option

  kubectl get pod --namespace kube-system -v8

Kuberentes API

Kubernetes API is a collection of primitive that represent the state of the system, we can manage the state of system primitively using kubectl commands or declartivey using declarative yaml files.

You can check the list kubernetes API and their version using the command below.

  kubectl kubectl api-resources

Key palyers Kubernetes Objects

image

Pod

The pod is the most basic unit of work and scheduling in Kubernetes, it contains one or more containers and it is your application or service.

The pod is ephemeral, it is never replayed, Kubernetes’ job is keeping your Pods running, more specifically keeping the desired state.

Controllers

The job of the controllers is to create pods, by ensuring the desires, states, one of the more important controller is Replica Set that ensure the number of desired Pod (a specified number of exact copies) is up and running, if an instance goes down, the job of the controller is to create a new instance of the application to ensure the desired state.

Deployment is the anther type of controller, is a higher abstraction of the ReplicSet, it manges both the Replica Set and Pod specified. Deployment can rollout changes of the Replica Set

DameanSet: is a controller that ensures one instance of the pod is running on each node of the cluster Job: is a controller that manages the task as it runs to completion CronJob: is a controller that manages to run scheduled jobs

Service

The job of service in cabinets is to add persistency to the ephemeral mode, it acts as a load balancer, the back-end pool of the pod is automatically updated by the creation of a deletion of pods by the controller. The service offers an IP address and DNS name of the application deployment

image

Volumes

Service API object adds presitency to access to formal pods, Volumes add the presestensy to ephemeral storage, as we know a container’s writable Layer is deleted when the (container / pod) is deleted any data stored in container writable layers is lost.

Persistent Volume (usually a volume outside of the cluster) allow to add persistence to data stored by Pod, the persistent volume is an external volume mounted to the pod, when the pod is deleted and recreated, the data the new instance, mount the same volume and has access to the data created by the previous instance, Volumes in kuberentes allow also to share data between different replicas of the same deployment.

Namespaces in kuberentes

Kubernetes is multi-tenant platform, namespaces provides a mechanism for isolating groups of resources within a single cluster, this isolation can be done by application (every application has its own namespace) or by environment (namespace by environment production, staging,…) access to namespaces can be secured using roles and roles binding.

by default Kubernetes come with two namespaces

You can create a new namespace using kubectl command

kubectl create namespace hello-world-npr-staging
# get the list of namespaces
kubectl get namespaces