mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-18 03:56:35 +00:00
Use the openfaas namespace for core services
All services like docker and k8s.io use their own namespaces for core services, this change moves openfaas services into the openfaas namespace instead of the default one. The main change is that logs will look like: journalctl -t openfaas:gateway Instead of "default:gateway" Function logs will remain unaffected and scheduled in the openfaas-fn namespace. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
2533c065bf
commit
32c00f0e9e
@ -125,14 +125,16 @@ echo logs | faas-cli invoke figlet
|
|||||||
|
|
||||||
Core services as defined in the docker-compose.yaml file are deployed as containers by faasd.
|
Core services as defined in the docker-compose.yaml file are deployed as containers by faasd.
|
||||||
|
|
||||||
|
The namespace is `openfaas` for core services.
|
||||||
|
|
||||||
View the logs for a component by giving its NAME:
|
View the logs for a component by giving its NAME:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
journalctl -t default:NAME
|
journalctl -t openfaas:NAME
|
||||||
|
|
||||||
journalctl -t default:gateway
|
journalctl -t openfaas:gateway
|
||||||
|
|
||||||
journalctl -t default:queue-worker
|
journalctl -t openfaas:queue-worker
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use `-f` to follow the logs, or `--lines` to tail a number of lines, or `--since` to give a timeframe.
|
You can also use `-f` to follow the logs, or `--lines` to tail a number of lines, or `--since` to give a timeframe.
|
||||||
|
@ -3,4 +3,11 @@ package pkg
|
|||||||
const (
|
const (
|
||||||
// FunctionNamespace is the default containerd namespace functions are created
|
// FunctionNamespace is the default containerd namespace functions are created
|
||||||
FunctionNamespace = "openfaas-fn"
|
FunctionNamespace = "openfaas-fn"
|
||||||
|
|
||||||
|
// faasdNamespace is the containerd namespace services are created
|
||||||
|
faasdNamespace = "openfaas"
|
||||||
|
|
||||||
|
faasServicesPullAlways = false
|
||||||
|
|
||||||
|
defaultSnapshotter = "overlayfs"
|
||||||
)
|
)
|
||||||
|
@ -38,20 +38,21 @@ func Remove(ctx context.Context, client *containerd.Client, name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if found {
|
if found {
|
||||||
status, _ := t.Status(ctx)
|
status, err := t.Status(ctx)
|
||||||
fmt.Printf("Status of %s is: %s\n", name, status.Status)
|
if err != nil {
|
||||||
|
fmt.Printf("Status of %s is: %s\n", name, status.Status)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Need to kill %s\n", name)
|
log.Printf("Need to kill %s\n", name)
|
||||||
err := killTask(ctx, t)
|
if err = killTask(ctx, t); err != nil {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error killing task %s, %s, %s", container.ID(), name, err)
|
return fmt.Errorf("error killing task %s, %s, %s", container.ID(), name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = container.Delete(ctx, containerd.WithSnapshotCleanup)
|
if err := container.Delete(ctx, containerd.WithSnapshotCleanup); err != nil {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error deleting container %s, %s, %s", container.ID(), name, err)
|
return fmt.Errorf("error deleting container %s, %s, %s", container.ID(), name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
service := client.SnapshotService("")
|
service := client.SnapshotService("")
|
||||||
key := name + "snapshot"
|
key := name + "snapshot"
|
||||||
@ -70,6 +71,7 @@ func killTask(ctx context.Context, task containerd.Task) error {
|
|||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if task != nil {
|
if task != nil {
|
||||||
@ -114,6 +116,7 @@ func getResolver(ctx context.Context, configFile *configfile.ConfigFile) (remote
|
|||||||
}
|
}
|
||||||
return ac.Username, ac.Password, nil
|
return ac.Username, ac.Password, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
authOpts := []docker.AuthorizerOpt{docker.WithAuthCreds(credFunc)}
|
authOpts := []docker.AuthorizerOpt{docker.WithAuthCreds(credFunc)}
|
||||||
authorizer := docker.NewDockerAuthorizer(authOpts...)
|
authorizer := docker.NewDockerAuthorizer(authOpts...)
|
||||||
opts := docker.ResolverOptions{
|
opts := docker.ResolverOptions{
|
||||||
@ -128,7 +131,7 @@ func PrepareImage(ctx context.Context, client *containerd.Client, imageName, sna
|
|||||||
resolver remotes.Resolver
|
resolver remotes.Resolver
|
||||||
)
|
)
|
||||||
|
|
||||||
if _, stErr := os.Stat(filepath.Join(dockerConfigDir, config.ConfigFileName)); stErr == nil {
|
if _, statErr := os.Stat(filepath.Join(dockerConfigDir, config.ConfigFileName)); statErr == nil {
|
||||||
configFile, err := config.Load(dockerConfigDir)
|
configFile, err := config.Load(dockerConfigDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -137,8 +140,8 @@ func PrepareImage(ctx context.Context, client *containerd.Client, imageName, sna
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return empty, err
|
return empty, err
|
||||||
}
|
}
|
||||||
} else if !os.IsNotExist(stErr) {
|
} else if !os.IsNotExist(statErr) {
|
||||||
return empty, stErr
|
return empty, statErr
|
||||||
}
|
}
|
||||||
|
|
||||||
var image containerd.Image
|
var image containerd.Image
|
||||||
@ -150,7 +153,6 @@ func PrepareImage(ctx context.Context, client *containerd.Client, imageName, sna
|
|||||||
|
|
||||||
image = img
|
image = img
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
img, err := client.GetImage(ctx, imageName)
|
img, err := client.GetImage(ctx, imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) {
|
||||||
@ -187,9 +189,11 @@ func pullImage(ctx context.Context, client *containerd.Client, resolver remotes.
|
|||||||
rOpts := []containerd.RemoteOpt{
|
rOpts := []containerd.RemoteOpt{
|
||||||
containerd.WithPullUnpack,
|
containerd.WithPullUnpack,
|
||||||
}
|
}
|
||||||
|
|
||||||
if resolver != nil {
|
if resolver != nil {
|
||||||
rOpts = append(rOpts, containerd.WithResolver(resolver))
|
rOpts = append(rOpts, containerd.WithResolver(resolver))
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := client.Pull(ctx, imageName, rOpts...)
|
img, err := client.Pull(ctx, imageName, rOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return empty, fmt.Errorf("cannot pull: %s", err)
|
return empty, fmt.Errorf("cannot pull: %s", err)
|
||||||
|
@ -26,11 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultSnapshotter = "overlayfs"
|
|
||||||
workingDirectoryPermission = 0644
|
workingDirectoryPermission = 0644
|
||||||
// faasdNamespace is the containerd namespace services are created
|
|
||||||
faasdNamespace = "default"
|
|
||||||
faasServicesPullAlways = false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
|
Reference in New Issue
Block a user