go micro application always getting "/greeter-srv" no such file or directory kubernetes

7/22/2020

I have trying to install go micro application, but its always getting below error,

`   Type     Reason     Age                 From               Message
  ----     ------     ----                ----               -------
  Normal   Scheduled  <unknown>           default-scheduler  Successfully assigned default/greeter-7d7c644bdc-dk5q2 to minikube
  Normal   Pulling    9s (x4 over 3m10s)  kubelet, minikube  Pulling image "12345.dkr.ecr.ap-south-1.amazonaws.com/micro:latest"
  Normal   Pulled     9s (x4 over 61s)    kubelet, minikube  Successfully pulled image "460378929709.dkr.ecr.ap-south-1.amazonaws.com/micro:latest"
  Normal   Created    8s (x4 over 59s)    kubelet, minikube  Created container greeter
  Warning  Failed     8s (x4 over 56s)    kubelet, minikube  Error: failed to start container "greeter": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/greeter-srv\": stat /greeter-srv: no such file or directory": unknown
`

i have used this doc for installation, as per this doc installed deppentency etcd and NAT , and its running fine. Any one is created this micro application in kubernetes, i have doubt my Dockerfile it self have any issue or yaml, can u clear me if i run any wrong , i did not get any correct doc for kubernetes installation from site.

I used below yaml file for kubernetes deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: default
  name: greeter
spec:
  replicas: 1
  selector:
    matchLabels:
      app: greeter-srv
  template:
    metadata:
      labels:
        app: greeter-srv
    spec:
      containers:
        - name: greeter
          command: [
        "/greeter-srv",
      ]
          image: 12345.dkr.ecr.ap-south-1.amazonaws.com/micro:latest
          imagePullPolicy: Always
          ports:
          - containerPort: 8080
            name: greeter-port
          env:
          - name: MICRO_SERVER_ADDRESS
            value: "0.0.0.0:8080"
          - name: MICRO_BROKER
            value: "nats"
          - name: MICRO_BROKER_ADDRESS
            value: "nats-cluster"
          - name: MICRO_REGISTRY
            value: "etcd"
          - name: MICRO_REGISTRY_ADDRESS
            value: "etcd-cluster-client"
      imagePullSecrets:
      - name: ap-south-1-ecr-registry

Dockerfile

  FROM alpine:latest
RUN apk --no-cache add make git go gcc libtool musl-dev
WORKDIR /go/src/
# Configure Go
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH

RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin

COPY . .
COPY greeter-srv /go/src/
RUN make

RUN apk add ca-certificates && \
    rm -rf /var/cache/apk/* /tmp/* && \
    [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

ENTRYPOINT ["/greeter-srv"]

service file name greeter-srv

import (
    "github.com/micro/go-micro/v2"
)
func main() {
    service := micro.NewService(
        micro.Name("greeter")
    )
    service.Init()
    service.Run()
}

I have build with above docker file then tag and push to aws ecr , then i used that registory in kubernetes yaml file.

-- shufilkhan
docker
kubernetes

2 Answers

7/25/2020

Your Dockerfile caused the issue change the ENTRYPOINT to /go/src/greeter-srv

-- Dashrath Mundkar
Source: StackOverflow

7/25/2020

stat /greeter-srv: no such file or directory" this is due to Dockerfile mensioned WORKDIR /go/src/ and ENTRYPOINT ["/greeter-srv"] this is wrong , should be used ENTRYPOINT ["/go/src/greeter-srv"]

-- shufilkhan
Source: StackOverflow