Skip to content

Commit

Permalink
Added vrouter_dpdk role
Browse files Browse the repository at this point in the history
Change-Id: I25f96652ccfc2865c14a1a97c1eb7676d803aa88
Partial-Bug: #1743610
  • Loading branch information
alexey-mr committed Feb 18, 2018
1 parent 656e2da commit f52bd72
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 23 deletions.
40 changes: 20 additions & 20 deletions README.md
@@ -1,12 +1,12 @@
# contrail-container-deployer

This set of playbooks installs Contrail Networking using a microservices architecture.
This set of playbooks installs Contrail Networking using a microservices architecture.

## container grouping

All processes are running in their own container.
The containers are grouped together into services, similiar to PODs
in kubernetes.
All processes are running in their own container.
The containers are grouped together into services, similiar to PODs
in kubernetes.

```
+-------------+
Expand Down Expand Up @@ -44,26 +44,26 @@ in kubernetes.
## Prerequisites

- CentOS 7.4
- working name resolution through either DNS or host file for long and short hostnames of the cluster nodes
- docker engine (tested with 17.03.1-ce)
- docker-compose (tested with 1.17.0) installed
- docker-compose python library (tested with 1.9.0)
- in case of k8s will be used, the tested version is 1.9.2.0
- for HA, the time must be in sync between the cluster nodes
- working name resolution through either DNS or host file for long and short hostnames of the cluster nodes
- docker engine (tested with 17.03.1-ce)
- docker-compose (tested with 1.17.0) installed
- docker-compose python library (tested with 1.9.0)
- in case of k8s will be used, the tested version is 1.9.2.0
- for HA, the time must be in sync between the cluster nodes

## instructions

### get the playbooks
### get the playbooks

```
git clone http://github.com/Juniper/contrail-ansible-deployer
```

### configuration
### configuration

#### container host configuration (inventory/hosts)

This file defines the hosts hosting the containers.
This file defines the hosts hosting the containers.
```
vi inventory/hosts
container_hosts:
Expand All @@ -77,14 +77,14 @@ container_hosts:
```
#### Contrail configuration

In case no configuration is provided, the playbook will do an all in one installation
on all hosts specified in inventory/hosts.
The following roles are installed by default:
['analytics', 'analytics_database', 'config', 'config_database', 'control', 'k8s_master', 'vrouter', 'webui']
The registry defaults to opencontrailnightly and the latest tag of the container.
In case no configuration is provided, the playbook will do an all in one installation
on all hosts specified in inventory/hosts.
The following roles are installed by default:
['analytics', 'analytics_database', 'config', 'config_database', 'control', 'k8s_master', 'vrouter', 'webui']
The registry defaults to opencontrailnightly and the latest tag of the container.

For customization the file inventory/group_vars/container_hosts.yml must be created.
The inventory/group_vars directory contains some examples.
For customization the file inventory/group_vars/container_hosts.yml must be created.
The inventory/group_vars directory contains some examples.
In this file the following settings can be set:

- Contrail Service configuration
Expand Down
78 changes: 78 additions & 0 deletions playbooks/roles/create_containers/tasks/create_vrouter_dpdk.yml
@@ -0,0 +1,78 @@
---
- name: create /etc/contrail/vrouter
file:
path: /etc/contrail/vrouter
state: directory
recurse: yes

- name: "get /etc/contrail/common_vrouter.env stat"
stat:
path: "/etc/contrail/common_vrouter.env"
register: st

- name: "delete /etc/contrail/common_vrouter.env if exists"
file:
path: "/etc/contrail/common_vrouter.env"
state: absent
when: st.stat.exists is defined and st.stat.exists

- name: "create /etc/contrail/common_vrouter.env"
file:
path: "/etc/contrail/common_vrouter.env"
state: touch

- name: "populate cluster wide common_vrouter.env"
lineinfile: dest=/etc/contrail/common_vrouter.env regexp='.*{{ item.key }}$' line="{{ item.key }}={{ item.value }}" state=present
with_dict: "{{ contrail_configuration }}"

- name: "populate pod specific common_vrouter.env"
lineinfile: dest=/etc/contrail/common_vrouter.env regexp='.*{{ config_item.key }}$' line="{{ config_item.key }}={{ config_item.value }}" state=present
with_dict: "{{ roles[inventory_hostname].vrouter_dpdk }}"
loop_control:
loop_var: config_item
ignore_errors: yes

- name: get pop
set_fact:
pop: "{{ roles[inventory_hostname].vrouter_dpdk.location }}"
when: roles[inventory_hostname].vrouter_dpdk.location is defined

- name: "populate pop settings"
lineinfile: dest=/etc/contrail/common_vrouter.env regexp='.*{{ pop_config.key }}$' line="{{ pop_config.key }}={{ pop_config.value }}" state=present
with_dict: "{{ remote_locations[pop] }}"
loop_control:
loop_var: pop_config
when: pop is defined

- name: calculate XMPP port if not assigned
set_fact:
xmpp_port: "{{ remote_locations[pop].CLUSTER_ID|int + 15268 }}"
when: pop is defined and remote_locations[pop].XMPP_SERVER_PORT is undefined

- name: set XMPP_SERVER_PORT port if assigned
set_fact:
xmpp_port: "{{ remote_locations[pop].XMPP_SERVER_PORT }}"
when: pop is defined and remote_locations[pop].XMPP_SERVER_PORT is defined

- name: "populate xmpp port"
lineinfile: dest=/etc/contrail/common_vrouter.env regexp='.*XMPP_SERVER_PORT$' line="XMPP_SERVER_PORT={{ xmpp_port }}" state=present
when: xmpp_port is defined

- name: update image
shell: "docker pull {{ container_registry }}/{{ item }}:{{ contrail_version_tag }}"
with_items:
- contrail-nodemgr
- contrail-agent-vrouter-init-kernel-dpdk
- contrail-agent-vrouter-dpdk
- contrail-agent-net-watchdog
- contrail-agent-vrouter
when: UPDATE_IMAGES is undefined or UPDATE_IMAGES != false

- name: "create contrail vrouter compose file"
template:
src: contrail-vrouter-dpdk.yaml.j2
dest: "/etc/contrail/vrouter/docker-compose.yaml"

- name: "start contrail vrouter"
docker_service:
project_src: /etc/contrail/vrouter
8 changes: 7 additions & 1 deletion playbooks/roles/create_containers/tasks/main.yml
Expand Up @@ -5,7 +5,7 @@
when: contrail_configuration is undefined
tags:
- always

- name: set container tag contrail version to master if not defined
set_fact:
contrail_version_tag: latest
Expand Down Expand Up @@ -178,6 +178,12 @@
tags:
- vrouter

- name: create contrail vrouter dpdk
include: create_vrouter_dpdk.yml
when: roles[inventory_hostname].vrouter_dpdk is defined
tags:
- vrouter

- name: set master
include: set_master.yml
when: roles[inventory_hostname].k8s_master is defined or roles[inventory_hostname].k8s_node is defined
Expand Down
@@ -0,0 +1,77 @@
version: '2'
services:
nodemgr:
image: "{{ container_registry }}/contrail-nodemgr:{{ contrail_version_tag }}"
env_file: /etc/contrail/common_vrouter.env
environment:
- NODE_TYPE=vrouter
network_mode: host
volumes:
- /var/log/contrail:/var/log/contrail
- /var/run/docker.sock:/var/run/docker.sock
- /etc/contrail/vrouter:/etc/contrail
restart: on-failure
vrouter-init-kernel-dpdk:
image: "{{ container_registry }}/contrail-agent-vrouter-init-kernel-dpdk:{{ contrail_version_tag }}"
env_file: /etc/contrail/common_vrouter.env
environment:
- AGENT_MODE=dpdk
network_mode: host
privileged: true
pid: host
volumes:
- /dev:/dev
- /lib/modules:/lib/modules
- /var/run:/var/run
- /var/log/contrail:/var/log/contrail
- /etc/contrail/vrouter:/etc/contrail
vrouter-agent-dpdk:
image: "{{ container_registry }}/contrail-agent-vrouter-dpdk:{{ contrail_version_tag }}"
env_file: /etc/contrail/common_vrouter.env
environment:
- AGENT_MODE=dpdk
network_mode: host
pid: host
privileged: true
volumes:
- /dev:/dev
- /lib/modules:/lib/modules
- /var/run:/var/run
- /var/log/contrail:/var/log/contrail
- /etc/contrail/vrouter:/etc/contrail
restart: on-failure
depends_on:
- vrouter-init-kernel-dpdk
vrouter-agent-net-watchdog:
image: "{{ container_registry }}/contrail-agent-net-watchdog:{{ contrail_version_tag }}"
env_file: /etc/contrail/common_vrouter.env
environment:
- AGENT_MODE=dpdk
network_mode: host
privileged: true
volumes:
- /dev:/dev
- /etc/sysconfig/network-scripts:/etc/sysconfig/network-scripts
- /lib/modules:/lib/modules
- /var/run:/var/run
- /var/log/contrail:/var/log/contrail
- /etc/contrail/vrouter:/etc/contrail
restart: on-failure
depends_on:
- vrouter-agent-dpdk
vrouter-agent:
image: "{{ container_registry }}/contrail-agent-vrouter:{{ contrail_version_tag }}"
env_file: /etc/contrail/common_vrouter.env
environment:
- AGENT_MODE=dpdk
network_mode: host
privileged: true
volumes:
- /dev:/dev
- /lib/modules:/lib/modules
- /var/run:/var/run
- /var/log/contrail:/var/log/contrail
- /etc/contrail/vrouter:/etc/contrail
restart: on-failure
depends_on:
- vrouter-agent-net-watchdog
4 changes: 2 additions & 2 deletions playbooks/roles/test/tasks/main.yml
Expand Up @@ -6,9 +6,9 @@
- []

- name: create roles
set_fact:
set_fact:
default_roles_hosts: "{{ default_roles_hosts|default({})|combine({item: default_roles}, recursive=True) }}"
with_items:
with_items:
- "{{ groups['container_hosts'] }}"
when: roles is undefined

Expand Down

0 comments on commit f52bd72

Please sign in to comment.