Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add faas-containerd provider to faasd binary #23

Closed
wants to merge 1 commit into from
Closed

Add faas-containerd provider to faasd binary #23

wants to merge 1 commit into from

Conversation

carlosedp
Copy link
Contributor

Description

This merges the functionality of faas-containerd provider into faasd
thru the start-provider command.

The use of containerd and CNI functionality has been reworked to reuse
the same codebase.

Signed-off-by: Carlos de Paula me@carlosedp.com

Motivation and Context

  • I have raised an issue to propose this change this is required

This has been proposed on issue #20.

How Has This Been Tested?

The faasd and faas-containerd functions were started with different systemd units and functions were deployed by using the faasd endpoint proxying the requests to faas-containerd.

Commands to deploy, list, remove and scale were tested.

Commands:

❯ faas store deploy figlet --name=figlet3 --env write_timeout=1s
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.

Deployed. 200 OK.
URL: http://localhost:8080/function/figlet3


❯ faas-cli list
Function                      	Invocations    	Replicas
figlet3                       	0              	1
figlet1                       	0              	1
figlet2                       	0              	1


❯ curl -d Test http://127.0.0.1:8080/function/figlet3
 _____         _
|_   _|__  ___| |_
  | |/ _ \/ __| __|
  | |  __/\__ \ |_
  |_|\___||___/\__|


❯ faas-cli remove figlet3
Deleting: figlet3.
Removing old function.

On faasd:

-- The job identifier is 4242.
Jan 20 17:41:01 debian10 faasd[4502]: 2020/01/20 17:41:01 File exists: "/run/faasd/secrets/basic-auth-password"
Jan 20 17:41:01 debian10 faasd[4502]: 2020/01/20 17:41:01 File exists: "/run/faasd/secrets/basic-auth-user"
Jan 20 17:41:01 debian10 faasd[4502]: 2020/01/20 17:41:01 Writing network config...
Jan 20 17:41:01 debian10 faasd[4502]: 2020/01/20 17:41:01 Supervisor created in: 1.124891ms
Jan 20 17:41:01 debian10 faasd[4502]: Preparing: basic-auth-plugin with image: docker.io/openfaas/basic-auth-plugin:0.18.10
Jan 20 17:41:01 debian10 faasd[4502]: Prepare done for: docker.io/openfaas/basic-auth-plugin:0.18.10, 7171180 bytes
Jan 20 17:41:01 debian10 faasd[4502]: Preparing: nats with image: docker.io/library/nats-streaming:0.11.2
Jan 20 17:41:01 debian10 faasd[4502]: Prepare done for: docker.io/library/nats-streaming:0.11.2, 4647125 bytes
Jan 20 17:41:01 debian10 faasd[4502]: Preparing: prometheus with image: docker.io/prom/prometheus:v2.14.0
Jan 20 17:41:01 debian10 faasd[4502]: Prepare done for: docker.io/prom/prometheus:v2.14.0, 53527559 bytes
Jan 20 17:41:01 debian10 faasd[4502]: Preparing: gateway with image: docker.io/openfaas/gateway:0.18.8
Jan 20 17:41:01 debian10 faasd[4502]: Prepare done for: docker.io/openfaas/gateway:0.18.8, 11117867 bytes
Jan 20 17:41:01 debian10 faasd[4502]: Preparing: queue-worker with image: docker.io/openfaas/queue-worker:0.9.0
Jan 20 17:41:01 debian10 faasd[4502]: Prepare done for: docker.io/openfaas/queue-worker:0.9.0, 4293659 bytes
Jan 20 17:41:01 debian10 faasd[4502]: Reconciling: basic-auth-plugin
Jan 20 17:41:01 debian10 faasd[4502]: 2020/01/20 17:41:01 Created container basic-auth-plugin
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 17:41:02 basic-auth-plugin has IP: 10.62.0.178.
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 17:41:02 Task: basic-auth-plugin        Container: basic-auth-plugin
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 22:41:02 Listening on: 8080
Jan 20 17:41:02 debian10 faasd[4502]: Reconciling: nats
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 17:41:02 Created container nats
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 17:41:02 nats has IP: 10.62.0.179.
Jan 20 17:41:02 debian10 faasd[4502]: 2020/01/20 17:41:02 Task: nats        Container: nats
Jan 20 17:41:03 debian10 faasd[4502]: Reconciling: prometheus
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.441816 [INF] STREAM: Starting nats-streaming-server[faas-cluster] version 0.11.2
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.441857 [INF] STREAM: ServerID: HsKehOyR1OGu9D8m9h68sa
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.441860 [INF] STREAM: Go version: go1.11.1
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.442345 [INF] Starting nats-server version 1.3.0
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.442359 [INF] Git commit [not set]
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.442482 [INF] Starting http monitor on 0.0.0.0:8222
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.442520 [INF] Listening for client connections on 0.0.0.0:4222
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.442523 [INF] Server is ready
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.472777 [INF] STREAM: Recovering the state...
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.472788 [INF] STREAM: No recovered state
Jan 20 17:41:03 debian10 faasd[4502]: 2020/01/20 17:41:03 Created container prometheus
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723431 [INF] STREAM: Message store is MEMORY
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723460 [INF] STREAM: ---------- Store Limits ----------
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723462 [INF] STREAM: Channels:                  100 *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723464 [INF] STREAM: --------- Channels Limits --------
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723465 [INF] STREAM:   Subscriptions:          1000 *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723467 [INF] STREAM:   Messages     :       1000000 *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723468 [INF] STREAM:   Bytes        :     976.56 MB *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723470 [INF] STREAM:   Age          :     unlimited *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723471 [INF] STREAM:   Inactivity   :     unlimited *
Jan 20 17:41:03 debian10 faasd[4502]: [1] 2020/01/20 22:41:03.723473 [INF] STREAM: ----------------------------------
Jan 20 17:41:03 debian10 faasd[4502]: 2020/01/20 17:41:03 prometheus has IP: 10.62.0.180.
Jan 20 17:41:03 debian10 faasd[4502]: 2020/01/20 17:41:03 Task: prometheus        Container: prometheus
Jan 20 17:41:03 debian10 faasd[4502]: Reconciling: gateway
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.801Z caller=main.go:296 msg="no time or size retention was set so using the default time retention" duration=15d
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.801Z caller=main.go:332 msg="Starting Prometheus" version="(version=2.14.0, branch=HEAD, revision=edeb7a44cbf745f1d8be4ea6f215e79e651bfe19)"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.801Z caller=main.go:333 build_context="(go=go1.13.4, user=root@df2327081015, date=20191111-14:27:12)"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.801Z caller=main.go:334 host_details="(Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 debian10 (none))"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.801Z caller=main.go:335 fd_limits="(soft=1024, hard=1024)"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.802Z caller=main.go:336 vm_limits="(soft=unlimited, hard=unlimited)"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.803Z caller=web.go:496 component=web msg="Start listening for connections" address=0.0.0.0:9090
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.803Z caller=main.go:657 msg="Starting TSDB ..."
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.806Z caller=head.go:535 component=tsdb msg="replaying WAL, this may take awhile"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.806Z caller=head.go:583 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.807Z caller=main.go:672 fs_type=794c7630
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.807Z caller=main.go:673 msg="TSDB started"
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.807Z caller=main.go:743 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
Jan 20 17:41:03 debian10 faasd[4502]: 2020/01/20 17:41:03 Created container gateway
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.818Z caller=main.go:771 msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml
Jan 20 17:41:03 debian10 faasd[4502]: level=info ts=2020-01-20T22:41:03.818Z caller=main.go:626 msg="Server is ready to receive web requests."
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 gateway has IP: 10.62.0.181.
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 Task: gateway        Container: gateway
Jan 20 17:41:04 debian10 faasd[4502]: Reconciling: queue-worker
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 HTTP Read Timeout: 1m0s
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 HTTP Write Timeout: 1m0s
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 Binding to external function provider: http://faas-containerd:8081/
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 Async enabled: Using NATS Streaming.
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 Opening connection to nats://nats:4222
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 22:41:04 Connect: nats://nats:4222
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 Created container queue-worker
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 queue-worker has IP: 10.62.0.182.
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 Task: queue-worker        Container: queue-worker
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 Supervisor init done in: 2.614853024s
Jan 20 17:41:04 debian10 faasd[4502]: Loading basic authentication credentials
Jan 20 17:41:04 debian10 faasd[4502]: 2020/01/20 17:41:04 faasd: waiting for SIGTERM or SIGINT
Jan 20 17:41:04 debian10 faasd[4502]: Connect: nats://nats:4222
Jan 20 17:41:04 debian10 faasd[4502]: Subscribing to: faas-request at nats://nats:4222
Jan 20 17:41:04 debian10 faasd[4502]: Wait for  5m5s
Jan 20 17:41:04 debian10 faasd[4502]: [1] 2020/01/20 22:41:04.373531 [INF] STREAM: Channel "faas-request" has been created
Jan 20 17:41:04 debian10 faasd[4502]: Listening on [faas-request], clientID=[faas-worker-debian10], qgroup=[faas] durable=[]
Jan 20 17:41:07 debian10 faasd[4502]: 2020/01/20 17:41:07 [up] Sending 10.62.0.181 to proxy
Jan 20 17:41:07 debian10 faasd[4502]: 2020/01/20 17:41:07 Starting faasd proxy on 8080
Jan 20 17:41:07 debian10 faasd[4502]: Gateway: 10.62.0.181:8080
Jan 20 17:41:07 debian10 faasd[4502]: 2020/01/20 17:41:07 [proxy] Wait for done
Jan 20 17:41:07 debian10 faasd[4502]: 2020/01/20 17:41:07 [proxy] Begin listen on 8080
Jan 20 17:41:12 debian10 faasd[4502]: [faasd] proxy: http://10.62.0.181:8080/system/functions
Jan 20 17:41:12 debian10 faasd[4502]: 2020/01/20 22:41:12 Validated request 200.
Jan 20 17:41:12 debian10 faasd[4502]: 2020/01/20 22:41:12 Forwarded [PUT] to /system/functions - [404] - 0.011314 seconds
Jan 20 17:41:12 debian10 faasd[4502]: [faasd] proxy: http://10.62.0.181:8080/system/functions
Jan 20 17:41:12 debian10 faasd[4502]: 2020/01/20 22:41:12 Validated request 200.
Jan 20 17:41:12 debian10 faasd[4502]: 2020/01/20 22:41:12 Forwarded [POST] to /system/functions - [200] - 0.310633 seconds


Jan 20 17:41:19 debian10 faasd[4502]: [faasd] proxy: http://10.62.0.181:8080/system/functions
Jan 20 17:41:19 debian10 faasd[4502]: 2020/01/20 22:41:19 Validated request 200.
Jan 20 17:41:19 debian10 faasd[4502]: 2020/01/20 22:41:19 Forwarded [GET] to /system/functions - [200] - 0.009061 seconds
Jan 20 17:41:23 debian10 faasd[4502]: [faasd] proxy: http://10.62.0.181:8080/function/figlet3
Jan 20 17:41:23 debian10 faasd[4502]: 2020/01/20 22:41:23 GetReplicas [figlet3.] took: 0.017907s
Jan 20 17:41:23 debian10 faasd[4502]: 2020/01/20 22:41:23 GetReplicas [figlet3.] took: 0.017929s
Jan 20 17:41:23 debian10 faasd[4502]: 2020/01/20 22:41:23 Forwarded [POST] to /function/figlet3 - [200] - 0.008294 seconds
Jan 20 17:41:30 debian10 faasd[4502]: [faasd] proxy: http://10.62.0.181:8080/system/functions
Jan 20 17:41:30 debian10 faasd[4502]: 2020/01/20 22:41:30 Validated request 200.
Jan 20 17:41:32 debian10 faasd[4502]: 2020/01/20 22:41:32 Forwarded [DELETE] to /system/functions - [200] - 2.344967 seconds

On faas-containerd:

-- The job identifier is 4317.
Jan 20 17:41:01 debian10 faas-containerd[4513]: 2020/01/20 17:41:01 faas-containerd starting..        Version:         Commit:         Service Timeout: 1m0s
Jan 20 17:41:01 debian10 faas-containerd[4513]: 2020/01/20 17:41:01 Writing network config...
Jan 20 17:41:01 debian10 faas-containerd[4513]: 2020/01/20 17:41:01 Listening on TCP port: 8081



Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 [Update] request: {"service":"figlet3","image":"functions/figlet:0.13.0","network":"","envProcess":"figlet","envVars":{"write_timeout":"1s"},"constraints":[],"secrets":[],"labels":{},"annotations":{},"limits":null,"requests":null,"readOnlyRootFilesystem":false}
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 [Update] service figlet3 not found
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 [Deploy] request: {"service":"figlet3","image":"functions/figlet:0.13.0","network":"","envProcess":"figlet","envVars":{"write_timeout":"1s"},"constraints":[],"secrets":[],"labels":{},"annotations":{},"limits":null,"requests":null,"readOnlyRootFilesystem":false}
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 Deploy docker.io/functions/figlet:0.13.0 size: 5658006
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 Container ID: figlet3        Task ID figlet3:        Task PID: 5088
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 17:41:12 figlet3 has IP: 10.62.0.183.
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 22:41:12 Version: 0.13.0        SHA: fa93655d90d1518b04e7cfca7d7548d7d133a34e
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 22:41:12 Read/write timeout: 5s, 1s. Port: 8080
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 22:41:12 Writing lock-file to: /tmp/.lock
Jan 20 17:41:12 debian10 faas-containerd[4513]: 2020/01/20 22:41:12 Metrics server. Port: 8081


Jan 20 17:41:23 debian10 faas-containerd[4513]: 2020/01/20 17:41:23 Resolve: "figlet3"
Jan 20 17:41:23 debian10 faas-containerd[4513]: 2020/01/20 22:41:23 Forking fprocess.
Jan 20 17:41:23 debian10 faas-containerd[4513]: 2020/01/20 22:41:23 Wrote 120 Bytes - Duration: 0.001418 seconds
Jan 20 17:41:23 debian10 faas-containerd[4513]: 2020/01/20 17:41:23 figlet3 took 0.004006 seconds
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 17:41:30 [Delete] request: {"functionName":"figlet3"}
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 17:41:30 [Delete] removing CNI network for figlet3
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 17:41:30 [Delete] removed figlet3 with namespace /proc/5088/ns/net and ID figlet3-5088
Jan 20 17:41:30 debian10 faas-containerd[4513]: Status of figlet3 is: running
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 17:41:30 Need to kill figlet3
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 22:41:30 SIGTERM received.. shutting down server in 1s
Jan 20 17:41:30 debian10 faas-containerd[4513]: 2020/01/20 22:41:30 Removing lock-file : /tmp/.lock
Jan 20 17:41:31 debian10 faas-containerd[4513]: 2020/01/20 22:41:31 No new connections allowed. Exiting in: 1s
Jan 20 17:41:32 debian10 faas-containerd[4513]: 2020/01/20 17:41:32 [Delete] deleted figlet3

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Commits:

  • I've read the CONTRIBUTION guide
  • My commit message has a body and describe how this was tested and why it is required.
  • I have signed-off my commits with git commit -s for the Developer Certificate of Origin (DCO)

Code:

  • My code follows the code style of this project.
  • I have added tests to cover my changes.

Docs:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@carlosedp
Copy link
Contributor Author

This is still a WIP, container and task creation for both faasd and functions could be refactored to use same codebase.

This merges the functionality of faas-containerd provider into faasd
thru the start-provider command.

The use of containerd and CNI functionality has been reworked to reuse
the same codebase.

Signed-off-by: Carlos de Paula <me@carlosedp.com>
@alexellis
Copy link
Member

Sorry I didn't know you were working on this, we had last discussed having a call to sync up on it, I didn't get a response to my question so went ahead with the change that so we could update the blogs and tutorials. If you've done anything differently to my PR, and please feel free to to send a patch for anything else we need.

I haven't closed the main issue yet because I think there is more deduplication that we can do.

@carlosedp
Copy link
Contributor Author

I'm working on deduplicate some functions. Will submit a PR later.

@alexellis
Copy link
Member

alexellis commented Jan 21, 2020

Sounds good, can I suggest a new PR/branch for that? PR #25 performed the merge of the two systems/binaries.

Can you also raise an issue so that we can track the work?

I've heard from Bryan and there should be a new CNI plugin release tomorrow afternoon.

@carlosedp carlosedp deleted the faas-provider branch March 9, 2020 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants