forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for Multus (multiple interfaces) CNI plugin (kubernetes-…
…sigs#3166) * Adds support for Multus (multiple interfaces) CNI plugin Multus is a latin word for "Multi". As the name suggests, it acts as a Multi plugin in Kubernetes and provides multiple network interface support in a pod. Multus uses the concept of invoking delegates by grouping multiple plugins into delegates and invoking them in the sequential order of the CNI configuration file provided in json format. * Change CNI version (0.1.0->0.3.1) of Contiv to be compatible with Multus
- Loading branch information
1 parent
3c5f201
commit bc9e14a
Showing
19 changed files
with
344 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Multus | ||
=========== | ||
|
||
Multus is a meta CNI plugin that provides multiple network interface support to | ||
pods. For each interface, Multus delegates CNI calls to secondary CNI plugins | ||
such as Calico, macvlan, etc. | ||
|
||
See [multus documentation](https://github.com/intel/multus-cni). | ||
|
||
## Multus installation | ||
|
||
Since Multus itself does not implement networking, it requires a master plugin, which is specified through the variable `kube_network_plugin`. To enable Multus an additional variable `kube_network_plugin_multus` must be set to `true`. For example, | ||
``` | ||
kube_network_plugin: calico | ||
kube_network_plugin_multus: true | ||
``` | ||
will install Multus and Calico and configure Multus to use Calico as the primary network plugin. | ||
|
||
## Using Multus | ||
|
||
Once Multus is installed, you can create CNI configurations (as a CRD objects) for additional networks, in this case a macvlan CNI configuration is defined. You may replace the config field with any valid CNI configuration where the CNI binary is available on the nodes. | ||
|
||
``` | ||
cat <<EOF | kubectl create -f - | ||
apiVersion: "k8s.cni.cncf.io/v1" | ||
kind: NetworkAttachmentDefinition | ||
metadata: | ||
name: macvlan-conf | ||
spec: | ||
config: '{ | ||
"cniVersion": "0.3.0", | ||
"type": "macvlan", | ||
"master": "eth0", | ||
"mode": "bridge", | ||
"ipam": { | ||
"type": "host-local", | ||
"subnet": "192.168.1.0/24", | ||
"rangeStart": "192.168.1.200", | ||
"rangeEnd": "192.168.1.216", | ||
"routes": [ | ||
{ "dst": "0.0.0.0/0" } | ||
], | ||
"gateway": "192.168.1.1" | ||
} | ||
}' | ||
EOF | ||
``` | ||
|
||
You may then create a pod with and additional interface that connects to this network using annotations. The annotation correlates to the name in the NetworkAttachmentDefinition above. | ||
|
||
``` | ||
cat <<EOF | kubectl create -f - | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: samplepod | ||
annotations: | ||
k8s.v1.cni.cncf.io/networks: macvlan-conf | ||
spec: | ||
containers: | ||
- name: samplepod | ||
command: ["/bin/bash", "-c", "sleep 2000000000000"] | ||
image: dougbtv/centos-network | ||
EOF | ||
``` | ||
|
||
You may now inspect the pod and see that there is an additional interface configured: | ||
|
||
``` | ||
$ kubectl exec -it samplepod -- ip a | ||
``` | ||
|
||
For more details on how to use Multus, please visit https://github.com/intel/multus-cni |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
roles/kubernetes-apps/network_plugin/multus/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Multus | Start resources | ||
kube: | ||
name: "{{item.item.name}}" | ||
namespace: "kube-system" | ||
kubectl: "{{bin_dir}}/kubectl" | ||
resource: "{{item.item.type}}" | ||
filename: "{{kube_config_dir}}/{{item.item.file}}" | ||
state: "latest" | ||
with_items: "{{ multus_manifest_1.results }} + {{multus_manifest_2.results }}" | ||
when: inventory_hostname == groups['kube-master'][0] and not item|skipped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
multus_conf_file: "auto" | ||
multus_cni_conf_dir_host: "/etc/cni/net.d" | ||
multus_cni_bin_dir_host: "/opt/cni/bin" | ||
multus_cni_conf_dir: "{{ ('/host', multus_cni_conf_dir_host) | join }}" | ||
multus_cni_bin_dir: "{{ ('/host', multus_cni_bin_dir_host) | join }}" | ||
multus_kubeconfig_file_host: "{{ (multus_cni_conf_dir_host, '/multus.d/multus.kubeconfig') | join }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
metadata: | ||
name: multus | ||
rules: | ||
- apiGroups: | ||
- '*' | ||
resources: | ||
- '*' | ||
verbs: | ||
- '*' | ||
- nonResourceURLs: | ||
- '*' | ||
verbs: | ||
- '*' |
13 changes: 13 additions & 0 deletions
13
roles/network_plugin/multus/files/multus-clusterrolebinding.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
metadata: | ||
name: multus | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: multus | ||
subjects: | ||
- kind: ServiceAccount | ||
name: multus | ||
namespace: kube-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
kind: CustomResourceDefinition | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
metadata: | ||
name: network-attachment-definitions.k8s.cni.cncf.io | ||
spec: | ||
group: k8s.cni.cncf.io | ||
version: v1 | ||
scope: Namespaced | ||
names: | ||
plural: network-attachment-definitions | ||
singular: network-attachment-definition | ||
kind: NetworkAttachmentDefinition | ||
shortNames: | ||
- net-attach-def | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
spec: | ||
properties: | ||
config: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: multus | ||
namespace: kube-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Multus | Copy manifest files | ||
copy: | ||
src: "{{ item.file }}" | ||
dest: "{{ kube_config_dir }}" | ||
with_items: | ||
- {name: multus-crd, file: multus-crd.yml, type: customresourcedefinition} | ||
- {name: multus-serviceaccount, file: multus-serviceaccount.yml, type: serviceaccount} | ||
- {name: multus-clusterrole, file: multus-clusterrole.yml, type: clusterrole} | ||
- {name: multus-clusterrolebinding, file: multus-clusterrolebinding.yml, type: clusterrolebinding} | ||
register: multus_manifest_1 | ||
|
||
- name: Multus | Copy manifest templates | ||
template: | ||
src: "{{ item.file }}.j2" | ||
dest: "{{ kube_config_dir }}/{{ item.file }}" | ||
with_items: | ||
- {name: multus-daemonset, file: multus-daemonset.yml, type: daemonset} | ||
register: multus_manifest_2 |
54 changes: 54 additions & 0 deletions
54
roles/network_plugin/multus/templates/multus-daemonset.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
kind: DaemonSet | ||
apiVersion: extensions/v1beta1 | ||
metadata: | ||
name: kube-multus-ds-amd64 | ||
namespace: kube-system | ||
labels: | ||
tier: node | ||
app: multus | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
tier: node | ||
app: multus | ||
spec: | ||
hostNetwork: true | ||
nodeSelector: | ||
beta.kubernetes.io/arch: amd64 | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
effect: NoSchedule | ||
serviceAccountName: multus | ||
containers: | ||
- name: kube-multus | ||
image: {{ multus_image_repo }}:{{ multus_image_tag }} | ||
command: ["/entrypoint.sh"] | ||
args: | ||
- "--cni-conf-dir={{ multus_cni_conf_dir }}" | ||
- "--cni-bin-dir={{ multus_cni_bin_dir }}" | ||
- "--multus-conf-file={{ multus_conf_file }}" | ||
- "--multus-kubeconfig-file-host={{ multus_kubeconfig_file_host }}" | ||
resources: | ||
requests: | ||
cpu: "100m" | ||
memory: "50Mi" | ||
limits: | ||
cpu: "100m" | ||
memory: "50Mi" | ||
securityContext: | ||
privileged: true | ||
volumeMounts: | ||
- name: cni | ||
mountPath: {{ multus_cni_conf_dir }} | ||
- name: cnibin | ||
mountPath: {{ multus_cni_bin_dir }} | ||
volumes: | ||
- name: cni | ||
hostPath: | ||
path: {{ multus_cni_conf_dir_host }} | ||
- name: cnibin | ||
hostPath: | ||
path: {{ multus_cni_bin_dir_host }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Instance settings | ||
cloud_image_family: centos-7 | ||
cloud_region: us-central1-c | ||
cloud_machine_type: "n1-standard-1" | ||
mode: default | ||
|
||
# Deployment settings | ||
kube_network_plugin_multus: true | ||
kube_network_plugin: calico | ||
deploy_netchecker: true | ||
kubedns_min_replicas: 1 | ||
cloud_provider: gce |
Oops, something went wrong.