mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-21 10:56:32 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
87c71b090f | |||
dc8667d36a | |||
137d199cb5 | |||
560c295eb0 | |||
93325b713e |
@ -11,12 +11,13 @@ runcmd:
|
|||||||
- curl -sLSf https://github.com/containerd/containerd/releases/download/v1.3.2/containerd-1.3.2.linux-amd64.tar.gz > /tmp/containerd.tar.gz && tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1
|
- curl -sLSf https://github.com/containerd/containerd/releases/download/v1.3.2/containerd-1.3.2.linux-amd64.tar.gz > /tmp/containerd.tar.gz && tar -xvf /tmp/containerd.tar.gz -C /usr/local/bin/ --strip-components=1
|
||||||
- curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.3.2/containerd.service | tee /etc/systemd/system/containerd.service
|
- curl -SLfs https://raw.githubusercontent.com/containerd/containerd/v1.3.2/containerd.service | tee /etc/systemd/system/containerd.service
|
||||||
- systemctl daemon-reload && systemctl start containerd
|
- systemctl daemon-reload && systemctl start containerd
|
||||||
|
- systemctl enable containerd
|
||||||
- /sbin/sysctl -w net.ipv4.conf.all.forwarding=1
|
- /sbin/sysctl -w net.ipv4.conf.all.forwarding=1
|
||||||
- mkdir -p /opt/cni/bin
|
- mkdir -p /opt/cni/bin
|
||||||
- curl -sSL https://github.com/containernetworking/plugins/releases/download/v0.8.5/cni-plugins-linux-amd64-v0.8.5.tgz | tar -xz -C /opt/cni/bin
|
- curl -sSL https://github.com/containernetworking/plugins/releases/download/v0.8.5/cni-plugins-linux-amd64-v0.8.5.tgz | tar -xz -C /opt/cni/bin
|
||||||
- mkdir -p /go/src/github.com/openfaas/
|
- mkdir -p /go/src/github.com/openfaas/
|
||||||
- cd /go/src/github.com/openfaas/ && git clone https://github.com/openfaas/faasd
|
- cd /go/src/github.com/openfaas/ && git clone https://github.com/openfaas/faasd
|
||||||
- curl -fSLs "https://github.com/openfaas/faasd/releases/download/0.7.5/faasd" --output "/usr/local/bin/faasd" && chmod a+x "/usr/local/bin/faasd"
|
- curl -fSLs "https://github.com/openfaas/faasd/releases/download/0.7.7/faasd" --output "/usr/local/bin/faasd" && chmod a+x "/usr/local/bin/faasd"
|
||||||
- cd /go/src/github.com/openfaas/faasd/ && /usr/local/bin/faasd install
|
- cd /go/src/github.com/openfaas/faasd/ && /usr/local/bin/faasd install
|
||||||
- systemctl status -l containerd --no-pager
|
- systemctl status -l containerd --no-pager
|
||||||
- journalctl -u faasd-provider --no-pager
|
- journalctl -u faasd-provider --no-pager
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/openfaas/faasd/pkg/cninetwork"
|
|
||||||
"github.com/openfaas/faasd/pkg/provider/config"
|
|
||||||
"github.com/openfaas/faasd/pkg/provider/handlers"
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
bootstrap "github.com/openfaas/faas-provider"
|
bootstrap "github.com/openfaas/faas-provider"
|
||||||
"github.com/openfaas/faas-provider/proxy"
|
"github.com/openfaas/faas-provider/proxy"
|
||||||
"github.com/openfaas/faas-provider/types"
|
"github.com/openfaas/faas-provider/types"
|
||||||
|
"github.com/openfaas/faasd/pkg/cninetwork"
|
||||||
|
"github.com/openfaas/faasd/pkg/provider/config"
|
||||||
|
"github.com/openfaas/faasd/pkg/provider/handlers"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,6 +81,14 @@ func runProvider(_ *cobra.Command, _ []string) error {
|
|||||||
InfoHandler: handlers.MakeInfoHandler(Version, GitCommit),
|
InfoHandler: handlers.MakeInfoHandler(Version, GitCommit),
|
||||||
ListNamespaceHandler: listNamespaces(),
|
ListNamespaceHandler: listNamespaces(),
|
||||||
SecretHandler: handlers.MakeSecretHandler(client, userSecretPath),
|
SecretHandler: handlers.MakeSecretHandler(client, userSecretPath),
|
||||||
|
LogHandler: func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Body != nil {
|
||||||
|
defer r.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNotImplemented)
|
||||||
|
w.Write([]byte(`Logs are not implemented for faasd`))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Listening on TCP port: %d\n", *config.TCPPort)
|
log.Printf("Listening on TCP port: %d\n", *config.TCPPort)
|
||||||
|
@ -107,6 +107,7 @@ func deploy(ctx context.Context, req types.FunctionDeployment, client *container
|
|||||||
oci.WithCapabilities([]string{"CAP_NET_RAW"}),
|
oci.WithCapabilities([]string{"CAP_NET_RAW"}),
|
||||||
oci.WithMounts(mounts),
|
oci.WithMounts(mounts),
|
||||||
oci.WithEnv(envs)),
|
oci.WithEnv(envs)),
|
||||||
|
containerd.WithContainerLabels(*req.Labels),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,10 +3,11 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/openfaas/faasd/pkg/cninetwork"
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
|
"github.com/openfaas/faasd/pkg/cninetwork"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Function struct {
|
type Function struct {
|
||||||
@ -16,6 +17,7 @@ type Function struct {
|
|||||||
pid uint32
|
pid uint32
|
||||||
replicas int
|
replicas int
|
||||||
IP string
|
IP string
|
||||||
|
labels map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,10 +46,18 @@ func GetFunction(client *containerd.Client, name string) (Function, error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
image, _ := c.Image(ctx)
|
image, _ := c.Image(ctx)
|
||||||
|
|
||||||
|
containerName := c.ID()
|
||||||
|
labels, labelErr := c.Labels(ctx)
|
||||||
|
if labelErr != nil {
|
||||||
|
log.Printf("cannot list container %s labels: %s", containerName, labelErr.Error())
|
||||||
|
}
|
||||||
|
|
||||||
f := Function{
|
f := Function{
|
||||||
name: c.ID(),
|
name: containerName,
|
||||||
namespace: FunctionNamespace,
|
namespace: FunctionNamespace,
|
||||||
image: image.Name(),
|
image: image.Name(),
|
||||||
|
labels: labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
replicas := 0
|
replicas := 0
|
||||||
|
@ -26,6 +26,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h
|
|||||||
Image: function.image,
|
Image: function.image,
|
||||||
Replicas: uint64(function.replicas),
|
Replicas: uint64(function.replicas),
|
||||||
Namespace: function.namespace,
|
Namespace: function.namespace,
|
||||||
|
Labels: &function.labels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ func MakeReplicaReaderHandler(client *containerd.Client) func(w http.ResponseWri
|
|||||||
AvailableReplicas: uint64(f.replicas),
|
AvailableReplicas: uint64(f.replicas),
|
||||||
Replicas: uint64(f.replicas),
|
Replicas: uint64(f.replicas),
|
||||||
Namespace: f.namespace,
|
Namespace: f.namespace,
|
||||||
|
Labels: &f.labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
functionBytes, _ := json.Marshal(found)
|
functionBytes, _ := json.Marshal(found)
|
||||||
|
Reference in New Issue
Block a user