Merge "Add support of containerd"
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/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')) %}