openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
798 stars 224 forks source link

After logging in to Faasd local, deploying function return error 401 #972

Closed hamedgibago closed 1 year ago

hamedgibago commented 1 year ago

Function need to be deployed in local instance of faasd

Expected Behaviour

Current Behaviour

I installed faasd from folder hack/install.sh. It runs as a service in my Ubuntu linux instance. Although I logged in from this command:

faas-cli login -u admin -p p8bWPnkAsJ0DP7Zl1dhj0Vqeq6PilwySXfuunRZXldIHCPAfs4FukTkv6X00mmz --gateway http://10.62.0.4:8080

And received this message:

WARNING! Using --password is insecure, consider using: cat ~/faas_pass.txt | faas-cli login -u user --password-stdin
Calling the OpenFaaS server to validate the credentials...

WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.
credentials saved for admin http://10.62.0.4:8080

But when I want to deploy my function to the gateway, it says unauthorized access, status code 401 :

sudo faas-cli deploy --image test3/callme --name callme --gateway 10.62.0.4:8080

WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.

unauthorized access, run "faas-cli login" to setup authentication for this server

Function 'callme' failed to deploy with status code: 401

Why do you need this?

Who is this for?

What company is this for? Are you listed in the ADOPTERS.md file?

Are you a GitHub Sponsor (Yes/No?)

Check at: https://github.com/sponsors/openfaas

List All Possible Solutions and Workarounds

Which Solution Do You Recommend?

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

Found deprecated go-style flags in command, translating to new format:
  faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

CLI:
 commit:  cfbfce67e4d8fcacc00775d87931b4bc7229eac7
 version: 0.16.9

Gateway
 uri:     http://127.0.0.1:8080
 version: 0.26.3
 sha:     a128df471f406690b1021a32317340b29689c315

Provider
 name:          faasd
 orchestration: containerd
 version:       0.16.9 
 sha:           e1d90bba609a55ca123d26e5b7e1ccfcfedf3e8f
Your faas-cli version (0.16.9) may be out of date. Version: 0.16.11 is now available on GitHub.
Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:51:00 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:51:00 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy

https://blog.alexellis.io/quickstart-openfaas-cli/

nitishkumar71 commented 1 year ago

Try faas-cli deploy without sudo as you have used faas-cli login without sudo.

hamedgibago commented 1 year ago

@nitishkumar71 Now error changed to 400 and is like this:

WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.

Unexpected status: 400, message: unable to pull image docker.io/test3/callme:latest: cannot pull: failed to resolve reference "docker.io/test3/callme:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Function 'callme' failed to deploy with status code: 400
alexellis commented 1 year ago

It sounds like you haven't pushed your image.

I can't docker pull docker.io/test3/callme:latest

Remember to run faas-cli publish or faas-cli build && faas-cli push on another machine where you have Docker installed.

I now recommend using ttl.sh instead of docker.io, it allows you to push images for testing without authentication or signing up.

Alex

alexellis commented 1 year ago

All the instructions for faasd are in the eBook - it sounds like you would benefit from a copy if you don't already have one, it also explains why we don't building images in the same VM as faasd.

https://store.openfaas.com/l/serverless-for-everyone-else

hamedgibago commented 1 year ago

Sorry for asking this simple question. I installed and ran OpenFaas from faasd, /hack/install.sh file. After building callme, I saw that in my images. I have docker installed in the same virtual machine (Ubuntu). Should I start image that added as test3/callme? How could I call the method after running this docker image?

It just starts with this message:

2023/07/07 13:58:58 Version: 0.2.1  SHA: cd8dc9f4e98049150d8079a74a18cd5a2e311aeb
2023/07/07 13:58:58 Timeouts: read: 5s write: 5s hard: 0s health: 5s.
2023/07/07 13:58:58 Listening on port: 8080
2023/07/07 13:58:58 Writing lock-file to: /tmp/.lock
2023/07/07 13:58:58 Metrics listening on port: 8081

In my sudo faas-cli list command I just see one function named Printer, once I added it accidentally from UI before with some errors, and can see my aimed function callme:

Function                        Invocations     Replicas
printer                         0               0 
hamedgibago commented 1 year ago

@nitishkumar71 Hi, do you have any suggestion?