Add test for run virtlet VM

Added test for run VM inside virtlet pod
Refactored deploy config for virtlet pod

Change-Id: I38d51b18030c9147168f6d0b2bd815c56b021231
Reviewed-on: https://review.gerrithub.io/364662
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/underlay.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/underlay.yaml
index 2434579..985110c 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/underlay.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/underlay.yaml
@@ -181,7 +181,7 @@
                     - private
 
           - name: {{ HOSTNAME_CTL02 }}
-            role: salt_minion
+            role: k8s_virtlet
             params:
               vcpu: !os_env SLAVE_NODE_CPU, 4
               memory: !os_env SLAVE_NODE_MEMORY, 2048
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet.yaml
index 4f2abb3..6e66fc4 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet.yaml
@@ -1,4 +1,5 @@
 {% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CTL02 with context %}
+{% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CFG01 with context %}
 
 # Clone virtlet project from git to the ctl01 node for start virtlet pod from yaml
 - description: Cloning virtlet project on ctl02
@@ -14,6 +15,21 @@
   retry: {count: 1, delay: 1}
   skip_fail: false
 
+# Add route for internal kube-services if necessary
+- description: Adding route for internal kube-services if necessary
+  cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kubernetes:pool' cmd.run "ip r | grep 10.254 || ip ro add 10.254.0.0/16 dev ens4"
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 1}
+  skip_fail: false
+
+
+# Install jq
+- description: Install jq
+  cmd: apt-get install jq -y
+  node_name: {{ HOSTNAME_CTL02 }}
+  retry: {count: 1, delay: 1}
+  skip_fail: false
+
 # Add extra parameter for kubelet service on virtlet node
 - description: Adding extra parameter for kubelet service on virtlet node
   cmd:  sed -i.bak "s|^\"|--feature-gates=DynamicKubeletConfig=true \\\\\\n\"|" /etc/default/kubelet
@@ -21,16 +37,19 @@
   retry: {count: 1, delay: 1}
   skip_fail: false
 
-# Restart kubelet and kube-api services on virtlet node
-- description: Restart kubelet and kube-api services on ctl02
-  cmd:  systemctl restart kube-apiserver kubelet
+# Restart kubelet service on virtlet node
+- description: Restart kubelet service on ctl02
+  cmd:  systemctl restart kubelet
   node_name: {{ HOSTNAME_CTL02 }}
   retry: {count: 1, delay: 1}
   skip_fail: false
 
 # Create virtlet pod
 - description: Creating virtlet pod
-  cmd:  kubectl create -f virtlet/deploy/virtlet-ds.yaml
+  cmd: |
+    kubectl convert -f virtlet/deploy/virtlet-ds.yaml --local -o json | jq \
+    '.items[0].spec.template.spec.containers[0].env|=.+[{"name":"VIRTLET_DISABLE_KVM","value":"y"}] | .items[0].spec.template.spec.volumes|=.+[{"name":"etcd","hostPath":{"path":"/var/lib/etcd"}},{"name":"kubernetes","hostPath":{"path":"/etc/kubernetes"}}] | .items[0].spec.template.spec.containers[0].volumeMounts|=.+[{"mountPath":"/etc/kubernetes","name":"kubernetes"},{"mountPath":"/var/lib/etcd","name":"etcd"}]' | \
+    kubectl create -f -
   node_name: {{ HOSTNAME_CTL02 }}
   retry: {count: 1, delay: 1}
   skip_fail: false