adding cni metadata to the container in the ctr run --config
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
parent
f50dce84f8
commit
5fdca538d0
@ -239,10 +239,6 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
opts = append(opts, oci.WithAnnotations(annos))
|
||||
}
|
||||
|
||||
if context.Bool("cni") {
|
||||
cniMeta := &commands.NetworkMetaData{EnableCni: true}
|
||||
cOpts = append(cOpts, containerd.WithContainerExtension(commands.CtrCniMetadataExtension, cniMeta))
|
||||
}
|
||||
if caps := context.StringSlice("cap-add"); len(caps) > 0 {
|
||||
for _, cap := range caps {
|
||||
if !strings.HasPrefix(cap, "CAP_") {
|
||||
@ -375,6 +371,11 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
}
|
||||
}
|
||||
|
||||
if context.Bool("cni") {
|
||||
cniMeta := &commands.NetworkMetaData{EnableCni: true}
|
||||
cOpts = append(cOpts, containerd.WithContainerExtension(commands.CtrCniMetadataExtension, cniMeta))
|
||||
}
|
||||
|
||||
runtimeOpts, err := getRuntimeOptions(context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -131,8 +131,6 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
return nil, err
|
||||
}
|
||||
opts = append(opts, oci.WithWindowsNetworkNamespace(ns.GetPath()))
|
||||
cniMeta := &commands.NetworkMetaData{EnableCni: true}
|
||||
cOpts = append(cOpts, containerd.WithContainerExtension(commands.CtrCniMetadataExtension, cniMeta))
|
||||
}
|
||||
if context.Bool("isolated") {
|
||||
opts = append(opts, oci.WithWindowsHyperV)
|
||||
@ -165,6 +163,11 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
}
|
||||
}
|
||||
|
||||
if context.Bool("cni") {
|
||||
cniMeta := &commands.NetworkMetaData{EnableCni: true}
|
||||
cOpts = append(cOpts, containerd.WithContainerExtension(commands.CtrCniMetadataExtension, cniMeta))
|
||||
}
|
||||
|
||||
runtime := context.String("runtime")
|
||||
var runtimeOpts interface{}
|
||||
if runtime == "io.containerd.runhcs.v1" {
|
||||
|
Loading…
Reference in New Issue
Block a user