Kubernetes學習筆記---安裝

Kubernetes安裝環境html

Centos7.1系統的機器3臺node

Master:192.168.0.120docker

Nodes:192.168.0.106, 192.168.0.107 json

 

=====api

Masteride

=====this

1 在Master上安裝kubernetes etcd flannelatom

yum install kubernetes etcd flannel -yurl

 

2 修改配置文件/etc/kubernetes/controller-managerrest

#指定key文件,key文件能夠經過命令生成:openssl genrsa -out /etc/kubernetes/service.key 2048

KUBE_CONTROLLER_MANAGER_ARGS="--service_account_private_key_file=/etc/kubernetes/service.key"

 

3 修改配置文件/etc/kubernetes/apiserver

# The address on the local server to listen to. 設爲所有監聽

KUBE_API_ADDRESS="--address=0.0.0.0"

 

# Comma separated list of nodes in the etcd cluster . 指定etcd節點的地址

KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.0.120:2379"

 

# Address range to use for services. 這個是設置從此運行Service所在的ip網段

KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.1.0/24"

 

# Add your own! 指定key文件

KUBE_API_ARGS="--service_account_key_file=/etc/kubernetes/service.key"

 

4 修改配置文件/etc/kubernetes/config

# How the controller-manager, scheduler, and proxy find the apiserver

KUBE_MASTER="--master=http://192.168.0.120:8080"

 

5 修改配置文件/etc/etcd/etcd.conf

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.120:2379"

 

6 啓動etcd和kubernetes的服務

systemctl start etcd kube-apiserver kube-controller-manager kube-scheduler

systemctl enable etcd kube-apiserver kube-controller-manager kube-scheduler

 

7 修改配置文件/etc/sysconfig/flanneld

# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD="http://192.168.0.120:2379"

 

# etcd config key.  This is the configuration key that flannel queries

# For address range assignment

FLANNEL_ETCD_KEY="/atomic.io/network"

 

8 設置etcd config的值

# 建立一個文件內容以下,Network指定的IP將爲之後容器運行的網段:

cat flannel-config.json

{

  "Network":"172.16.0.0/16",

  "SubnetLen":24,

  "Backend":{

    "Type":"vxlan",

    "VNI":1

  }

}

 

# 經過文件內容來設置etc的config

etcdctl set atomic.io/network/config < flannel-config.json

 

9 啓動flannel服務 

systemctl start flanneld

systemctl enable flanneld

 

到這裏Master就安裝配置完畢,執行下面命令能夠查看master信息:

kubectl cluster-info

 

====

Nodes

====

每一個節點上都要作以下的安裝配置,這裏以107節點爲例(已安裝docker爲前提)

 

1 安裝kubernetes和flannel

yum -y install kubernetes flannel

 

2 修改/etc/kubernetes/config

KUBE_MASTER="--master=http://192.168.0.120:8080"

 

3 修改/etc/kubernetes/kubelet

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)

KUBELET_ADDRESS="--address=0.0.0.0"

 

# You may leave this blank to use the actual hostname

KUBELET_HOSTNAME="--hostname-override=node107.kuber.com"

 

# location of the api-server

KUBELET_API_SERVER="--api-servers=http://192.168.0.120:8080"

 

4 修改/etc/sysconfig/flanneld

# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD="http://192.168.0.120:2379"

 

5 啓動flannel和kube相關服務
# 注意Node和Master上啓動的kube的服務是不同的

systemctl start flanneld kube-proxy kubelet

systemctl enable flanneld kube-proxy kubelet

 

# 重啓docker服務

systemctl restart docker

 

 

到此,Node節點配置完畢,能夠在Master上執行下面命令查看節點信息

kubectl get nodes

 

來源:http://www.youruncloud.com/docker/1_77.html

相關文章
相關標籤/搜索