title: go-micro kubernetes greeter example - unable to reach greeter api service
body: <p>I'm trying to get this go-micro greeter example working on Kubernetes <a href="https://github.com/micro/examples/tree/master/greeter" rel="nofollow noreferrer">https://github.com/micro/examples/tree/master/greeter</a></p>
  
  <p>I can run this locally in docker fine. However when I attempt to access the greeter api service via Kubernetes (http://{{external-ip}}/greeter/say/hello), I get the error: {"id":"go.micro.api","code":500,"detail":"not found","status":"Internal Server Error"}</p>
  
  <p>For the sake of troubleshooting I've simplified the scenario, I simply want to be able to make a call via the micro api to a go-micro api service. Below is my setup:</p>
  
  <p>api.go</p>
  
  <pre><code>package main
  
  import (
      "github.com/micro/go-micro"
      api "github.com/micro/micro/api/proto"
      "log"
      k8s "github.com/micro/kubernetes/go/micro"
  
      "context"
  )
  
  type Say struct {
  }
  
  //I just want to access this via the micro api on k8s via services external ip
  func (s *Say) Hello(ctx context.Context, req *api.Request, rsp *api.Response) error {
      rsp.StatusCode = 200
      rsp.Body = "Hello"
      return nil
  }
  
  func main() {
      service := k8s.NewService(
          micro.Name("default.greeter-api"),
      )
  
      service.Init()
  
      service.Server().Handle(
          service.Server().NewHandler(
              &amp;Say{},
          ),
      )
  
      if err := service.Run(); err != nil {
          log.Fatal(err)
      }
  }
  </code></pre>
  
  <p>micro-api-deployment.yml</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: micro
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: micro
    template:
      metadata:
        labels:
          app: micro
      spec:
          containers:
          - name: micro
            image: microhq/micro:kubernetes
            args:
              - "api"
              - "--handler=rpc"
              - "--namespace=default"
            env:
            - name: MICRO_API_ADDRESS
              value: ":80"
            ports:
            - containerPort: 80
              name: api-port
  </code></pre>
  
  <p>micro-api-svc.yml</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: micro
  spec:
    type: LoadBalancer
    ports:
    - name: api-http
      port: 80
      targetPort: "api-port"
      protocol: TCP
    selector:
      app: micro
  </code></pre>
  
  <p>greet-deployment.yml</p>
  
  <pre><code>apiVersion: apps/v1beta1
  kind: Deployment
  metadata:
    name: greeter-api
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: greeter-api
    template:
      metadata:
        labels:
          app: greeter-api
      spec:
          containers:
          - name: greeter-api-service
            image: greeter-api:latest
            imagePullPolicy: Always
            command: [
              "./greet",
              "--selector=static",
              "--server_address=:8080",
            ]
            ports:
            - containerPort: 8080
              name: greet-port
  </code></pre>
  
  <p>greet-svc.yml</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: greet
    labels:
      app: greet
  spec:
    ports:
    - port: 8080
      protocol: TCP
    selector:
      app: greet
  </code></pre>