projectriff / riff

riff is for functions
https://projectriff.io
Apache License 2.0
799 stars 64 forks source link

riff system install --node-port error: stat /root/.kube/config: no such file or directory #1339

Closed reachyunsong closed 5 years ago

reachyunsong commented 5 years ago

I use this tutoral: https://projectriff.io/docs/getting-started/minikube/ And I run knative using riff on minikube. riff system install --node-port could't work.


Install riff and Knative system components.

If an `istio-system` namespace isn't found, it will be created and Istio components will be installed.
Use the `--node-port` flag when installing on Minikube and other clusters that don't support an external load balancer.
Use the `--manifest` flag to specify the path or URL of a manifest file which provides the URLs of the kubernetes configuration files of the components to be installed. The manifest file contents should be of the following form:

    manifestVersion: 0.1
    istio:
    - https://path/to/istio-release.yaml
    knative:
    - https://path/to/build-release.yaml
    - https://path/to/serving-release.yaml
    - https://path/to/eventing-release.yaml
    namespace:
    - https://path/to/buildtemplate-release.yaml

Note: relative file paths or http/https URLs may be used in the manifest.

Usage:
  riff system install  [flags]

Flags:
      --force             force the install of components without getting any prompts
  -h, --help              help for install
  -m, --manifest string   manifest of kubernetes configuration files to be applied; can be a named manifest (latest, nightly, stable) or a path of a manifest file (default "stable")
      --node-port         whether to use NodePort instead of LoadBalancer for ingress gateways

Global Flags:
      --kubeconfig path   the path of a kubeconfig (default "~/.kube/config")
      --master address    the address of the Kubernetes API server; overrides any value in kubeconfig

Error: stat /root/.kube/config: no such file or directory```
sbawaska commented 5 years ago

@reachyunsong The riff cli needs access to your kubernetes cluster and it expects to find ~/.kube/config. Are you running riff in a container?

reachyunsong commented 5 years ago

I don't think I run riff in a container, I just use this command to run it.

$ riff system install --node-port
trisberg commented 5 years ago

do you have kubectl installed and are able to use it to connect to your cluster?

reachyunsong commented 5 years ago

yes, I think so. @trisberg

$ sudo kubectl get nodes
NAME       STATUS   ROLES    AGE     VERSION
minikube   Ready    <none>   7h57m   v1.14.0
trisberg commented 5 years ago

I wonder why you run kubectl with sudo? Look for where the .kube/config is created.

reachyunsong commented 5 years ago

@trisberg I first installed kubectl following the official guide, but met this error:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

I haven't find solution so I use another tutorial but it always need sudo. And .kube/config is in my root directory.

$ locate .kube/config
/users/yunsong/.kube/config
sbawaska commented 5 years ago

@reachyunsong not ideal, but if you sudo the riff command, it will be able to find kube/config.

I would highly recommend that you re-install minikube & kubectl cli by following official instructions and then start the minikube cluster using instructions from projectriff

reachyunsong commented 5 years ago

Thank you, @sbawaska I re-install minikube & kubectl as you mentioned, and now I think I can install knative successfully, but couldn't create function.....

$ kubectl get pod --all-namespaces
NAMESPACE          NAME                                            READY   STATUS    RESTARTS   AGE
istio-system       cluster-local-gateway-5bf5488bb-2jfws           1/1     Running   0          4m39s
istio-system       istio-citadel-78fd647cf-zm5fn                   1/1     Running   0          4m46s
istio-system       istio-egressgateway-5547468b8d-62fww            1/1     Running   0          4m49s
istio-system       istio-galley-64ddbbff8b-djp7s                   1/1     Running   0          4m49s
istio-system       istio-ingressgateway-686d54b4bf-zdpqs           1/1     Running   0          4m49s
istio-system       istio-pilot-7c86c7cb8b-7hzmd                    2/2     Running   0          4m47s
istio-system       istio-policy-64b5ff6bd8-m268x                   2/2     Running   0          4m48s
istio-system       istio-sidecar-injector-6956c47586-k7dmq         1/1     Running   0          4m46s
istio-system       istio-telemetry-55b97c59c4-5cpw8                2/2     Running   0          4m48s
knative-build      build-controller-77cbbc9888-rcq25               1/1     Running   0          119s
knative-build      build-webhook-64f9bbc7c9-t5c57                  1/1     Running   0          119s
knative-eventing   eventing-controller-8b87fcbb5-5jzf8             1/1     Running   0          104s
knative-eventing   in-memory-channel-controller-c48986657-rh5fd    1/1     Running   0          94s
knative-eventing   in-memory-channel-dispatcher-5f68fff98d-hspr8   2/2     Running   1          91s
knative-eventing   webhook-6dc88dbfb4-kg2bg                        1/1     Running   0          104s
knative-serving    activator-5956447886-dtjz7                      2/2     Running   0          115s
knative-serving    autoscaler-5cb94cdb69-rczg9                     2/2     Running   0          115s
knative-serving    controller-c4c56dd6d-6wnvr                      1/1     Running   0          114s
knative-serving    webhook-6cf887c686-vjmfw                        1/1     Running   0          113s
kube-system        coredns-fb8b8dccf-7dfpc                         1/1     Running   0          9m8s
kube-system        coredns-fb8b8dccf-mbg8v                         1/1     Running   0          9m8s
kube-system        etcd-minikube                                   1/1     Running   0          8m21s
kube-system        kube-addon-manager-minikube                     1/1     Running   0          8m8s
kube-system        kube-apiserver-minikube                         1/1     Running   0          7m58s
kube-system        kube-controller-manager-minikube                1/1     Running   0          8m15s
kube-system        kube-proxy-hzvwl                                1/1     Running   0          9m7s
kube-system        kube-scheduler-minikube                         1/1     Running   0          8m17s
kube-system        storage-provisioner                             1/1     Running   0          8m57s
$ riff function create square \
>   --git-repo https://github.com/projectriff-samples/node-square  \
>   --artifact square.js \
>   --verbose
Applied default --image="docker.io/dockeryunsong/square"
Waiting for LatestCreatedRevisionName
Waiting on function creation: checkService failed to obtain service status for observedGeneration 1
Waiting on function creation: function creation incomplete: service status unknown: RevisionMissing
LatestCreatedRevisionName available: square-gsj2k
default/square-6s262-pod-dc50b6[build-step-git-source-0]: {"level":"warn","ts":1561938341.9878285,"logger":"fallback-logger","caller":"logging/config.go:65","msg":"Fetch GitHub commit ID from kodata failed: \"ref: refs/heads/upstream/release-0.5\" is not a valid GitHub commit ID"}
default/square-6s262-pod-dc50b6[build-step-git-source-0]: {"level":"error","ts":1561938347.0181088,"logger":"fallback-logger","caller":"git-init/main.go:52","msg":"Unexpected error running git [fetch --depth=1 --recurse-submodules=yes origin master]: exit status 128\nfatal: unable to access 'https://github.com/projectriff-samples/node-square/': Could not resolve host: github.com\n","stacktrace":"main.runOrFail\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:52\nmain.main\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:91\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:200"}
default/square-6s262-pod-dc50b6[build-step-git-source-0]: {"level":"error","ts":1561938352.0422978,"logger":"fallback-logger","caller":"git-init/main.go:41","msg":"Error running git [pull --recurse-submodules=yes origin]: exit status 1\nfatal: unable to access 'https://github.com/projectriff-samples/node-square/': Could not resolve host: github.com\n","stacktrace":"main.run\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:41\nmain.main\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:95\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:200"}
default/square-6s262-pod-dc50b6[build-step-git-source-0]: {"level":"error","ts":1561938352.0445173,"logger":"fallback-logger","caller":"git-init/main.go:52","msg":"Unexpected error running git [checkout master]: exit status 1\nerror: pathspec 'master' did not match any file(s) known to git.\n","stacktrace":"main.runOrFail\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:52\nmain.main\n\t/go/src/github.com/knative/build/cmd/git-init/main.go:96\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:200"}
default/square-6s262-pod-dc50b6[build-step-git-source-0]: {"level":"info","ts":1561938352.0445998,"logger":"fallback-logger","caller":"git-init/main.go:101","msg":"Successfully cloned \"https://github.com/projectriff-samples/node-square\" @ \"master\" in path \"/workspace\""}
gyliu513 commented 5 years ago

@skeeey can you help check and give some comments here?

jldec commented 5 years ago

@reachyunsong, it appears from the error message that your environment could not resolve github.com to pull the source code for the function.

Could not resolve host: github.com

Instead of building directly from GitHub you could try to clone the repo to your own machine and then create the function using '--local-path' instead of '--git-repo'

git clone https://github.com/projectriff-samples/node-square.git
cd node-square

riff function create square \
--local-path .  \
--artifact square.js \
--verbose

The local-path option assumes that you have initialized the namespace with your docker credentials, and are running a local docker daemon which is logged-in using those credentials.

skeeey commented 5 years ago

@reachyunsong I think @jldec is right, you should make sure your environment can visit the github.com successfully, in my environment, I can run the example successfully, here is my log

root@perftest4:~# riff function create square \
>   --git-repo https://github.com/projectriff-samples/node-square  \
>   --artifact square.js \
>   --verbose
Applied default --image="docker.io/skeeey/square"
Waiting for LatestCreatedRevisionName
Waiting on function creation: checkService failed to obtain service status for observedGeneration 1
Waiting on function creation: function creation incomplete: service status unknown: RevisionMissing
LatestCreatedRevisionName available: square-5pflg
default/square-twqnb-pod-386787[build-step-git-source-0]: {"level":"warn","ts":1562564734.4276793,"logger":"fallback-logger","caller":"logging/config.go:65","msg":"Fetch GitHub commit ID from kodata failed: \"ref: refs/heads/upstream/release-0.5\" is not a valid GitHub commit ID"}
default/square-twqnb-pod-386787[build-step-git-source-0]: {"level":"info","ts":1562564734.8910928,"logger":"fallback-logger","caller":"git-init/main.go:101","msg":"Successfully cloned \"https://github.com/projectriff-samples/node-square\" @ \"master\" in path \"/workspace\""}
default/square-twqnb-pod-386787[build-step-analyze]: WARNING: image 'docker.io/skeeey/square' not found or requires authentication to access
default/square-twqnb-pod-386787[build-step-analyze]: WARNING: image 'docker.io/skeeey/square' has incompatible 'io.buildpacks.lifecycle.metadata' label
default/square-twqnb-pod-386787[build-step-build]: -----> Node.js Buildpack 0.0.4
start to build and export image ...
default/square-5pflg-deployment-5968f87b9c-6xg9l[user-container]: Node started in 148ms
start the container and invoke it ...
riff function create completed successfully
Deployed image "index.docker.io/skeeey/square@sha256:edaea2004c982afdfd62e57196e5f90694347e63de323f24702db4b8d3b960ec"
reachyunsong commented 5 years ago

@jldec Thank you, I followed step you mentioned, but met this error, is this due to docker configuration?

~/node-square$ riff function create square \
> --local-path .  \
> --artifact square.js \
> --verbose
Applied default --image="docker.io/dockeryunsong/square"
Using user-provided builder image projectriff/builder:0.2.0
Pulling builder image projectriff/builder:0.2.0 (use --no-pull flag to skip this step)
2019/07/16 21:13:27 Unable to read "/users/yunsong/.docker/config.json": open /users/yunsong/.docker/config.json: no such file or directory
2019/07/16 21:13:28 Unable to read "/users/yunsong/.docker/config.json": open /users/yunsong/.docker/config.json: no such file or directory

Error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/create?fromImage=projectriff%2Fbuilder&tag=0.2.0: dial unix /var/run/docker.sock: connect: permission denied
reachyunsong commented 5 years ago

@skeeey Thank you~~~ I‘ll check my environment again.

jldec commented 5 years ago

as i mentioned above,

The --local-path option assumes that you have initialized the namespace with your docker credentials, and are running a local docker daemon which is logged-in using those credentials.

To install docker, please see here

scothis commented 5 years ago

@reachyunsong please reopen if you still having issues