Posts

Showing posts from March, 2019

Setting up and Deploying eShopOnContainers to Windows Containers

The proper way of setting up your EshopOnContainer on windows containers is executing the following command :- docker-compose -f docker-compose.yml -f docker-compose.windows.yml build Some error you might encounter are, which are misleading and confusing :-  -Service 'webstatus' failed to build: no matching manifest for unknown in the manifest list entries - Client version 1.22 is too old. Minimum supported API version is 1.24, 

helm install

Don't waste time downloading, you can install helm using the following command :- On Linux sudo snap install helm --classic choco install kubernetes-helm

Newtonsoft's CASE Insensitive selecting path to a jason token

The following codes allow us travel select key path regardless of whether you're using upper or lower case. var objectJson = JObject.Parse(validJsonObject); objectJson.GetValue(jsonPathKey, StringComparison.OrdinalIgnoreCase).Value ();

git fatal: unable to read tree

I think the best solution (fast and easy) is to clone the same repo and do a "git fsck".

sklearn - Fast way to do Hot encoding :)

Fast way to do Hot encoding :)

mongodb conection string for kubernetes

Image
The idea is pretty straight foward. With kubernetes you create your own network / cluster. Then u started to put in your database service and give it a name so it can be recognized by apps running on the same network, for example, you want to call your database " mongoserver ". Here we call our service mogoserver, doesnt really matter. But the label DOES. It will based on this criteria to look for your server (under the configuration called, labels (yeap this is important, besides the port number) It has gotta to match. Service configuration file. apiVersion : v1 kind : Service metadata : labels : name : mongoserver name : mongoserver spec : ports : - port : 27017 protocol : TCP targetPort : 27017 selector : name : mongoserver Database pod configuration file  kind : Pod apiVersion : v1 metadata : labels : name : mongoserver name : mongoserver spec : volumes : ...

Adding filter to docker swarm task REST API

Here we try to pass the correct filter when calling docker's swarm service task REST API. In the docs it says, we should be passing in 'map[string][] string] = i am interpreting it as a map of string to strings array. Anyways, here is an example of using service name as the filter. Notice  filter and the correc json block shown below :- mydocker-REST-service/v1.35/tasks? filters = {" service ":{" lalaland ":true} }

Golang - protoc doesn't generate stub for client and server

In case you bump into this issue, you can try the following command. This is kinda tricky, as sometimes you executed the code successfully but didn't generate stub for client and server Notice i bolded the loggingStream - this must be a valid directory that you need to specify. For example, you might have the following directory -src    - server    - client    - loggingStream (this is where your proto files resides) protoc -I loggingstream / l oggingstream /loggingStream.proto --go_out=plugins=grpc: loggingstream or you could just go into the proto directory and  protoc -- go_out = plugins = grpc :. loggingStream . proto

Quick setup using gRpc

Install the tools go get -u github.com/golang/protobuf/protoc-gen-go Client side  const (      address = "localhost:50051"      defaultName = "world" ) func main () {      // Set up a connection to the server.      conn , err := grpc. Dial (address, grpc. WithInsecure ())      if err != nil {         log. Fatalf ( "did not connect: %v" , err)     }      defer conn. Close ()      c := pb. NewGreeterClient (conn)      // Contact the server and print out its response.      name := defaultName      if len (os.Args) > 1 {          name = os.Args[ 1 ]     }      ctx , cancel...

Docker swarm - creating a service with a specific share memory requirement or constraint.

Docker swarm - creating a service with a specific share memory requirement or constraint. sudo docker service create --replicas 1 -p 10000:8080 -p 11000:55555 --reserve-memory=2g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin  --mount type=tmpfs, dst=/dev/shm,tmpfs-size=1000000000 --name=solace_swarm solace/solace-pubsub-standard

golang serving up files example

This is an example to serve file over http2. func index_main (w http.ResponseWriter, r *http.Request) {     http. ServeFile (w, r, "your_file_name.pdf" ) } func main () {      var srv http.Server      srv.Addr = ":8002"      //Enable http2     http2. ConfigureServer (&srv, nil )     http. HandleFunc ( "/" , index_main)      err := srv. ListenAndServeTLS ( "certs/localhost.cert" , "certs/localhost.key" )      if err != nil {         fmt. Println (err)     } }

golang http2 implementations requires tls / ssl

Yes you need to generate your ssl cert if you want to use Golang http2 features, otherwise it will just fall back to http:1.1 Use the code sample below and you're good to go :-

git diff a specific file

To do a git diff for specific file, you can use "git diff -- filename"  Example, git diff 5b99a9d21cf44029a33810c9661d3f23354effd0 -- Dockerfile

moving docker programdata to another folder

Docker's program data is huge. Could take up as much as 30g. So you need to place it in a drive that has alot of space. You can do this by Settings -> Daemon -> then update the following. Wish it was that simple, eh? Nope. you have to open up the file on your folder here : %programdata%\docker\config\daemon.json (windows) or /etc/docker/daemon.json   "data-root": "d:\\docker", An example would look something like this :- 

kubectl command that delete all

The most powerful command of the week. Delete all in a single command :) kubectl delete --all deployments,pv,pvc,svc,ing,pods,daemonsets,replicasets

Solving Sonarqube :- Project was never analyzed. A regular analysis is required before a branch analysis

This means :- sonarqube don't have any info about your project. you need to setup your project in sonarqube. The end goal here is to get your login - which is a guid for example,  "9f6cf20347297da17ce4591b1d2ada820a30d23e" and your project key which is a unique alphanumeric value to differentiate your project. Goto Create Project - > Generate a token -> Provide  your project name -> Select C# or VB or Java (when prompt Run analysis on your project" At the end of the dialog you will get Login :- which is a has and Project Key. Then you pass those info into MsBuild or whatever build tools you currently using.

Testing out websocket client and server

Websocket server  To spin up a server that serve ws request, you can use the following code Run "dep init" Run "dep ensure -update" Websocket client npm install - g wscat wscat -c ws://localhost:8002 You will see that you're connected. 

Installing tf2

Installing using pip. pip install tf-nightly-2.0-preview Using docker with tf2  docker pull tensorflow/tensorflow                  # Download latest image  docker run -it -p 8888:8888 tensorflow/tensorflow

Creating a dockerfile for golang with dep as the dependency manager

This is a sample dockerfile that you can use to build a docker image using dep as the package manager. FROM golang:1.8 AS builder ADD https://github.com/golang/dep/releases/download/v0.5.1/dep-linux-amd64 /usr/bin/dep RUN chmod +x /usr/bin/dep # Copy the code from the host and compile it WORKDIR $GOPATH/src/github.com/appcoreopc/gTradeApp COPY Gopkg.toml Gopkg.lock ./ RUN dep ensure --vendor-only COPY . ./ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /app . FROM scratch COPY --from=builder /app ./ ENTRYPOINT ["./app"]

react :- function as children component

The following are example for using function as child component. It loads whatever child component within a markup and render it better or diffently.

react higher order components

Here is a sample of higher order component.

a simple react component - dumb and smart component

Just to keep thing handy for me to copy and paste : -

Golang interface using value / pointer ref

Golang interface the important thing to know before writing your class / type as pointer or value class. https://play.golang.org/p/173qSbZ5FeL

Best react link i have encounter today

This is the best link for what i wanna be doing this week. Upskill myself to the next level. https://facebook.github.io/create-react-app/docs/adding-typescript

bitnami mongodb starts on /opt/bitnami/mongodb

Quickly spinning up a kubernetes volume and volume claim

Adding some docs around how to spin up a volume and volume claim quickly.

Getting a regex for json that works with newline

Here is a regex that able to look up json objects in a string regardless of newlines. Please have a look here for a demo :-

kubernetes dev

The following command should help dev to be able to spin up image for deployment to a kubernetes clusters. Your image must be be running or listening to a port.  You don't have to expose it on Dockerfile but the services needs to be up and listening to a port. Simple deployment configuration apiVersion : extensions/v1beta1 kind : Deployment metadata : name : gowebapi spec : replicas : 1 template : metadata : labels : app : gowebapi spec : containers : - name : kepunggomux1 image : kepung/gomux1 ports : - containerPort : 9001 name : my-name Simple service deployment. Here we will use nodeport. Nodeport confiiguration opens up a port on every nodes so that you can talk to them. ClusterIP opens up a port that you or your application talks to in a local cluster. In our scenario, we will use NodePort. Here we wil use 30001 to talk to application (deplo...