mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-21 00:06:37 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
560c295eb0 | |||
93325b713e |
@ -11,6 +11,7 @@ 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
|
||||||
|
@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user