Skip to content

Commit

Permalink
Simplify Multus install options
Browse files Browse the repository at this point in the history
To address redhat-nfvpe#245 and redhat-nfvpe#258, this change fixes followings:
 + rename multus_npwg_demo to multus-2nics
 + make multus_use_crd default
 + add multus_build flag
   (if no/false, use daemonset yaml in github/multus)
 + unsupport legacy multus version
 + add docker_install_suppress_newgrp for latest ansible
 + fix daemonset yaml to support latest k8s
 + fix several build script (e.g. sr-iov cni)

Verified it under following combinations:
 + pod_network_type=none
 + pod_network_type=multus
 + pod_network_type=multus + multus_build=true
 + pod_network_type=none + multus_build=true
 + pod_network_type=multus-2nics
 + pod_network_type=multus-2nics + multus_build=true
  • Loading branch information
s1061123 committed Dec 27, 2018
1 parent e276a06 commit b586fa3
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 435 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Playbooks are located in the `playbooks/` directory.
| `kube-install.yml` | `./inventory/vms.local.generated` | Install and configure a k8s cluster |
| `kube-teardown.yml` | `./inventory/vms.local.generated` | Runs `kubeadm reset` on all nodes to tear down k8s |
| `vm-teardown.yml` | `./inventory/virthost/` | Destroys VMs on the virtual machine host |
| `ka-multus-cni/multus-cni.yml` | `./inventory/vms.local.generated` | Compiles [multus-cni](https://github.com/Intel-Corp/multus-cni) |
| `ka-multus-cni/multus-cni.yml` | `./inventory/vms.local.generated` | Compiles [multus-cni](https://github.com/intel/multus-cni) |
| `ka-gluster-install/gluster-install.yml` | `./inventory/vms.local.generated` | Install a GlusterFS cluster across VMs (requires vm-attach-disk) |
| `fedora-python-bootstrapper.yml` | `./inventory/vms.local.generated` | Bootstrapping Python dependencies on cloud images |
| `ka-builder/builder.yml` | `./inventory/vms.local.generated` | Build a Kubernetes release in a dedicated virtual machine |
Expand Down
3 changes: 3 additions & 0 deletions inventory/examples/crio/crio.inventory
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This file is used for build/install crio, with crio_build_install
kube-master ansible_host=master.example.local
kube-node-1 ansible_host=node.example.local
vmhost ansible_host=virt-host.example.local ansible_ssh_user=root
Expand Down Expand Up @@ -25,6 +26,7 @@ kubectl_home=/home/fedora
kubectl_user=fedora
kubectl_group=fedora
# Using CRI-O (you must set this as an extra var, e.g. `-e "container_runtime=crio"`)
# crio_build_install=true
# container_runtime=crio

[nodes:vars]
Expand All @@ -35,6 +37,7 @@ kubectl_home=/home/fedora
kubectl_user=fedora
kubectl_group=fedora
# Using CRI-O (you must set this as an extra var, e.g. `-e "container_runtime=crio"`)
# crio_build_install=true
# container_runtime=crio

# Need to set crio_versions for installed kubernetes version, see following URL for details.
Expand Down
6 changes: 6 additions & 0 deletions inventory/examples/multus-2nics/extra-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Note:
# You need to set -e 'network_type=multus-2nics' in case of playbooks/virthost-setup.yml
# to create 2nic environment.
---
pod_network_type: "multus-2nics"
multus_version: "master"
6 changes: 0 additions & 6 deletions inventory/examples/multus/multus-extravars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ virtual_machines:
optional_packages:
- tcpdump
- bind-utils
multus_use_crd: true
multus_ipam_subnet: "192.168.1.0/24"
multus_ipam_rangeStart: "192.168.1.200"
multus_ipam_rangeEnd: "192.168.1.216"
multus_ipam_gateway: "192.168.1.1"
multus_macvlan_master: "eth0"
28 changes: 0 additions & 28 deletions inventory/examples/multus/v1.multus-extravars.yml

This file was deleted.

5 changes: 0 additions & 5 deletions inventory/examples/npwg-demo-1/extra-vars.yml

This file was deleted.

12 changes: 6 additions & 6 deletions playbooks/ka-init/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# - crio
container_runtime: docker

# --------------------------- -
# docker vars - -
# --------------------------- -
docker_install_suppress_newgrp: true

# --------------------------- -
# crio vars - -
# --------------------------- -
Expand Down Expand Up @@ -88,14 +93,9 @@ kubectl_proxy_port: 8088
# multus-cni vars - -
# ------------------------- -
# Usually use "master" for multus version, but, otherwise...
multus_build: false
multus_version: master
multus_npwg_demo: false
multus_git_url: "https://github.com/intel/multus-cni.git"
multus_use_crd: true
multus_ipam_subnet: "192.168.1.0/24"
multus_ipam_rangeStart: "192.168.1.200"
multus_ipam_rangeEnd: "192.168.1.216"
multus_ipam_gateway: "192.168.1.1"

# ----------------------------
# glusterfs vars
Expand Down
4 changes: 0 additions & 4 deletions playbooks/ka-multus-cni/test-multus.yml

This file was deleted.

12 changes: 3 additions & 9 deletions playbooks/kube-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
become_user: root
tasks: []
roles:
- { role: npwg-poc1-setup, when: pod_network_type == 'multus' and multus_npwg_demo }
- { role: multus-2nics-setup, when: pod_network_type == 'multus-2nics' }
- { role: bridge-setup, when: pod_network_type == 'bridge' }
- { role: optional-packages }
# You can add "crio_force: true" if you need to run the builds again.
- { role: cri-o-install, when: container_runtime == 'crio', crio_force: false }
- { role: buildah-install, when: buildah_install|bool }
- { role: install-docker, when: container_runtime == 'docker' }
- { role: kube-install }
- { role: multus-cni, when: pod_network_type == "multus" }
- { role: multus-cni, when: multus_build|bool }

- hosts: master,nodes
become: true
Expand All @@ -41,15 +41,9 @@
- hosts: master
tasks: []
roles:
- { role: kube-cni, when : "pod_network_type != 'none'"}
- { role: kube-cni, when : "pod_network_type != 'none'" }
- { role: kube-niceties }


- hosts: master
tasks: []
roles:
- { role: multus-crd, when: "pod_network_type == 'multus' and multus_use_crd and not multus_npwg_demo"}

- hosts: nodes
become: true
become_user: root
Expand Down
22 changes: 15 additions & 7 deletions roles/kube-cni/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
kubectl create -f /etc/flannel-rbac.yaml
args:
creates: "{{ kubectl_home }}/.kubeadm-podnetwork-complete"
when: pod_network_type == "flannel" or pod_network_type == "multus"
when: >
pod_network_type == "flannel"
- name: Apply the flannel podnetwork
shell: >
Expand All @@ -45,19 +46,26 @@
when: pod_network_type == "weave"

# ----------- multus
- name: Apply the multus podnetwork
- name: Apply the multus podnetwork from github
shell: >
kubectl apply -f /etc/multus.yaml > /tmp/podnetwork-apply.log
kubectl apply -f https://raw.githubusercontent.com/intel/multus-cni/master/images/flannel-daemonset.yml > /tmp/podnetwork-apply.log && \
kubectl apply -f https://raw.githubusercontent.com/intel/multus-cni/master/images/multus-daemonset.yml >> /tmp/podnetwork-apply.log
args:
creates: "{{ kubectl_home }}/.kubeadm-podnetwork-complete"
when: pod_network_type == "multus" and not multus_use_crd
when:
- pod_network_type == "multus" or pod_network_type == "multus-2nics"
- not (multus_build|bool)

- name: Apply the multus podnetwork (CRD style)
# ----------- multus
- name: Apply the multus podnetwork from local
shell: >
kubectl apply -f /etc/multus-crd.yaml > /tmp/podnetwork-apply.log
kubectl create -f /etc/flannel-rbac.yaml > /tmp/podnetwork-apply.log && \
kubectl apply -f /etc/multus-crd.yaml >> /tmp/podnetwork-apply.log
args:
creates: "{{ kubectl_home }}/.kubeadm-podnetwork-complete"
when: pod_network_type == "multus" and multus_use_crd
when:
- pod_network_type == "multus" or pod_network_type == "multus-2nics"
- multus_build|bool


# ----------- calico
Expand Down
8 changes: 1 addition & 7 deletions roles/kube-template-cni/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
---

- name: Template multus.yaml
template:
src: multus.yaml.j2
dest: /etc/multus.yaml
when: not multus_use_crd

- name: Template CRD flavored multus.yaml
template:
src: multus-crd.yaml.j2
dest: /etc/multus-crd.yaml
when: multus_use_crd
when: pod_network_type == 'multus' or pod_network_type == 'multus-2nics'

- name: Template flannel.yaml
template:
Expand Down
5 changes: 2 additions & 3 deletions roles/kube-template-cni/templates/flannel.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ spec:
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
- operator: Exists
effect: NoSchedule
serviceAccountName: flannel
initContainers:
Expand Down Expand Up @@ -120,4 +119,4 @@ spec:
path: /etc/cni/net.d
- name: flannel-cfg
configMap:
name: kube-flannel-cfg
name: kube-flannel-cfg
15 changes: 3 additions & 12 deletions roles/kube-template-cni/templates/multus-crd.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,16 @@ data:
"name": "multus-cni-network",
"type": "multus",
"delegates": [
{% if multus_npwg_demo %}
{
"type": "flannel",
"name": "flannel.1",
"delegate": {
{% if pod_network_type == "multus-2nics" %}
"bridge": "kbr0",
{% endif %}
"isDefaultGateway": true
}
}
{% else %}
{
"type": "flannel",
"name": "flannel.1",
"delegate": {
"isDefaultGateway": true
}
}
{% endif %}
],
"kubeconfig": "/etc/kubernetes/kubelet.conf"
}
Expand Down Expand Up @@ -67,8 +59,7 @@ spec:
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
- operator: Exists
effect: NoSchedule
serviceAccountName: flannel
initContainers:
Expand Down
131 changes: 0 additions & 131 deletions roles/kube-template-cni/templates/multus.yaml.j2

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b586fa3

Please sign in to comment.