Nov 112019
 

Ok so this is something that I was not really aware on how to do. The assignment was to read the data from the log analytics in azure to show it in one of our application by using c#

The challenge was to understand how to do it. So I started searching google and I found these three very interesting links

https://dev.loganalytics.io/documentation/Tools/CSharp-Sdk

this link is mentioned on these SDKs but it limited to limitations in the OpenAPISpecification. I am going to try that out to see if it works or not. I couldn’t quite understand the domain in this part may be its super easy and obvious but as I said I am not fully aware I think I will skip that,

The other way that I found is mentioned on this link

https://docs.microsoft.com/en-us/rest/api/loganalytics/query/get

this is the more direct way of accessing it but its more to access via power shell or python. There is still no way mentioned here to access it via c# so I found these two links

https://stackoverflow.com/questions/53915236/querying-azure-log-analytics-from-c-sharp-application

https://blogs.technet.microsoft.com/livedevopsinjapan/2017/08/23/log-analytics-log-search-rest-api-for-c/

from the second link I was able to get the bearer token so I use this link to get the token and from the first link I checked how to use the api call.

Initially I was still getting the 443 forbidden so what I did is I created a new app and allowed the log analytics access to that app. I did another run and it still didn’t work. So then I realized that my log analytics workspace should also that app to access the logs. So I have to add the role assignment in the workspace for that app. I did that and after that I got a 404 because the log table that I accessed doesn’t exists so I added another table name ‘Usage’ in the query and it worked fine.

 Posted by at 10:22 pm
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