Merge "Refactor parameters for k8s-aio-calico model."
diff --git a/classes/cluster/k8s-aio-calico/infra/config.yml b/classes/cluster/k8s-aio-calico/infra/config.yml
index a9d6178..63034f6 100644
--- a/classes/cluster/k8s-aio-calico/infra/config.yml
+++ b/classes/cluster/k8s-aio-calico/infra/config.yml
@@ -5,10 +5,9 @@
 - system.salt.master.pkg
 - system.salt.minion.ca.salt_master
 - system.salt.master.api
-- system.salt.minion.cert.k8s_server
-- system.mysql.client
+- system.salt.minion.cert.k8s_server_single
 - system.reclass.storage.salt
-- system.reclass.storage.system.kubernetes_control_cluster
+- system.reclass.storage.system.kubernetes_control_single
 - cluster.k8s-aio-calico
 parameters:
   _param:
@@ -17,6 +16,7 @@
     reclass_data_revision: master
     reclass_config_master: ${_param:infra_config_deploy_address}
     single_address: ${_param:infra_config_address}
+    deploy_address: ${_param:infra_config_deploy_address}
     linux_system_codename: xenial
     salt_api_password_hash: "$6$WV0P1shnoDh2gI/Z$22/Bcd7ffMv0jDlFpT63cAU4PiXHz9pjXwngToKwqAsgoeK4HNR3PiKaushjxp3JsQ8hNoJmAC6TxzVqfV8WH/"
     salt_master_host: 127.0.0.1
@@ -37,6 +37,8 @@
               value_template: <<node_os>>
             salt_master_host:
               value_template: <<node_master_ip>>
+            deploy_address:
+              value_template: <<node_deploy_ip>>
         infra_config:
           expression: <<node_hostname>>__startswith__cfg
           cluster_param:
@@ -44,23 +46,20 @@
               value_template: <<node_control_ip>>
             infra_config_deploy_address:
               value_template: <<node_deploy_ip>>
+            cluster_domain:
+              value_template: <<node_domain>>
         kubernetes_control01:
           expression: <<node_hostname>>__equals__ctl01
           cluster_param:
             kubernetes_control_node01_address:
               value_template: <<node_control_ip>>
-        kubernetes_control02:
-          expression: <<node_hostname>>__equals__ctl02
-          cluster_param:
-            kubernetes_control_node02_address:
-              value_template: <<node_control_ip>>
-        kubernetes_control03:
-          expression: <<node_hostname>>__equals__ctl03
-          cluster_param:
-            kubernetes_control_node03_address:
-              value_template: <<node_control_ip>>
+            kubernetes_control_node01_deploy_address:
+              value_template: <<node_deploy_ip>>
         kubernetes_compute:
           expression: <<node_hostname>>__startswith__cmp
           node_class:
             value_template:
               - cluster.<<node_cluster>>.kubernetes.compute
+          node_param:
+            deploy_address:
+              value_template: <<node_deploy_ip>>
diff --git a/classes/cluster/k8s-aio-calico/infra/init.yml b/classes/cluster/k8s-aio-calico/infra/init.yml
index d6c546e..9d3b5c0 100644
--- a/classes/cluster/k8s-aio-calico/infra/init.yml
+++ b/classes/cluster/k8s-aio-calico/infra/init.yml
@@ -12,8 +12,8 @@
     infra_config_address: 172.16.10.100
     infra_config_deploy_address: 192.168.10.90
 
-    cluster_domain: virtual-mcp11-k8s-calico.local
-    cluster_name: virtual-mcp11-k8s-calico
+    cluster_domain: k8s-aio-calico.local
+    cluster_name: k8s-aio-calico
     apt_mk_version: nightly
     primary_interface: ens3
   linux:
@@ -24,15 +24,6 @@
           names:
           - ${_param:infra_config_hostname}
           - ${_param:infra_config_hostname}.${_param:cluster_domain}
-      interface:
-        primary_interface:
-          enabled: true
-          type: eth
-          proto: dhcp
-          #proto: static
-          #name: ${_param:primary_interface}
-          #address: ${_param:single_address}
-          #netmask: 255.255.255.0
     system:
       name: ${_param:infra_config_hostname}
       domain: ${_param:cluster_domain}
diff --git a/classes/cluster/k8s-aio-calico/kubernetes/compute.yml b/classes/cluster/k8s-aio-calico/kubernetes/compute.yml
index b7be97b..7f9da05 100644
--- a/classes/cluster/k8s-aio-calico/kubernetes/compute.yml
+++ b/classes/cluster/k8s-aio-calico/kubernetes/compute.yml
@@ -1,25 +1,23 @@
 classes:
 - system.linux.system.repo.docker_legacy
-- system.kubernetes.pool.cluster
+- system.kubernetes.pool.single
 - system.linux.network.hosts
-- system.salt.minion.cert.k8s_client
+- system.salt.minion.cert.k8s_client_single
 - system.salt.minion.cert.etcd_client
 - cluster.k8s-aio-calico
 parameters:
-  _param:
-    kubernetes_calicoctl_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/ctl:latest
-    kubernetes_calico_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/node:latest
-    kubernetes_calico_cni_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/cni:latest
-    kubernetes_hyperkube_image: docker-prod-virtual.docker.mirantis.net/mirantis/kubernetes/hyperkube-amd64:v1.7.8-3
   docker:
     host:
       pkgs:
-        - docker-engine=1.12.6-0~ubuntu-xenial
+        - - ${_param:kubernetes_docker_package}
         - python-docker
       options:
         bip: 172.31.255.1/24
+        storage-driver: overlay2
   kubernetes:
     pool:
+      kubelet:
+        address: ${_param:single_address}
       network:
         etcd:
           ssl:
@@ -30,6 +28,13 @@
         cni:
           image: ${_param:kubernetes_calico_cni_image}
     common:
+      addons:
+        virtlet:
+          enabled: ${_param:kubernetes_virtlet_enabled}
+          namespace: ${_param:kubernetes_addon_namespace}
+          image: ${_param:kubernetes_virtlet_image}
+          hosts:
+          - ${linux:system:name}
       hyperkube:
         image: ${_param:kubernetes_hyperkube_image}
   linux:
@@ -40,9 +45,16 @@
           - 172.18.176.4
           - 172.18.176.7
       interface:
-        primary_interface:
+        ens3:
+          enabled: true
+          type: eth
+          proto: static
+          name: ${_param:primary_interface}
+          address: ${_param:deploy_address}
+          netmask: 255.255.255.0
+          gateway: 192.168.10.1
           route:
             kubernetes_services:
               address: 10.254.0.0
               netmask: 255.255.0.0
-              gateway: ${_param:single_address}
+              gateway: ${_param:deploy_address}
diff --git a/classes/cluster/k8s-aio-calico/kubernetes/control.yml b/classes/cluster/k8s-aio-calico/kubernetes/control.yml
index 7c4dfe3..a26ab0a 100644
--- a/classes/cluster/k8s-aio-calico/kubernetes/control.yml
+++ b/classes/cluster/k8s-aio-calico/kubernetes/control.yml
@@ -1,9 +1,9 @@
 classes:
-- service.etcd.server.cluster
-- system.haproxy.proxy.listen.kubernetes.apiserver
+- service.etcd.server.single
 - system.linux.system.repo.docker_legacy
-- system.salt.minion.cert.etcd_server
-- system.kubernetes.master.cluster
+- system.salt.minion.cert.etcd_server_single
+- system.salt.minion.cert.k8s_server_single
+- system.kubernetes.master.single
 - cluster.k8s-aio-calico.kubernetes.compute
 - cluster.k8s-aio-calico
 parameters:
@@ -12,6 +12,8 @@
     keepalived_vip_virtual_router_id: 60
   etcd:
     server:
+      bind:
+        host: ${_param:deploy_address}
       source:
         engine: docker_hybrid
       ssl:
@@ -23,20 +25,31 @@
   kubernetes:
     common:
       addons:
-        netchecker:
-          enabled: true
+        dashboard:
+          enabled: ${_param:kubernetes_dashboard}
         helm:
-          enabled: true
+          enabled: ${_param:kubernetes_helm_enabled}
         coredns:
           enabled: ${_param:kubernetes_coredns_enabled}
         externaldns:
           enabled: ${_param:kubernetes_externaldns_enabled}
           image: ${_param:kubernetes_externaldns_image}
           provider: ${_param:kubernetes_externaldns_provider}
+        calico_policy:
+          enabled: ${_param:kubernetes_calico_policy_enabled}
+          image: ${_param:kubernetes_calico_policy_image}
+        netchecker:
+          enabled: ${_param:kubernetes_netchecker_enabled}
+          agent_image: ${_param:kubernetes_netchecker_agent_image}
+          server_image: ${_param:kubernetes_netchecker_server_image}
+          agent_probeurls: ${_param:kubernetes_netchecker_agent_probeurls}
     master:
       etcd:
         ssl:
           enabled: true
+    master:
+      kubelet:
+        address: ${_param:single_address}
       network:
         etcd:
           ssl:
diff --git a/classes/cluster/k8s-aio-calico/kubernetes/init.yml b/classes/cluster/k8s-aio-calico/kubernetes/init.yml
index 9bb00dd..0856f18 100644
--- a/classes/cluster/k8s-aio-calico/kubernetes/init.yml
+++ b/classes/cluster/k8s-aio-calico/kubernetes/init.yml
@@ -14,36 +14,45 @@
     kubernetes_dns_token: 0S1I4iJeFjq5fopPwwCwTp3xFpEZfeUl
     etcd_initial_token: IN7KaRMSo3xkGxkjAAPtkRkAgqN4ZNRq
 
+    # docker package version
+    kubernetes_docker_package: docker-engine=1.12.6-0~ubuntu-xenial
+
+    # component docker images
+    kubernetes_calicoctl_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/ctl:latest
+    kubernetes_calico_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/node:latest
+    kubernetes_calico_cni_image: docker-prod-virtual.docker.mirantis.net/mirantis/projectcalico/calico/cni:latest
+    kubernetes_calico_policy_image: calico/kube-policy-controller:v0.5.4
+
+    kubernetes_hyperkube_image: docker-prod-virtual.docker.mirantis.net/mirantis/kubernetes/hyperkube-amd64:v1.7.8-3
+    kubernetes_virtlet_image: mirantis/virtlet:latest
+    kubernetes_netchecker_agent_image: mirantis/k8s-netchecker-agent:stable
+    kubernetes_netchecker_server_image: mirantis/k8s-netchecker-server:stable
+    kubernetes_netchecker_agent_probeurls: "http://ipinfo.io"
+
+    # switches of addons
+    kubernetes_addon_namespace: kube-system
+    kubernetes_dashboard: false
+    kubernetes_helm_enabled: true
+    kubernetes_netchecker_enabled: true
+    kubernetes_calico_policy_enabled: false
+    kubernetes_virtlet_enabled: false
+
     # addresses and hostnames
     kubernetes_internal_api_address: 10.254.0.1
-    kubernetes_control_hostname: ctl
-    kubernetes_control_address: 192.168.10.253
     kubernetes_control_node01_hostname: ctl01
-    kubernetes_control_node02_hostname: ctl02
-    kubernetes_control_node03_hostname: ctl03
-    kubernetes_compute_node01_hostname: cmp01
-    kubernetes_compute_node02_hostname: cmp02
     kubernetes_control_node01_address: 172.16.10.101
-    kubernetes_control_node02_address: 172.16.10.102
-    kubernetes_control_node03_address: 172.16.10.103
-    kubernetes_compute_node01_address: 172.16.10.105
-    kubernetes_compute_node02_address: 172.16.10.106
-    kubernetes_proxy_node01_hostname: prx01
-    kubernetes_proxy_node01_address: 172.16.10.121
+    master_address: ${_param:kubernetes_control_node01_address}
 
-    cluster_vip_address: ${_param:kubernetes_control_address}
     cluster_local_address: ${_param:single_address}
 
+    # cert
+    control_address: ${_param:kubernetes_control_node01_address}
+    salt_master_base_environment: prd
+
     # etcd stuff
-    cluster_node01_hostname: ${_param:kubernetes_control_node01_hostname}
-    cluster_node01_address: ${_param:kubernetes_control_node01_address}
-    cluster_node01_port: 4001
-    cluster_node02_hostname: ${_param:kubernetes_control_node02_hostname}
-    cluster_node02_address: ${_param:kubernetes_control_node02_address}
-    cluster_node02_port: 4001
-    cluster_node03_hostname: ${_param:kubernetes_control_node03_hostname}
-    cluster_node03_address: ${_param:kubernetes_control_node03_address}
-    cluster_node03_port: 4001
+    node_hostname: ${_param:kubernetes_control_node01_hostname}
+    node_address: ${_param:kubernetes_control_node01_address}
+    node_port: 4001
 
     # calico
     calico_private_network: 192.168.0.0
@@ -59,59 +68,9 @@
 
   linux:
     network:
-      resolv:
-        domain: virtual-mcp11-k8s-calico.local
-        options:
-          - ndots:5
-          - timeout:2
-          - attempts:2
       host:
-        ctl:
-          address: ${_param:kubernetes_control_address}
-          names:
-          - ${_param:kubernetes_control_hostname}
-          - ${_param:kubernetes_control_hostname}.${_param:cluster_domain}
         ctl01:
           address: ${_param:kubernetes_control_node01_address}
           names:
           - ${_param:kubernetes_control_node01_hostname}
           - ${_param:kubernetes_control_node01_hostname}.${_param:cluster_domain}
-        ctl02:
-          address: ${_param:kubernetes_control_node02_address}
-          names:
-          - ${_param:kubernetes_control_node02_hostname}
-          - ${_param:kubernetes_control_node02_hostname}.${_param:cluster_domain}
-        ctl03:
-          address: ${_param:kubernetes_control_node03_address}
-          names:
-          - ${_param:kubernetes_control_node03_hostname}
-          - ${_param:kubernetes_control_node03_hostname}.${_param:cluster_domain}
-        cmp01:
-          address: ${_param:kubernetes_compute_node01_address}
-          names:
-          - ${_param:kubernetes_compute_node01_hostname}
-          - ${_param:kubernetes_compute_node01_hostname}.${_param:cluster_domain}
-        cmp02:
-          address: ${_param:kubernetes_compute_node02_address}
-          names:
-          - ${_param:kubernetes_compute_node02_hostname}
-          - ${_param:kubernetes_compute_node02_hostname}.${_param:cluster_domain}
-        prx01:
-          address: ${_param:kubernetes_proxy_node01_address}
-          names:
-          - ${_param:kubernetes_proxy_node01_hostname}
-          - ${_param:kubernetes_proxy_node01_hostname}.${_param:cluster_domain}
-    system:
-      rc:
-        local: |
-          #!/bin/sh -e
-          #
-          # rc.local
-          #
-          ######### This file is managed by Salt! ##########
-          # This script is executed at the end of each multiuser runlevel.
-          # Make sure that the script will "exit 0" on success or any other
-          # value on error.
-          #
-          ip r a 10.254.0.0/16 dev ens3
-          exit 0