Skip to content

Commit 69ecfeb

Browse files
authored
Merge pull request #12 from phoracek/multus-conf-file-auto
automatically detect multus configuration
2 parents 1a94179 + 457f3b5 commit 69ecfeb

File tree

5 files changed

+12
-89
lines changed

5 files changed

+12
-89
lines changed

README.md

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,29 @@ kind: NetworkAddonsConfig
1616
metadata:
1717
name: cluster
1818
spec:
19-
multus:
20-
delegates: |
21-
[{
22-
"type": "flannel",
23-
"name": "flannel.1",
24-
"delegate": {
25-
"isDefaultGateway": true
26-
}
27-
}]
19+
multus: {}
2820
linuxBridge: {}
2921
```
3022
3123
## Multus
3224
33-
The operator allows administrator to deploy multi-network [Multus plugin](https://github.com/intel/multus-cni). Configuration of this component varies based on used platform.
34-
35-
### On Kubernetes
36-
37-
On Kubernetes or OpenShift 3, operator can be used to deploy and configure
38-
Multus. It is done using `multus` attribute. `multus.delegates` attribute must
39-
be specified and contain CNI configuration for the default plugin used on your
40-
cluster.
25+
The operator allows administrator to deploy multi-network
26+
[Multus plugin](https://github.com/intel/multus-cni). It is done using `multus`
27+
attribute.
4128

4229
```yaml
4330
apiVersion: networkaddonsoperator.network.kubevirt.io/v1alpha1
4431
kind: NetworkAddonsConfig
4532
metadata:
4633
name: cluster
4734
spec:
48-
multus:
49-
delegates: |
50-
[{
51-
"type": "flannel",
52-
"name": "flannel.1",
53-
"delegate": {
54-
"isDefaultGateway": true
55-
}
56-
}]
35+
multus: {}
5736
```
5837

5938
Additionally, container image used to deliver this plugin can be set using
6039
`MULTUS_IMAGE` environment variable in operator deployment manifest.
6140

62-
### On OpenShift 4
63-
64-
OpenShift 4 is shipped with [Cluster Network Operator](https://github.com/openshift/cluster-network-operator). OpenShift operator already supports Multus deployment. Therefore, if Multus is requested in our operator using `multus` attribute, we just make sure that is is not disabled in the OpenShift one.
65-
66-
```yaml
67-
apiVersion: networkaddonsoperator.network.kubevirt.io/v1alpha1
68-
kind: NetworkAddonsConfig
69-
metadata:
70-
name: cluster
71-
spec:
72-
multus: {}
73-
```
41+
**Note:** OpenShift 4 is shipped with [Cluster Network Operator](https://github.com/openshift/cluster-network-operator). OpenShift operator already supports Multus deployment. Therefore, if Multus is requested in our operator using `multus` attribute, we just make sure that is is not disabled in the OpenShift one.
7442

7543
## Linux Bridge
7644

@@ -109,15 +77,7 @@ kind: NetworkAddonsConfig
10977
metadata:
11078
name: cluster
11179
spec:
112-
multus:
113-
delegates: |
114-
[{
115-
"type": "flannel",
116-
"name": "flannel.1",
117-
"delegate": {
118-
"isDefaultGateway": true
119-
}
120-
}]
80+
multus: {}
12181
linuxBridge: {}
12282
EOF
12383
```

config-example.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,5 @@ kind: NetworkAddonsConfig
33
metadata:
44
name: cluster
55
spec:
6-
multus:
7-
delegates: |
8-
[{
9-
"type": "flannel",
10-
"name": "flannel.1",
11-
"delegate": {
12-
"isDefaultGateway": true
13-
}
14-
}]
6+
multus: {}
157
linuxBridge: {}

data/multus/002-multus.yaml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ spec:
2121
config:
2222
type: string
2323
---
24-
kind: ConfigMap
25-
apiVersion: v1
26-
metadata:
27-
name: multus-cni-config
28-
namespace: multus
29-
labels:
30-
tier: node
31-
app: multus
32-
data:
33-
00-multus.json: |
34-
{
35-
"name": "multus-cni-network",
36-
"type": "multus",
37-
"delegates": {{ .MultusDelegates | indent 8}},
38-
"kubeconfig": "/etc/cni/net.d/multus.d/multus.kubeconfig"
39-
}
40-
---
4124
apiVersion: extensions/v1beta1
4225
kind: DaemonSet
4326
metadata:
@@ -62,7 +45,7 @@ spec:
6245
containers:
6346
- name: kube-multus
6447
command: ["/entrypoint.sh"]
65-
args: ["--multus-conf-file=/usr/src/multus-cni/images/00-multus.json"]
48+
args: ["--multus-conf-file=auto"]
6649
image: {{ .MultusImage }}
6750
resources:
6851
requests:
@@ -78,15 +61,10 @@ spec:
7861
mountPath: /host/etc/cni/net.d
7962
- name: cnibin
8063
mountPath: /host/opt/cni/bin
81-
- name: multus-cfg
82-
mountPath: /usr/src/multus-cni/images/
8364
volumes:
8465
- name: cni
8566
hostPath:
8667
path: /etc/cni/net.d
8768
- name: cnibin
8869
hostPath:
8970
path: /opt/cni/bin
90-
- name: multus-cfg
91-
configMap:
92-
name: multus-cni-config

pkg/apis/networkaddonsoperator/v1alpha1/networkaddonsconfig_types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ type NetworkAddonsConfigSpec struct {
1212
}
1313

1414
// +k8s:openapi-gen=true
15-
type Multus struct {
16-
Delegates string `json:"delegates,omitempty"`
17-
}
15+
type Multus struct{}
1816

17+
// +k8s:openapi-gen=true
1918
type LinuxBridge struct{}
2019

2120
// NetworkAddonsConfigStatus defines the observed state of NetworkAddonsConfig

pkg/network/multus.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ func validateMultus(conf *opv1alpha1.NetworkAddonsConfigSpec, openshiftNetworkCo
1919
return []error{}
2020
}
2121

22-
if openshiftNetworkConfig == nil {
23-
if conf.Multus.Delegates == "" {
24-
return []error{errors.Errorf("if multus is used, delegates must be specified")}
25-
}
26-
// TODO notify that multus configuration is left for openshift
27-
} else {
22+
if openshiftNetworkConfig != nil {
2823
if openshiftNetworkConfig.Spec.DisableMultiNetwork == newTrue() {
2924
return []error{errors.Errorf("multus has been requested, but is disabled on OpenShift Cluster Network Operator")}
3025
}
@@ -49,7 +44,6 @@ func renderMultus(conf *opv1alpha1.NetworkAddonsConfigSpec, manifestDir string,
4944
// render manifests from disk
5045
data := render.MakeRenderData()
5146
data.Data["MultusImage"] = os.Getenv("MULTUS_IMAGE")
52-
data.Data["MultusDelegates"] = conf.Multus.Delegates
5347
data.Data["EnableSCC"] = enableSCC
5448

5549
objs, err := render.RenderDir(filepath.Join(manifestDir, "multus"), &data)

0 commit comments

Comments
 (0)