19

Kubernetes has master and minion nodes.

Will (can) Kubernetes run specified Docker containers on the master node(s)?

I guess another way of saying it is: can a master also be a minion?

Thanks for any assistance.

Ashley Aitken
  • 2,419
  • 2
  • 20
  • 24

3 Answers3

15

Update 2015-08-06: As of PR #12349 (available in 1.0.3 and will be available in 1.1 when it ships), the master node is now one of the available nodes in the cluster and you can schedule pods onto it just like any other node in the cluster.


A docker container can only be scheduled onto a kubernetes node running a kubelet (what you refer to as a minion). There is nothing preventing you from creating a cluster where the same machine (physical or virtual) runs both the kubernetes master software and a kubelet, but the current cluster provisioning scripts separate the master onto a distinct machine.

This is going to change significantly when Issue #6087 is implemented.

Robert Bailey
  • 17,866
  • 3
  • 50
  • 58
  • Thanks again Robert. I note (as you say) that the Vagrant provisioning separates master from minions, which is ok. For our staging machines I guess I would just adjust Ansible inventory to include master in minions group. #2303 sounds great. – Ashley Aitken Jan 08 '15 at 07:52
  • Robert, Is it implemented yet? Issue is closed, but I see you created the new one for it. If yes - is there any example/guideline? If no - just say if its doable via current steps of installing kubernetes - if I just install kubernetes binaries and systemd services for both master and minion (apiserver, controller-manager and kubelet) on the same single machine, will it work? thx. – sandric Apr 15 '15 at 20:59
  • The work has been moved to #6087 (I've updated the original link). I have it working locally in my own branch and should have a pull request out this week. In my working code, I now see the kubelet on the master as a schedulable node in the cluster. – Robert Bailey Apr 16 '15 at 03:12
6

You need to taint your master node to run containers on it, although not recommended.

Run this on your master node:

kubectl taint nodes --all node-role.kubernetes.io/master-

Courtesy of Alex Ellis' blog post here.

loonison101
  • 180
  • 3
  • 4
  • It did not work for me: ```~% kubectl taint nodes --all node-role.kubernetes.io/master- node "master1" untainted error: taint "node-role.kubernetes.io/master:" not found``` – sekrett Jun 26 '18 at 12:51
  • Thanks. This command worked on Ubuntu 18.04 and Kubernetes 1.11.2 – laimison Aug 22 '18 at 04:07
  • This also worked for me on CentOS and K8s 1.14.2. AFAICT, the above error message will be shown for non-master nodes/if executed multiple times, but can be ignored. – ST-DDT Jun 11 '19 at 07:02
  • Shouldn't this say : *You need to **untaint** your master* ? – k1eran Sep 13 '19 at 09:42
  • 1
    Why it's not recommended? What are the downsides of this approach? – laimison Dec 10 '19 at 14:29
1

You can try this code:

kubectl label node [name_of_node] node-short-name=node-1 

Create yaml file (first.yaml)

apiVersion: v1
kind: Pod
metadata:
 name: nginxtest 
 labels:
  env: test
spec:
 containers:
 - name: nginx 
   image: nginx 
   imagePullPolicy: IfNotPresent
 nodeSelector: 
  node-short-name: node-1

Create a pod

kubectl create –f  first.yaml
Vageesha
  • 51
  • 1