<h1>Problem encountered</h1>

<p>When deploying a cluster with <strong>Kubespray</strong>, <strong>CRI-O</strong> and <strong>Cilium</strong> I get an error about having multiple CRI socket to choose from.</p>

<p><em>Full error</em></p>

<pre><code>fatal: [p3kubemaster1]: FAILED! =&gt; {"changed": true, "cmd": " mkdir -p /etc/kubernetes/external_kubeconfig &amp;&amp;  /usr/local/bin/kubeadm  init phase   kubeconfig admin --kubeconfig-dir /etc/kubernetes/external_kubeconfig  --cert-dir /etc/kubernetes/ssl --apiserver-advertise-address 10.10.3.15 --apiserver-bind-port 6443  &gt;/dev/null &amp;&amp; cat /etc/kubernetes/external_kubeconfig/admin.conf &amp;&amp; rm -rf /etc/kubernetes/external_kubeconfig ", "delta": "0:00:00.028808", "end": "2019-09-02 13:01:11.472480", "msg": "non-zero return code", "rc": 1, "start": "2019-09-02 13:01:11.443672", "stderr": "Found multiple CRI sockets, please use --cri-socket to select one: /var/run/dockershim.sock, /var/run/crio/crio.sock", "stderr_lines": ["Found multiple CRI sockets, please use --cri-socket to select one: /var/run/dockershim.sock, /var/run/crio/crio.sock"], "stdout": "", "stdout_lines": []}
</code></pre>

<p><em>Interesting part</em></p>

<pre><code>kubeadm  init phase kubeconfig admin --kubeconfig-dir /etc/kubernetes/external_kubeconfig [...] &gt;/dev/null,"stderr": "Found multiple CRI sockets, please use --cri-socket to select one: /var/run/dockershim.sock, /var/run/crio/crio.sock"}
</code></pre>

<hr>

<h1>What I've tried</h1>

<ul>
<li>1) I've tried to set the <code>--cri-socket</code> flag inside <code>/var/lib/kubelet/kubeadm-flags.env</code>:  </li>
</ul>

<pre><code>KUBELET_KUBEADM_ARGS="--container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --cri-socket=/var/run/crio/crio.sock"
</code></pre>

<p>=> Makes no difference</p>

<ul>
<li>2) I've checked <code>/etc/kubernetes/kubeadm-config.yaml</code> but it already contains the following section :</li>
</ul>

<pre><code>apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: 10.10.3.15
  bindPort: 6443
certificateKey: 9063a1ccc9c5e926e02f245c06b8d9f2ff3xxxxxxxxxxxx
nodeRegistration:
  name: p3kubemaster1
  taints:
  - effect: NoSchedule
    key: node-role.kubernetes.io/master
  criSocket: /var/run/crio/crio.sock
</code></pre>

<p>=> Its already ending with the <code>criSocket</code> flag, so nothing to do...</p>

<ul>
<li>3) Tried to edit the ansible script to add the <code>--cri-socket</code> to the existing command but it fails with <code>Unknow command --cri-socket</code></li>
</ul>

<p>Existing :  </p>

<pre><code>{% if kubeadm_version is version('v1.14.0', '&gt;=') %}
    init phase`
</code></pre>

<p>Tried :  </p>

<pre><code>{% if kubeadm_version is version('v1.14.0', '&gt;=') %}
    init phase --crio socket /var/run/crio/crio.sock`
</code></pre>

<hr>

<h1>Theories</h1>

<p>It seems that the problem comes from the command <code>kubeadm init phase</code> which is not compatible with the <code>--crio-socket</code> flag... (see point 3)  </p>

<p>Even though the correct socket is set (see point 2) using the config file, the <code>kubeadm init phase</code> is not using it.  </p>

<p>Any ideas would be apreciated ;-)<br>
thx  </p>

Doctor
<p>This worked for me for multiple cri sockets</p>
<pre><code>kubeadm init --pod-network-cidr=10.244.0.0/16 --cri-socket=unix:///var/run/cri-dockerd.sock
</code></pre>
<p>Image pull command before initialization for multiple cri:</p>
<pre><code>kubeadm config images pull --cri-socket=unix:///var/run/cri-dockerd.sock
</code></pre>
<hr />
<p>You can choose cri socket path from the following table. See original documentation <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-runtime" rel="noreferrer">here</a></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Runtime</th>
<th>Path to Unix domain socket</th>
</tr>
</thead>
<tbody>
<tr>
<td>containerd</td>
<td><code>unix:///var/run/containerd/containerd.sock</code></td>
</tr>
<tr>
<td>CRI-O</td>
<td><code>unix:///var/run/crio/crio.sock</code></td>
</tr>
<tr>
<td>Docker Engine (using cri-dockerd)</td>
<td><code>unix:///var/run/cri-dockerd.sock</code></td>
</tr>
</tbody>
</table>
</div>