Flannel: kubectl apply -f kube-flannel.yml fails

Created on 23 Aug 2018  路  4Comments  路  Source: coreos/flannel

I am installing a single node of kubernetes on Ubuntu 16. I continuously encounter the error : unable to recognize "https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml": yaml: line 10: mapping values are not allowed in this context

whenever I pass the command:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-legacy.yml

I have tried several online yaml formatting and there seems to be no problem with the yaml file (kube-flannel.yml).

I am not sure how to proceed to configure flannel for the kubernetes networking.

Most helpful comment

It does not matter if you run "kubeadm join" as root or not (however, it is better to run it a regular user with sudo). The problem is that you must follow the steps listed after you run "kubeadm init", which is:
Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

And after creating .kube directory in your $HOME, copying kubernetes admin.conf file and setting appropriate file permission you may successfully issue:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-legacy.yml

All 4 comments

@SyCode7 are you logged in as root or a regular user? You will get that problem if logged in as root. (Well I did anyway)

I am trying to set up a single node Kubernetes Cluster from https://ninetaillabs.com/setting-up-a-single-node-kubernetes-cluster/ and getting error dial tcp 127.0.0.1:6443: connect: connection refused
when kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml is executed.
I have tried different yml files
https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml
but every time it is dial tcp 127.0.0.1:6443: connect: connection refused.

Thanks

try running following commands before you run kubectl apply command

ravijangra@kubemaster:~$ mkdir -p ~/.kube
ravijangra@kubemaster:~$ sudo cp -i /etc/kubernetes/admin.conf ~/.kube/config
ravijangra@kubemaster:~$ sudo chown $(id -u):$(id -g) ~/.kube/config

It does not matter if you run "kubeadm join" as root or not (however, it is better to run it a regular user with sudo). The problem is that you must follow the steps listed after you run "kubeadm init", which is:
Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

And after creating .kube directory in your $HOME, copying kubernetes admin.conf file and setting appropriate file permission you may successfully issue:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-legacy.yml

Was this page helpful?
0 / 5 - 0 ratings