add opencontrail
Change-Id: I1b1d47756fadbd0a2fa5a717ff728784aac8868f
diff --git a/kubernetes/files/opencontrail/kube-network-manager.manifest b/kubernetes/files/opencontrail/kube-network-manager.manifest
new file mode 100644
index 0000000..85b30fa
--- /dev/null
+++ b/kubernetes/files/opencontrail/kube-network-manager.manifest
@@ -0,0 +1,25 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+{
+ "apiVersion": "v1",
+ "kind": "Pod",
+ "metadata": {
+ "namespace": "default",
+ "name": "kube-network-manager"
+ },
+ "spec":{
+ "hostNetwork": true,
+ "containers":[{
+ "name": "kube-network-manager",
+ "image": "{{ master.network.get('image', 'yashulyak/contrail-controller') }}:{{ master.network.get('image', 'latest') }}",
+ "command": ["/usr/sbin/kube-network-manager", "--logtostderr", "--v=5"],
+ "volumeMounts": [{
+ "name": "config",
+ "mountPath": "/etc/kubernetes"
+ }]
+ }],
+ "volumes": [{
+ "name": "config",
+ "hostPath": {"path": "/etc/kubernetes"}
+ }]
+ }
+}
diff --git a/kubernetes/files/opencontrail/network.conf b/kubernetes/files/opencontrail/network.conf
index a40cabd..7db48f1 100644
--- a/kubernetes/files/opencontrail/network.conf
+++ b/kubernetes/files/opencontrail/network.conf
@@ -1,15 +1,15 @@
{%- from "kubernetes/map.jinja" import master with context %}
[DEFAULT]
-service-cluster-ip-range = {{ master.network.service_cluster_ip_range }}
+service-cluster-ip-range = {{ master.service_addresses }}
[opencontrail]
-default-domain = {{ master.network.default_domain }}
+default-domain = {{ master.network.get('default_domain', 'default-domain') }}
public-ip-range = {{ master.network.public_ip_range }}
-cluster-service = {{ master.network.cluster_service }}
-api-server = {{ master.network.host }}
-api-port = {{ master.network.port }}
-default-project = {{ master.network.default_project }}
+cluster-service = {{ master.network.get('cluster_service', 'kube-system/default') }}
+api-server = {{ master.network.opencontrail.address }}
+api-port = {{ master.network.get('port', '8082') }}
+default-project = {{ master.network.get('default_project','default-domain:default-project') }}
public-network = {{ master.network.public_network }}
private-ip-range = {{ master.network.private_ip_range }}
-network-label = {{ master.network.network_label }}
-service-label = {{ master.network.service_label }}
\ No newline at end of file
+network-label = {{ master.network.get('network_label','name') }}
+service-label = {{ master.network.get('service_label','uses') }}
\ No newline at end of file
diff --git a/kubernetes/files/opencontrail/opencontrail.conf b/kubernetes/files/opencontrail/opencontrail.conf
new file mode 100644
index 0000000..a1ba7f4
--- /dev/null
+++ b/kubernetes/files/opencontrail/opencontrail.conf
@@ -0,0 +1,18 @@
+{%- from "kubernetes/map.jinja" import pool with context %}
+{
+ "cniVersion": "0.2.0",
+ "contrail" : {
+ "apiserver": {"address": "{{ pool.network.opencontrail.address }}", "port": {{ pool.network.opencontrail.get('port', 8082) }}, "default-domain": "default-domain"},
+ "vrouter" : {
+ "ip" : "127.0.0.1",
+ "port" : 9091
+ },
+ "dir" : "/var/lib/contrail/ports"
+ },
+ "log" : {
+ "dir" : "/var/log/contrail/cni",
+ "level" : "10"
+ },
+ "name": "opencontrail",
+ "type": "opencontrail"
+}
diff --git a/kubernetes/master/init.sls b/kubernetes/master/init.sls
index 310746a..e528c1e 100644
--- a/kubernetes/master/init.sls
+++ b/kubernetes/master/init.sls
@@ -3,7 +3,7 @@
- kubernetes.master.service
- kubernetes.master.kube-addons
{%- if master.network.engine == "opencontrail" %}
-- kubernetes.master.opencontrail-network-manager
+- kubernetes.master.opencontrail
{%- endif %}
{%- if master.network.engine == "flannel" %}
- kubernetes.master.flannel
diff --git a/kubernetes/master/opencontrail.sls b/kubernetes/master/opencontrail.sls
new file mode 100644
index 0000000..c13a6c9
--- /dev/null
+++ b/kubernetes/master/opencontrail.sls
@@ -0,0 +1,24 @@
+{%- from "kubernetes/map.jinja" import master with context %}
+{%- if master.enabled %}
+
+/etc/kubernetes/manifests/kube-network-manager.manifest:
+ file.managed:
+ - source: salt://kubernetes/files/opencontrail/kube-network-manager.manifest
+ - user: root
+ - group: root
+ - mode: 644
+ - makedirs: true
+ - dir_mode: 755
+ - template: jinja
+
+/etc/kubernetes/network.conf:
+ file.managed:
+ - source: salt://kubernetes/files/opencontrail/network.conf
+ - user: root
+ - group: root
+ - mode: 644
+ - makedirs: true
+ - dir_mode: 755
+ - template: jinja
+
+{%- endif %}
\ No newline at end of file
diff --git a/kubernetes/pool/opencontrail.sls b/kubernetes/pool/opencontrail.sls
new file mode 100644
index 0000000..b0f43ab
--- /dev/null
+++ b/kubernetes/pool/opencontrail.sls
@@ -0,0 +1,15 @@
+{%- from "kubernetes/map.jinja" import pool with context %}
+{%- if pool.enabled %}
+
+/etc/cni/net.d/11-opencontrail.conf:
+ file.managed:
+ - source: salt://kubernetes/files/opencontrail/opencontrail.conf
+ - user: root
+ - group: root
+ - mode: 644
+ - makedirs: true
+ - dir_mode: 755
+ - template: jinja
+
+
+{%- endif %}