Auto-generate multus conf. Do not exit sriov DS

Instead of relying on configmap to be created/customized by the user to
generate multus conf, we autogenerate it using the current default CNI
conf file on the host. This way CNI's with host specific conf details
will continue to work.

```
{
  "type": "calico",
  "nodename": "clr-01",
   ...
}
```

Since SR-IOV device may not be present on all nodes, the daemonset
should not exit as this will put the pod in restart loop. This would
cause the kubelet and runtimes to repeatedly restart, as per
initContainer logic.

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
This commit is contained in:
Saikrishna
2019-01-08 19:53:27 +00:00
committed by Manohar Castelino
parent 39f3e063d3
commit 42ffa8df71
3 changed files with 26 additions and 41 deletions
+3 -5
View File
@@ -5,15 +5,13 @@
We launch a `Daemonset` with an `initContainer` which sets up the CNI
directories on the host with the necessary binaries and configuration files.
### Customization
> NOTE: SR-IOV devices are not necessary to test multi-network capability
Replace `flannel` configuration in the delegates section with contents of your
default network's cni configuration in [multus-conf.yaml](clr-k8s-examples/9-multi-network/multus-conf.yaml).
### Customization
The device plugin will register the SR-IOV enabled devices on the host, specified
as `rootDevices` in [sriov-conf.yaml](clr-k8s-examples/9-multi-network/sriov-conf.yaml).
> Helper [systemd](clr-k8s-examples/9-multi-network/systemd/sriov.service) example config
Helper [systemd](clr-k8s-examples/9-multi-network/systemd/sriov.service) example config
is provided, which enables SR-IOV for the above `rootDevices`
> NOTE: This assumes homogenous nodes in the cluster
@@ -1,21 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: multus-conf
namespace: kube-system
data:
01-cni-conf.json: |
{
"name": "multus-cni-network",
"type": "multus",
"delegates": [
{
"type": "flannel",
"delegate": {
"isDefaultGateway": true
}
}
],
"kubeconfig": "/etc/cni/net.d/multus-kubeconfig"
}
@@ -55,7 +55,7 @@ rules:
kind: ConfigMap
apiVersion: v1
metadata:
name: multus-certs
name: multus-scripts
namespace: kube-system
data:
install-certs.sh: |
@@ -87,6 +87,21 @@ data:
user: multus
current-context: multus-context
EOF
install-multus-conf.sh: |
# copied from https://github.com/intel/multus-cni/blob/master/images/entrypoint.sh
rm -f /host/etc/cni/net.d/00-multus.conf
MASTER_PLUGIN="$(ls /host/etc/cni/net.d | grep -E '\.conf(list)?$' | head -1)"
MASTER_PLUGIN_JSON="$(cat /host/etc/cni/net.d/$MASTER_PLUGIN)"
cat > /host/etc/cni/net.d/00-multus.conf <<EOF
{
"name": "multus-cni-network",
"type": "multus",
"kubeconfig": "/etc/cni/net.d/multus-kubeconfig",
"delegates": [
$MASTER_PLUGIN_JSON
]
}
EOF
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
@@ -116,17 +131,15 @@ spec:
name: sriov-device-plugin
spec:
initContainers:
- name: init-sriov-dp
- name: multus
image: ngick8stesting/aio-cni:k8s-1.13
command: [ "bash", "-c" ]
args:
- cp /tmp/cni/bin/{multus,sriov} /host/opt/cni/bin/;
cp /tmp/etc/cni/net.d/* /host/etc/cni/net.d/;
/tmp/multus/install-multus-conf.sh;
/tmp/multus/install-certs.sh;
systemctl stop kubelet;
cp /tmp/bin/kubelet /host/usr/bin/kubelet;
echo "Restarting crio/containerd, kubelet";
systemctl daemon-reload;
systemctl restart containerd;
systemctl restart crio;
systemctl restart kubelet;
@@ -135,11 +148,9 @@ spec:
mountPath: /host/usr/bin
- name: cni-bin
mountPath: /host/opt/cni/bin
- name: multus-cm
mountPath: /tmp/etc/cni/net.d
- name: multus-sa
mountPath: /var/run/secrets/multus/serviceaccount
- name: multus-certs
- name: multus-scripts
mountPath: /tmp/multus
- name: cni-conf
mountPath: /host/etc/cni/net.d
@@ -148,12 +159,12 @@ spec:
- name: systemd
mountPath: /run/systemd
containers:
- name: sriov-dp
- name: sriovdp
image: ngick8stesting/aio-cni:k8s-1.13
command: [ "sh", "-c" ]
args:
- /usr/bin/sriovdp --logtostderr -v 10;
echo "exit status $?";
sleep infinity;
volumeMounts:
- name: net
mountPath: /sys/class/net
@@ -174,16 +185,13 @@ spec:
- name: cni-bin
hostPath:
path: /opt/cni/bin
- name: multus-cm
configMap:
name: multus-conf
- name: multus-sa
secret:
secretName: multus-sa-secret
- name: multus-certs
- name: multus-scripts
configMap:
defaultMode: 511
name: multus-certs
name: multus-scripts
- name: cni-conf
hostPath:
path: /etc/cni/net.d