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

Default net #34

Merged
merged 3 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ When network management is delegated to CNI plugins with static integration leve
Pods can request network connections to DanmNets by defining one or more network connections in the annotation of their (template) spec field, according to the schema described in the **schema/network_attach.yaml** file.

For each connections defined in such a manner DANM will provision exactly one interface into the Pod's network namespace, according to the way described in previous chapters (configuration taken from teh referenced DanmNet API object).
Note: if the Pod annotation is empty (no danmnet connection is defined), DANM will fall back to use a default network definition, if created. The danmnet object in the target K8S namespace must use the name: "default". It can have any network type (either delegated or ipvlan). Naturally, user in this case cannot specify any further property for the Pod (i.e. static IP address). This way, the user is able to use unmodified manifest files (i.e. community maintained Helm charts or Pods created by K8S operators).

In addition to simply invoking other CNI libraries to set-up network connections, Pod's can even influence the way their interfaces are created to a certain extent.
For example Pods can ask DANM to provision L3 IP addresses to their IPVLAN or SRI-OV interfaces dnyamically, statically, or not at all!
Expand Down
9 changes: 6 additions & 3 deletions pkg/danm/danm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
v1Endpoint = "/api/v1/"
cniVersion = "0.3.1"
kubeConf string
defaultNetworkName = "default"
)

type NetConf struct {
Expand Down Expand Up @@ -71,9 +72,8 @@ func createInterfaces(args *skel.CmdArgs) error {
return fmt.Errorf("Pod manifest could not be parsed with error: %v", err)
}
extractConnections(cniArgs)
if len(cniArgs.interfaces) == 0 {
log.Println("ERROR: ADD: DANM cannot create interfaces for Pod:" + cniArgs.podId + " , because no network connections are defined in spec.metadata.annotation")
return fmt.Errorf("DANM cannot create interfaces for Pod:%s, because no network connections are defined in spec.metadata.annotation", cniArgs.podId)
if len(cniArgs.interfaces) == 1 && cniArgs.interfaces[0].Network == defaultNetworkName {
log.Println("WARN: ADD: no network connections for Pod: " + cniArgs.podId + " are defined in spec.metadata.annotation. Falling back to use: " + defaultNetworkName)
}
cniResult, err := setupNetworking(cniArgs)
if err != nil {
Expand Down Expand Up @@ -175,6 +175,9 @@ func extractConnections(args *cniArgs) error {
break
}
}
if len(ifaces) == 0 {
ifaces = []danmtypes.Interface{{Network: defaultNetworkName}}
}
args.interfaces = ifaces
return nil
}
Expand Down