<h3>Overview</h3>

<p><em>kube-dns</em> can't start (SetupNetworkError) after <em>kubeadm init</em> and network setup:</p>

<pre><code>Error syncing pod, skipping: failed to "SetupNetwork" for 
"kube-dns-654381707-w4mpg_kube-system" with SetupNetworkError: 
"Failed to setup network for pod 
\"kube-dns-654381707-w4mpg_kube-system(8ffe3172-a739-11e6-871f-000c2912631c)\" 
using network plugins \"cni\": open /run/flannel/subnet.env: 
no such file or directory; Skipping pod"
</code></pre>

<h3>Kubernetes version</h3>

<pre><code>Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.4", GitCommit:"3b417cc4ccd1b8f38ff9ec96bb50a81ca0ea9d56", GitTreeState:"clean", BuildDate:"2016-10-21T02:48:38Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.4", GitCommit:"3b417cc4ccd1b8f38ff9ec96bb50a81ca0ea9d56", GitTreeState:"clean", BuildDate:"2016-10-21T02:42:39Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
</code></pre>

<h3>Environment</h3>

<p>VMWare Fusion for Mac</p>

<h3>OS</h3>

<pre><code>NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.1 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
</code></pre>

<h3>Kernel (e.g. uname -a)</h3>

<pre><code>Linux ubuntu-master 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<h3>What is the problem</h3>

<pre><code>kube-system   kube-dns-654381707-w4mpg                0/3       ContainerCreating   0          2m
FirstSeen     LastSeen        Count   From                    SubobjectPath   Type            Reason          Message
  ---------     --------        -----   ----                    -------------   --------        ------          -------
  3m            3m              1       {default-scheduler }                    Normal          Scheduled       Successfully assigned kube-dns-654381707-w4mpg to ubuntu-master
  2m            1s              177     {kubelet ubuntu-master}                 Warning         FailedSync      Error syncing pod, skipping: failed to "SetupNetwork" for "kube-dns-654381707-w4mpg_kube-system" with SetupNetworkError: "Failed to setup network for pod \"kube-dns-654381707-w4mpg_kube-system(8ffe3172-a739-11e6-871f-000c2912631c)\" using network plugins \"cni\": open /run/flannel/subnet.env: no such file or directory; Skipping pod"
</code></pre>

<h3>What I expected to happen</h3>

<p>kube-dns Running</p>

<h3>How to reproduce it</h3>

<pre><code>root@ubuntu-master:~# kubeadm init
Running pre-flight checks
&lt;master/tokens&gt; generated token: "247a8e.b7c8c1a7685bf204"
&lt;master/pki&gt; generated Certificate Authority key and certificate:
Issuer: CN=kubernetes | Subject: CN=kubernetes | CA: true
Not before: 2016-11-10 11:40:21 +0000 UTC Not After: 2026-11-08 11:40:21 +0000 UTC
Public: /etc/kubernetes/pki/ca-pub.pem
Private: /etc/kubernetes/pki/ca-key.pem
Cert: /etc/kubernetes/pki/ca.pem
&lt;master/pki&gt; generated API Server key and certificate:
Issuer: CN=kubernetes | Subject: CN=kube-apiserver | CA: false
Not before: 2016-11-10 11:40:21 +0000 UTC Not After: 2017-11-10 11:40:21 +0000 UTC
Alternate Names: [172.20.10.4 10.96.0.1 kubernetes kubernetes.default     kubernetes.default.svc kubernetes.default.svc.cluster.local]
Public: /etc/kubernetes/pki/apiserver-pub.pem
Private: /etc/kubernetes/pki/apiserver-key.pem
Cert: /etc/kubernetes/pki/apiserver.pem
&lt;master/pki&gt; generated Service Account Signing keys:
Public: /etc/kubernetes/pki/sa-pub.pem
Private: /etc/kubernetes/pki/sa-key.pem
&lt;master/pki&gt; created keys and certificates in "/etc/kubernetes/pki"
&lt;util/kubeconfig&gt; created "/etc/kubernetes/kubelet.conf"
&lt;util/kubeconfig&gt; created "/etc/kubernetes/admin.conf"
&lt;master/apiclient&gt; created API client configuration
&lt;master/apiclient&gt; created API client, waiting for the control plane to become ready
&lt;master/apiclient&gt; all control plane components are healthy after 14.053453 seconds
&lt;master/apiclient&gt; waiting for at least one node to register and become ready
&lt;master/apiclient&gt; first node is ready after 0.508561 seconds
&lt;master/apiclient&gt; attempting a test deployment
&lt;master/apiclient&gt; test deployment succeeded
&lt;master/discovery&gt; created essential addon: kube-discovery, waiting for it to become ready
&lt;master/discovery&gt; kube-discovery is ready after 1.503838 seconds
&lt;master/addons&gt; created essential addon: kube-proxy
&lt;master/addons&gt; created essential addon: kube-dns

Kubernetes master initialised successfully!

You can now join any number of machines by running the following on each node:

kubeadm join --token=247a8e.b7c8c1a7685bf204 172.20.10.4
root@ubuntu-master:~# 
root@ubuntu-master:~# kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY     STATUS              RESTARTS   AGE
kube-system   dummy-2088944543-eo1ua                  1/1       Running             0          47s
kube-system   etcd-ubuntu-master                      1/1       Running             3          51s
kube-system   kube-apiserver-ubuntu-master            1/1       Running             0          49s
kube-system   kube-controller-manager-ubuntu-master   1/1       Running             3          51s
kube-system   kube-discovery-1150918428-qmu0b         1/1       Running             0          46s
kube-system   kube-dns-654381707-mv47d                0/3       ContainerCreating   0          44s
kube-system   kube-proxy-k0k9q                        1/1       Running             0          44s
kube-system   kube-scheduler-ubuntu-master            1/1       Running             3          51s
root@ubuntu-master:~# 
root@ubuntu-master:~# kubectl apply -f https://git.io/weave-kube
daemonset "weave-net" created
root@ubuntu-master:~# 
root@ubuntu-master:~# 
root@ubuntu-master:~# kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY     STATUS              RESTARTS   AGE
kube-system   dummy-2088944543-eo1ua                  1/1       Running             0          47s
kube-system   etcd-ubuntu-master                      1/1       Running             3          51s
kube-system   kube-apiserver-ubuntu-master            1/1       Running             0          49s
kube-system   kube-controller-manager-ubuntu-master   1/1       Running             3          51s
kube-system   kube-discovery-1150918428-qmu0b         1/1       Running             0          46s
kube-system   kube-dns-654381707-mv47d                0/3       ContainerCreating   0          44s
kube-system   kube-proxy-k0k9q                        1/1       Running             0          44s
kube-system   kube-scheduler-ubuntu-master            1/1       Running             3          51s
kube-system   weave-net-ja736                         2/2       Running             0          1h
</code></pre>

<p>It looks like you have configured flannel before running <code>kubeadm init</code>. You can try to fix this by removing flannel (it may be sufficient to remove config file <code>rm -f /etc/cni/net.d/*flannel*</code>), but it's best to start fresh.</p>
