Merge "Changes to SL k8s addons"
diff --git a/kubernetes/_common.sls b/kubernetes/_common.sls
index 8781d4a..6fe6fea 100644
--- a/kubernetes/_common.sls
+++ b/kubernetes/_common.sls
@@ -41,6 +41,34 @@
     - onlyif: /bin/false
     {%- endif %}
 
+{%- if common.get('containerd', {}).get('enabled') %}
+
+containerd_pkg:
+  pkg.installed:
+  - name: {{ common.containerd.get('package', 'containerd.io') }}
+
+runc_pkg:
+  pkg.installed:
+  - name: {{ common.containerd.get('runc_package', 'runc') }}
+
+/etc/containerd/config.toml:
+  file.absent
+
+containerd_service:
+  service.running:
+  - name: containerd
+  - enable: True
+  - watch:
+    - file: /etc/containerd/config.toml
+  - require:
+    - containerd_pkg
+    - runc_pkg
+  {%- if grains.get('noservices') %}
+  - onlyif: /bin/false
+  {%- endif %}
+
+{%- endif %}
+
 {%- if common.addons.get('virtlet', {}).get('enabled') %}
 
 /usr/bin/criproxy:
@@ -55,6 +83,8 @@
     - onlyif: /bin/false
     {%- endif %}
 
+{%- if not common.get('containerd', {}).get('enabled') %}
+
 {%- if not pillar.kubernetes.pool is defined %}
 
 /etc/default/dockershim:
@@ -77,19 +107,6 @@
 
 {%- endif %}
 
-/etc/criproxy:
-  file.directory:
-    - user: root
-    - group: root
-    - mode: 0750
-
-/etc/criproxy/node.conf:
-  file.managed:
-    - user: root
-    - group: root
-    - mode: 0640
-    - contents: ''
-
 /etc/systemd/system/dockershim.service:
   file.managed:
     - source: salt://kubernetes/files/systemd/dockershim.service
@@ -98,14 +115,6 @@
     - group: root
     - mode: 755
 
-/etc/systemd/system/criproxy.service:
-  file.managed:
-    - source: salt://kubernetes/files/systemd/criproxy.service
-    - template: jinja
-    - user: root
-    - group: root
-    - mode: 755
-
 dockershim_service:
   service.running:
   - name: dockershim
@@ -117,6 +126,29 @@
   - onlyif: /bin/false
   {%- endif %}
 
+{%- endif %}
+
+/etc/criproxy:
+  file.directory:
+    - user: root
+    - group: root
+    - mode: 0750
+
+/etc/criproxy/node.conf:
+  file.managed:
+    - user: root
+    - group: root
+    - mode: 0640
+    - contents: ''
+
+/etc/systemd/system/criproxy.service:
+  file.managed:
+    - source: salt://kubernetes/files/systemd/criproxy.service
+    - template: jinja
+    - user: root
+    - group: root
+    - mode: 755
+
 criproxy_service:
   service.running:
   - name: criproxy
@@ -134,10 +166,12 @@
 /etc/criproxy:
   file.absent
 
+{%- if not common.get('containerd', {}).get('enabled') %}
 dockershim_service:
   service.dead:
   - name: dockershim
   - enable: False
+{%- endif %}
 
 criproxy_service:
   service.dead:
diff --git a/kubernetes/files/kube-addons/virtlet/virtlet-ds.yml b/kubernetes/files/kube-addons/virtlet/virtlet-ds.yml
index 51657a8..b6688c1 100644
--- a/kubernetes/files/kube-addons/virtlet/virtlet-ds.yml
+++ b/kubernetes/files/kube-addons/virtlet/virtlet-ds.yml
@@ -104,6 +104,12 @@
               key: cpu-model
               name: virtlet-config
               optional: true
+        - name: KUBELET_ROOT_DIR
+          valueFrom:
+            configMapKeyRef:
+              name: virtlet-config
+              key: kubelet_root_dir
+              optional: true
         - name: VIRTLET_IMAGE_TRANSLATIONS_DIR
           value: /etc/virtlet/images
         image: {{ common.addons.virtlet.image }}
@@ -193,6 +199,7 @@
           readOnly: true
         - mountPath: /var/lib/virtlet
           name: virtlet
+          mountPropagation: Bidirectional
         - mountPath: /var/lib/libvirt
           name: libvirt
         - mountPath: /var/run/libvirt
@@ -220,10 +227,14 @@
         volumeMounts:
         - mountPath: /var/lib/virtlet
           name: virtlet
+          mountPropagation: HostToContainer
         - mountPath: /var/lib/libvirt
           name: libvirt
         - mountPath: /var/log/vms
           name: vms-log
+        - mountPath: /var/lib/kubelet/pods
+          name: k8s-pods-dir
+          mountPropagation: HostToContainer
         - mountPath: /dev
           name: dev
         - mountPath: /lib/modules
@@ -282,11 +293,6 @@
           name: virtlet-image-translations
         name: image-name-translations
   updateStrategy: {}
-status:
-  currentNumberScheduled: 0
-  desiredNumberScheduled: 0
-  numberMisscheduled: 0
-  numberReady: 0
 
 ---
 apiVersion: rbac.authorization.k8s.io/v1beta1
@@ -464,11 +470,6 @@
     singular: virtletimagemapping
   scope: Namespaced
   version: v1
-status:
-  acceptedNames:
-    kind: ""
-    plural: ""
-  conditions: null
 
 ---
 apiVersion: apiextensions.k8s.io/v1beta1
@@ -544,11 +545,6 @@
             priority:
               type: integer
   version: v1
-status:
-  acceptedNames:
-    kind: ""
-    plural: ""
-  conditions: null
 
 ---
 apiVersion: v1
diff --git a/kubernetes/files/kubelet/default.master b/kubernetes/files/kubelet/default.master
index b3f0e41..748686d 100644
--- a/kubernetes/files/kubelet/default.master
+++ b/kubernetes/files/kubelet/default.master
@@ -31,6 +31,10 @@
 --cloud-config=/etc/kubernetes/cloud-config.conf \
 {%- endif %}
 {%- endif %}
+{%- if common.get('containerd', {}).get('enabled') %}
+--container-runtime={{ pool.get('container-runtime', 'remote') }} \
+--container-runtime-endpoint={{ pool.get('image-service-endpoint', 'unix:///run/containerd/containerd.sock') }} \
+{%- endif %}
 {%- for key, value in master.get('kubelet', {}).get('daemon_opts', {}).items() %}
 --{{ key }}={{ value }} \
 {%- endfor %}
diff --git a/kubernetes/files/kubelet/default.pool b/kubernetes/files/kubelet/default.pool
index beb39c5..ee1a5a9 100644
--- a/kubernetes/files/kubelet/default.pool
+++ b/kubernetes/files/kubelet/default.pool
@@ -67,6 +67,10 @@
 {%- endif %}
 --enable-controller-attach-detach={{ pool.get('enable-controller-attach-detach', 'false') }} \
 {%- endif %}
+{%- if common.get('containerd', {}).get('enabled') and not common.addons.get('virtlet', {}).get('enabled') %}
+--container-runtime={{ pool.get('container-runtime', 'remote') }} \
+--container-runtime-endpoint={{ pool.get('image-service-endpoint', 'unix:///run/containerd/containerd.sock') }} \
+{%- endif %}
 {%- for key, value in pool.get('kubelet', {}).get('daemon_opts', {}).items() %}
 --{{ key }}={{ value }} \
 {%- endfor %}
diff --git a/kubernetes/files/systemd/criproxy.service b/kubernetes/files/systemd/criproxy.service
index 894070e..b5f9d18 100644
--- a/kubernetes/files/systemd/criproxy.service
+++ b/kubernetes/files/systemd/criproxy.service
@@ -1,3 +1,4 @@
+{%- from "kubernetes/map.jinja" import common with context -%}
 {%- from "kubernetes/map.jinja" import pool with context -%}
 {%- from "kubernetes/map.jinja" import master with context -%}
 {%- from "kubernetes/map.jinja" import version %}
@@ -11,7 +12,11 @@
 SyslogIdentifier=criproxy
 User=root
 ExecStart=/usr/bin/criproxy -alsologtostderr \
+          {%- if common.get('containerd', {}).get('enabled') %}
+          -connect /run/containerd/containerd.sock,virtlet.cloud:/run/virtlet.sock \
+          {%- else %}
           -connect /var/run/dockershim.sock,virtlet.cloud:/run/virtlet.sock \
+          {%- endif %}
           -listen /var/run/criproxy.sock \
           -v 3 \
           -alsologtostderr \
diff --git a/kubernetes/map.jinja b/kubernetes/map.jinja
index b89cdad..ad1a7a8 100644
--- a/kubernetes/map.jinja
+++ b/kubernetes/map.jinja
@@ -142,4 +142,4 @@
     'instance_minor_threshold_percent': 0.3,
     'instance_major_threshold_percent': 0.6,
   },
-}, grain='os_family', merge=salt['pillar.get']('kubernetes:monitoring')) %}
\ No newline at end of file
+}, grain='os_family', merge=salt['pillar.get']('kubernetes:monitoring')) %}