Move faas-containerd to faasd-provider unit file

The new unit file runs the merged faasd binary and the provider
command. The install script also prints out a sample login
command to make it easier to use the faas-cli.

Travis / CI has been updated to run the new steps in the e2e
tests.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2020-01-21 13:30:33 +00:00
committed by Alex Ellis
parent d551721649
commit bacf8ebad5
4 changed files with 16 additions and 23 deletions

View File

@ -2,7 +2,6 @@ Version := $(shell git describe --tags --dirty)
GitCommit := $(shell git rev-parse HEAD) GitCommit := $(shell git rev-parse HEAD)
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)" LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"
CONTAINERD_VER := 1.3.2 CONTAINERD_VER := 1.3.2
FAASC_VER := 0.4.0
CNI_VERSION := v0.8.4 CNI_VERSION := v0.8.4
ARCH := amd64 ARCH := amd64
@ -27,12 +26,11 @@ prepare-test:
sudo /sbin/sysctl -w net.ipv4.conf.all.forwarding=1 sudo /sbin/sysctl -w net.ipv4.conf.all.forwarding=1
sudo mkdir -p /opt/cni/bin sudo mkdir -p /opt/cni/bin
curl -sSL https://github.com/containernetworking/plugins/releases/download/$(CNI_VERSION)/cni-plugins-linux-$(ARCH)-$(CNI_VERSION).tgz | sudo tar -xz -C /opt/cni/bin curl -sSL https://github.com/containernetworking/plugins/releases/download/$(CNI_VERSION)/cni-plugins-linux-$(ARCH)-$(CNI_VERSION).tgz | sudo tar -xz -C /opt/cni/bin
sudo curl -sSLf "https://github.com/alexellis/faas-containerd/releases/download/$(FAASC_VER)/faas-containerd" --output "/usr/local/bin/faas-containerd" && sudo chmod a+x "/usr/local/bin/faas-containerd" || :
sudo cp $(GOPATH)/src/github.com/alexellis/faasd/bin/faasd /usr/local/bin/ sudo cp $(GOPATH)/src/github.com/alexellis/faasd/bin/faasd /usr/local/bin/
cd $(GOPATH)/src/github.com/alexellis/faasd/ && sudo /usr/local/bin/faasd install cd $(GOPATH)/src/github.com/alexellis/faasd/ && sudo /usr/local/bin/faasd install
sudo systemctl status -l containerd --no-pager sudo systemctl status -l containerd --no-pager
sudo journalctl -u faas-containerd --no-pager sudo journalctl -u faasd-provider --no-pager
sudo systemctl status -l faas-containerd --no-pager sudo systemctl status -l faasd-provider --no-pager
sudo systemctl status -l faasd --no-pager sudo systemctl status -l faasd --no-pager
curl -sSLf https://cli.openfaas.com | sudo sh curl -sSLf https://cli.openfaas.com | sudo sh
sleep 120 && sudo journalctl -u faasd --no-pager sleep 120 && sudo journalctl -u faasd --no-pager

View File

@ -78,10 +78,6 @@ You can run this tutorial on your Raspberry Pi, or adapt the steps for a regular
Install the CNI plugins: Install the CNI plugins:
```sh
export CNI_VERSION=v0.8.4
```
* For PC run `export ARCH=amd64` * For PC run `export ARCH=amd64`
* For RPi/armhf run `export ARCH=arm` * For RPi/armhf run `export ARCH=arm`
* For arm64 run `export ARCH=arm64` * For arm64 run `export ARCH=arm64`
@ -89,8 +85,9 @@ export CNI_VERSION=v0.8.4
Then run: Then run:
```sh ```sh
mkdir -p /opt/cni/bin export CNI_VERSION=v0.8.4
curl -sSL https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C /opt/cni/bin sudo mkdir -p /opt/cni/bin
curl -sSL https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | sudo tar -xz -C /opt/cni/bin
``` ```
First run faas-containerd First run faas-containerd

View File

@ -19,7 +19,7 @@ var installCmd = &cobra.Command{
} }
const faasdwd = "/run/faasd" const faasdwd = "/run/faasd"
const faasContainerdwd = "/run/faas-containerd" const faasdProviderWd = "/run/faasd-provider"
func runInstall(_ *cobra.Command, _ []string) error { func runInstall(_ *cobra.Command, _ []string) error {
@ -27,7 +27,7 @@ func runInstall(_ *cobra.Command, _ []string) error {
return err return err
} }
if err := ensureWorkingDir(faasContainerdwd); err != nil { if err := ensureWorkingDir(faasdProviderWd); err != nil {
return err return err
} }
@ -43,18 +43,13 @@ func runInstall(_ *cobra.Command, _ []string) error {
return err return err
} }
err := binExists("/usr/local/bin/", "faas-containerd") err := binExists("/usr/local/bin/", "faasd")
if err != nil { if err != nil {
return err return err
} }
err = binExists("/usr/local/bin/", "faasd") err = systemd.InstallUnit("faasd-provider", map[string]string{
if err != nil { "Cwd": faasdProviderWd,
return err
}
err = systemd.InstallUnit("faas-containerd", map[string]string{
"Cwd": faasContainerdwd,
"SecretMountPath": path.Join(faasdwd, "secrets")}) "SecretMountPath": path.Join(faasdwd, "secrets")})
if err != nil { if err != nil {
@ -71,7 +66,7 @@ func runInstall(_ *cobra.Command, _ []string) error {
return err return err
} }
err = systemd.Enable("faas-containerd") err = systemd.Enable("faasd-provider")
if err != nil { if err != nil {
return err return err
} }
@ -81,7 +76,7 @@ func runInstall(_ *cobra.Command, _ []string) error {
return err return err
} }
err = systemd.Start("faas-containerd") err = systemd.Start("faasd-provider")
if err != nil { if err != nil {
return err return err
} }
@ -91,6 +86,9 @@ func runInstall(_ *cobra.Command, _ []string) error {
return err return err
} }
fmt.Println(`Login with:
sudo cat /run/faasd/secrets/basic-auth-password | faas-cli login -s`)
return nil return nil
} }

View File

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=faasd-containerd Description=faasd-provider
[Service] [Service]
MemoryLimit=500M MemoryLimit=500M