I'm using go-micro for my applications, currently I'm using consul for local development, however I'm using Kubernetes when I deployed my service into staging and production environment. I read about Telepresence[1] which is basically a dual proxy allowing you to access you dependency on Kubernetes services. So I tried to use Telepresence. This local code was deployed using Telepresence create new deployment with test namespaces and allow that to access another service in different namespace within the same cluster. However my service have this kind of error:
2019/01/29 13:11:18 stat
/var/run/secrets/kubernetes.io/serviceaccount: no such file or direct
Which is kind of weird because I can use the same approach when my service don't need to have any dependency in the Kubernetes cluster. As another note I'm using GKE on Google Cloud with RBAC for each namespaces.
This is because, by default go micro with kubernetes will try to find the default service account needed to be able to deploy the application in the cluster. This is applicable only if we use Telepresence in new deployment mode. Because Telepresence will create a new deployment to open a proxy connection so that we will be able to access all of the cluster's resources.
I managed to run my code using telepresence with go-micro, all I should do is create:
sudo mkdir -p /var/run/secrets/kubernetes.io/
and then use symlink:
sudo ln -s $TELEPRESENCE_ROOT/var/run/secrets/kubernetes.io/serviceaccount/ /var/run/secrets/kubernetes.io
and then run:
go main.go --selector=static --server_address=0.0.0.0:<port>
The static flag here is important [1]
References: 1. https://github.com/micro/go-plugins/tree/master/selector/static