openfaas / faasd

A lightweight & portable faas engine
https://store.openfaas.com/l/serverless-for-everyone-else
Other
3.01k stars 214 forks source link

Tutorial Problems #132

Closed oconnore closed 3 years ago

oconnore commented 3 years ago

I think all of the tutorials I've found are quite detailed and helpful for the use cases they describe. However, I've been having trouble installing faasd over the last few days -- probably because my install is slightly different (I'm trying to install on a vanilla ubuntu on AWS).

The best tutorial I've been able to find is for installing lightweight services on a raspberry pi, but there are significant differences between the arm and the x86 ubuntu I'm running on AWS. I also found the one about using terraform for DigitalOcean, but I don't have a digital ocean account.

I think I would benefit from just a description of what dependencies faasd requires, and tips on how to get those.

Right now I have runc:1.0.0~rc10-0ubuntu1, containerd:1.3.3-0ubuntu2, cni:0.9.8, and bridge-utils installed. I'm a bit confused because it says to not have docker installed, but right now I'm stuck on the install step where it says:

ubuntu@ip-10-0-0-26:~$ sudo ./faasd install
2020/11/21 17:54:37 Writing to: "/var/lib/faasd/secrets/basic-auth-password"
2020/11/21 17:54:37 Writing to: "/var/lib/faasd/secrets/basic-auth-user"
Error: open docker-compose.yaml: no such file or directory

I'm also not sure if all of these commands are required when I'm not on a raspi:

# One-off
sudo modprobe br_netfilter && \
sudo sysctl net.bridge.bridge-nf-call-iptables=1

# Make it permanent
echo "br_netfilter" | sudo tee -a /etc/modules-load.d/modules.conf

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf

What are those actually doing?

oconnore commented 3 years ago

I found those files in the repo and was able to make more progress by cloning the repository:

ubuntu@ip-10-0-0-26:~$ git clone https://github.com/openfaas/faasd.git faasd_wd
Cloning into 'faasd_wd'...
remote: Enumerating objects: 162, done.
remote: Counting objects: 100% (162/162), done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 3610 (delta 76), reused 54 (delta 23), pack-reused 3448
Receiving objects: 100% (3610/3610), 5.44 MiB | 3.92 MiB/s, done.
Resolving deltas: 100% (1331/1331), done.
ubuntu@ip-10-0-0-26:~$ cd faasd_wd
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo ../faasd install
2020/11/21 18:13:26 File exists: "/var/lib/faasd/secrets/basic-auth-password"
2020/11/21 18:13:26 File exists: "/var/lib/faasd/secrets/basic-auth-user"
Error: unable to stat /usr/local/bin/faasd, install this binary before continuing
ubuntu@ip-10-0-0-26:~/faasd_wd$ mv ../faasd ./
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo ./faasd install
2020/11/21 18:13:49 File exists: "/var/lib/faasd/secrets/basic-auth-password"
2020/11/21 18:13:49 File exists: "/var/lib/faasd/secrets/basic-auth-user"
Error: unable to stat /usr/local/bin/faasd, install this binary before continuing
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo cp faasd /usr/local/bin/faasd
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo ./faasd install
2020/11/21 18:14:07 File exists: "/var/lib/faasd/secrets/basic-auth-password"
2020/11/21 18:14:07 File exists: "/var/lib/faasd/secrets/basic-auth-user"
Login with:
  sudo cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
Calling the OpenFaaS server to validate the credentials...
Cannot connect to OpenFaaS on URL: http://127.0.0.1:8080. Get http://127.0.0.1:8080/system/functions: dial tcp 127.0.0.1:8080: connect: connection refused
oconnore commented 3 years ago

faasd-provider was down after the install. Restarting it brought it back up, but the error message is still there

ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl status faasd-provider
● faasd-provider.service - faasd-provider
     Loaded: loaded (/lib/systemd/system/faasd-provider.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2020-11-21 18:18:01 UTC; 5s ago
    Process: 21267 ExecStart=/usr/local/bin/faasd provider (code=exited, status=1/FAILURE)
   Main PID: 21267 (code=exited, status=1/FAILURE)

Nov 21 18:18:01 ip-10-0-0-26 systemd[1]: faasd-provider.service: Main process exited, code=exited, status=1/FAILURE
Nov 21 18:18:01 ip-10-0-0-26 systemd[1]: faasd-provider.service: Failed with result 'exit-code'.
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl restart faasd-provider
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl status faasd-provider
● faasd-provider.service - faasd-provider
     Loaded: loaded (/lib/systemd/system/faasd-provider.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-11-21 18:18:15 UTC; 1s ago
   Main PID: 21351 (faasd)
      Tasks: 4 (limit: 2337)
     Memory: 3.4M (limit: 500.0M)
     CGroup: /system.slice/faasd-provider.service
             └─21351 /usr/local/bin/faasd provider

Nov 21 18:18:15 ip-10-0-0-26 systemd[1]: Started faasd-provider.
Nov 21 18:18:15 ip-10-0-0-26 faasd[21351]: 2020/11/21 18:18:15 faasd-provider starting..        Service Timeout: 1m0s
Nov 21 18:18:15 ip-10-0-0-26 faasd[21351]: faasd version: 0.9.8        commit: bc859e595ff2de87c963a5cab8a9ea0011d86b64
Nov 21 18:18:15 ip-10-0-0-26 faasd[21351]: 2020/11/21 18:18:15 Writing network config...
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
Calling the OpenFaaS server to validate the credentials...
Cannot connect to OpenFaaS on URL: http://127.0.0.1:8080. Get http://127.0.0.1:8080/system/functions: dial tcp 127.0.0.1:8080: connect: connection refused
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl status faasd
● faasd.service - faasd
     Loaded: loaded (/lib/systemd/system/faasd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-11-21 18:18:31 UTC; 134ms ago
   Main PID: 21407 (faasd)
      Tasks: 4 (limit: 2337)
     Memory: 4.7M (limit: 500.0M)
     CGroup: /system.slice/faasd.service
             └─21407 /usr/local/bin/faasd up

Nov 21 18:18:31 ip-10-0-0-26 systemd[1]: faasd.service: Scheduled restart job, restart counter is at 13.
Nov 21 18:18:31 ip-10-0-0-26 systemd[1]: Stopped faasd.
Nov 21 18:18:31 ip-10-0-0-26 systemd[1]: Started faasd.
Nov 21 18:18:31 ip-10-0-0-26 faasd[21407]: faasd version: 0.9.8        commit: bc859e595ff2de87c963a5cab8a9ea0011d86b64
Nov 21 18:18:31 ip-10-0-0-26 faasd[21407]: 2020/11/21 18:18:31 File exists: "/var/lib/faasd/secrets/basic-auth-password"
Nov 21 18:18:31 ip-10-0-0-26 faasd[21407]: 2020/11/21 18:18:31 File exists: "/var/lib/faasd/secrets/basic-auth-user"

For some reason the service is not listening on the expected port:

ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo lsof -nPT -i tcp
COMMAND    PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd       696            root    3u  IPv4  20008      0t0  TCP *:22
sshd       696            root    4u  IPv6  20019      0t0  TCP *:22
amazon-ss 1731            root    8u  IPv4 167651      0t0  TCP 10.0.0.26:56652->52.94.212.197:443
amazon-ss 1731            root   13u  IPv4  23876      0t0  TCP 10.0.0.26:46914->52.119.161.149:443
sshd      1883            root    4u  IPv4  24445      0t0  TCP 10.0.0.26:22->73.15.8.7:59713
sshd      2000          ubuntu    4u  IPv4  24445      0t0  TCP 10.0.0.26:22->73.15.8.7:59713
systemd-r 8797 systemd-resolve   13u  IPv4  37209      0t0  TCP 127.0.0.53:53
oconnore commented 3 years ago

Oh, I guess Ubuntu's version of containerd is broken?

ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl status  containerd
● containerd.service - containerd container runtime
     Loaded: loaded (/etc/systemd/system/containerd.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2020-11-21 18:30:29 UTC; 2s ago
       Docs: https://containerd.io
    Process: 23205 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
    Process: 23213 ExecStart=/usr/local/bin/containerd (code=exited, status=203/EXEC)
   Main PID: 23213 (code=exited, status=203/EXEC)

Nov 21 18:30:28 ip-10-0-0-26 systemd[1]: containerd.service: Main process exited, code=exited, status=203/EXEC
Nov 21 18:30:28 ip-10-0-0-26 systemd[1]: containerd.service: Failed with result 'exit-code'.
Nov 21 18:30:29 ip-10-0-0-26 systemd[1]: Failed to start containerd container runtime.
ubuntu@ip-10-0-0-26:~/faasd_wd$ sudo systemctl restart containerd
Job for containerd.service failed because the control process exited with error code.
See "systemctl status containerd.service" and "journalctl -xe" for details.
ubuntu@ip-10-0-0-26:~$ wget https://github.com/containerd/containerd/releases/download/v1.4.1/containerd-1.4.1-linux-amd64.tar.gz
ubuntu@ip-10-0-0-26:~$ tar  -xf containerd-1.4.1-linux-amd64.tar.gz
ubuntu@ip-10-0-0-26:~$ ls
bin                                 containerd-1.4.1-linux-amd64.tar.gz  docker-compose.yl   faasd_wd
cni-plugins-linux-amd64-v0.8.7.tgz  docker-compose.yaml                  docker-compose.yml  script.sh
ubuntu@ip-10-0-0-26:~$ ls bin/
containerd  containerd-shim  containerd-shim-runc-v1  containerd-shim-runc-v2  ctr
ubuntu@ip-10-0-0-26:~$ sudo cp bin/* /usr/local/bin
ubuntu@ip-10-0-0-26:~$ curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.3.5/containerd.service | sudo tee /etc/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity

[Install]
WantedBy=multi-user.target
ubuntu@ip-10-0-0-26:~$ sudo systemctl enable containerd
ubuntu@ip-10-0-0-26:~$ sudo systemctl start containerd
ubuntu@ip-10-0-0-26:~$ sudo systemctl status  containerd
● containerd.service - containerd container runtime
     Loaded: loaded (/etc/systemd/system/containerd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-11-21 18:33:18 UTC; 6s ago
       Docs: https://containerd.io
    Process: 23959 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
   Main PID: 23961 (containerd)
      Tasks: 13
     Memory: 40.0M
     CGroup: /system.slice/containerd.service
             └─23961 /usr/local/bin/containerd

Now the login command was able to work:

ubuntu@ip-10-0-0-26:~$ sudo cat /var/lib/faasd/secrets/basic-auth-password | faas-cli login -s
Calling the OpenFaaS server to validate the credentials...
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.
credentials saved for admin http://127.0.0.1:8080
alexellis commented 3 years ago

Why did you close the issue?v

For existing VMs you should just be able to run the install bash file.

oconnore commented 3 years ago

@alexellis well, I was able to get the figlet demo running eventually. I think I did try to run the bash script earlier on, but I didn’t capture the output or why I thought it wasn’t working.

I’m very new to this, so I’ll let you be the judge of whether my initial confusion represents a documentation gap or if I’m just a confused newbie. If you do want to reopen, I’d be happy to help write something up (though maybe that would be more useful after I dig in more?)

alexellis commented 3 years ago

On AWS you can:

If any of those can be proven to be broken workflows, we need to know and have a reproducible issue so we can get it sorted out.

oconnore commented 3 years ago

@alexellis ok thanks, I will check these out and reopen if I can reproduce it again.