Will (can) Kubernetes run Docker containers on the

2020-05-25 06:53发布

问题:

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.

回答1:

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.



回答2:

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.



回答3:

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


标签: kubernetes