Cloud provider net options support

Related bug: PROD-25969 (PROD:25969)

Change-Id: I02cbe0899ed4c7cee1f94873430defed6511625b
diff --git a/kubernetes/_common.sls b/kubernetes/_common.sls
index 88a9fcd..ae8a851 100644
--- a/kubernetes/_common.sls
+++ b/kubernetes/_common.sls
@@ -192,6 +192,7 @@
   file.absent
 
 {%- if common.get('cloudprovider', {}).get('enabled') and common.get('cloudprovider', {}).get('provider') == 'openstack' %}
+{%- set cloudconfig_type = 'external' %}
 /etc/kubernetes/cloud-config:
   file.managed:
   - source: salt://kubernetes/files/cloudprovider/cloud-config-openstack.conf
@@ -199,6 +200,21 @@
   - user: root
   - group: root
   - mode: 600
+  - defaults:
+      cloudconfig_type: {{ cloudconfig_type }}
+
+{%- if pillar.kubernetes.master is defined %}
+{%- set cloudconfig_type = 'intree' %}
+/etc/kubernetes/cloud-config.intree:
+  file.managed:
+  - source: salt://kubernetes/files/cloudprovider/cloud-config-openstack.conf
+  - template: jinja
+  - user: root
+  - group: root
+  - mode: 600
+  - defaults:
+      cloudconfig_type: {{ cloudconfig_type }}
+{% endif %}
 
 {% endif %}
 
diff --git a/kubernetes/files/cloudprovider/cloud-config-openstack.conf b/kubernetes/files/cloudprovider/cloud-config-openstack.conf
index 92a1cdd..83bdd8d 100644
--- a/kubernetes/files/cloudprovider/cloud-config-openstack.conf
+++ b/kubernetes/files/cloudprovider/cloud-config-openstack.conf
@@ -22,15 +22,15 @@
 
 
 [LoadBalancer]
-{%- if common.cloudprovider.params.subnet_id is defined %}
 use-octavia=true
+{%- if common.cloudprovider.params.subnet_id is defined %}
 subnet-id={{ common.cloudprovider.params.subnet_id }}
 {%- endif %}
 {%- if common.cloudprovider.params.lb_method is defined %}
 lb-method={{ common.cloudprovider.params.lb_method }}
 {%- endif %}
-{%- if common.cloudprovider.params.floating_network_id is defined %}
-floating-network-id={{ common.cloudprovider.params.floating_network_id }}
+{%- if common.cloudprovider.params.floating_net_id is defined %}
+floating-network-id={{ common.cloudprovider.params.floating_net_id }}
 {%- endif %}
 {%- if common.cloudprovider.params.create_monitor is defined %}
 create-monitor={{ common.cloudprovider.params.create_monitor }}
@@ -46,3 +46,17 @@
 
 [BlockStorage]
 ignore-volume-az=true
+
+
+{%- if pillar.kubernetes.master is defined and cloudconfig_type == "external" %}
+[Networking]
+{%- if common.cloudprovider.params.internal_net_name is defined %}
+internal-network-name={{ common.cloudprovider.params.internal_net_name }}
+{%- endif %}
+{%- if common.cloudprovider.params.public_net_name is defined %}
+public-network-name={{ common.cloudprovider.params.public_net_name }}
+{%- endif %}
+{%- if common.cloudprovider.params.ipv6_support_disabled is defined %}
+ipv6-support-disabled={{ common.cloudprovider.params.ipv6_support_disabled }}
+{%- endif %}
+{%- endif %}
diff --git a/kubernetes/files/kubelet/default.pool b/kubernetes/files/kubelet/default.pool
index 8e2a1e9..4ba5328 100644
--- a/kubernetes/files/kubelet/default.pool
+++ b/kubernetes/files/kubelet/default.pool
@@ -56,7 +56,7 @@
 {%- endif %}
 --file-check-frequency={{ pool.kubelet.frequency }} \
 {%- if common.get('cloudprovider', {}).get('enabled') and common.get('cloudprovider', {}).get('provider') == 'openstack' %}
---cloud-provider=openstack \
+--cloud-provider=external \
 --cloud-config=/etc/kubernetes/cloud-config \
 {%- endif %}
 {%- if common.addons.get('virtlet', {}).get('enabled') %}
diff --git a/kubernetes/master/controller.sls b/kubernetes/master/controller.sls
index a458868..ce31e34 100644
--- a/kubernetes/master/controller.sls
+++ b/kubernetes/master/controller.sls
@@ -231,6 +231,11 @@
         --root-ca-file=/etc/kubernetes/ssl/ca-{{ master.ca }}.crt
         --service-account-private-key-file=/etc/kubernetes/ssl/kubernetes-server.key
         --use-service-account-credentials
+{%- if common.get('cloudprovider', {}).get('enabled') and common.get('cloudprovider', {}).get('provider') == 'openstack' %}
+        --external-cloud-volume-plugin=openstack
+        --cloud-config /etc/kubernetes/cloud-config.intree
+        --cloud-provider external
+{%- endif %}
         --v={{ master.get('verbosity', 2) }}
 {%- if master.network.get('flannel', {}).get('enabled', False) %}
         --allocate-node-cidrs=true
@@ -317,6 +322,13 @@
     - file: /etc/kubernetes/cloud-config
     - file: /etc/default/openstack-cloud-controller-manager
     - file: /etc/kubernetes/controller-manager.kubeconfig
+    - file: /usr/bin/openstack-cloud-controller-manager
+
+kube_controller_mnanager_service:
+  service.running:
+  - name: kube-controller-manager
+  - watch:
+    - file: /etc/kubernetes/cloud-config.intree
 {%- endif %}
 {%- endif %}