golang: dynamic type in a json field

We had an experience where the type of a field change base on certain conditions. We think this is bad, but we have to support it. Here’s how. You’ll have to specify the field type as an interface. type P struct { T interface{} `json:"t"` } After that, you’ll need to use switch to determine the type. In our case, we needed it as int. var i int var p P s := `{"t": "3460"}` // should also work with // s := `{"t": 3460}` if err := json....

November 7, 2018 · 1 min · Zakatell Kanda

a possible list to think about when writing a test.

When writing test, the documentation that the API you are integrating will only list all the good values that they intend to deliver to you or the other way around. What I observed from working with my colleague Harmen is this: A negative test A positive test for the happy path An empty input A malformed data I might add more example in the future but for now, I’ll try to follow this guideline....

November 3, 2018 · 1 min · Zakatell Kanda

installing prometheus in k8s cluster with helm

Prerequisite: A cluster with RBAC enabled. Have enough capacity in the cluster Install Helm: kubectl create serviceaccount tiller --namespace kube-system kubectl create clusterrolebinding tiller-rb --clusterrole=cluster-admin --serviceaccount=kube-system:tiller helm init --service-account tiller Get the values.yaml from here Edit some things that you want to tweak, for us, we change the CPU limit to a lower value. Then just install Prometheus: helm install -f values.yaml --name prometheus stable/prometheus Ideally, this should be installed in another namespace but we will keep it simple for now....

September 4, 2018 · 1 min · Zakatell Kanda

our experience in resizing an ebs volume in ec2 instances.

Increasing disk space without downtime. So in our team, we had to resize an instance disk because it’s getting full, this is our experience. For the first time we search on how to do this, there are many articles written about it and most of them require to stop the system and detaching a volume. But there must be a real doc from aws itself, that is most likely up to date....

March 19, 2018 · 2 min · Zakatell Kanda

disabling udp in memcached.

One of our server provider which is running in Germany have a bot that scans for an open port, this is to prevent other humans/robot in abusing services that are open on the internet. For us, they determined that our memcached port is open, we were confused at first how could this happen, we were sure that this is blocked via iptables. It turns out memcached by default listens to both TCP and UDP, since we don’t have yet a firewall for UDP, we opted for something simpler and to disable UDP on memcached(we know we only use TCP)....

March 7, 2018 · 1 min · Zakatell Kanda