设为首页 收藏本站
查看: 1427|回复: 0

[经验分享] first step of kubernetes on ubuntu for single node

[复制链接]

尚未签到

发表于 2016-4-22 12:49:46 | 显示全部楼层 |阅读模式
from:https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/ubuntu.md

 

Kubernetes Deployment On Bare-metal Ubuntu Nodes

This document describes how to deploy kubernetes on ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to any number of minion nodes by changing some settings with ease. The original idea was heavily inspired by @jainvipin 's ubuntu single node work, which has been merge into this document.
Cloud team from Zhejiang University will maintain this work.


Prerequisites:


1 The minion nodes have installed docker version 1.2+ and bridge-utils to manipulate linux bridge
2 All machines can communicate with each other, no need to connect Internet (should use private docker registry in this case)
3 These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it should also work on most Ubuntu versions
4 Dependences of this guide: etcd-2.0.9, flannel-0.4.0, k8s-0.18.0, but it may work with higher versions
5 All the remote servers can be ssh logged in without a password by using key authentication


Main Steps



I. Make kubernetes , etcd and flanneld binaries


First clone the kubernetes github repo, $ git clone https://github.com/GoogleCloudPlatform/kubernetes.git then $ cd kubernetes/cluster/ubuntu.
Then run $ ./build.sh, this will download all the needed binaries into ./binaries.
You can customize your etcd version, flannel version, k8s version by changing variable ETCD_VERSION , FLANNEL_VERSIONand K8S_VERSION in build.sh, default etcd version is 2.0.9, flannel version is 0.4.0 and K8s version is 0.18.0.
Please make sure that there are kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, kube-proxy,etcd, etcdctl and flannel in the binaries/master or binaries/minion directory.

  We used flannel here because we want to use overlay network, but please remember it is not the only choice, and it is also not a k8s' necessary dependence. Actually you can just build up k8s cluster natively, or use flannel, Open vSwitch or any other SDN tool you like, we just choose flannel here as a example.



II. Configure and start the kubernetes cluster


An example cluster is listed as below:


IP Address
Role

10.10.103.223
minion


10.10.103.162
minion


10.10.103.250
both master and minion

First configure the cluster information in cluster/ubuntu/config-default.sh, below is a simple sample.

export nodes="vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"
export roles=("ai" "i" "i")
export NUM_MINIONS=${NUM_MINIONS:-3}
export SERVICE_CLUSTER_IP_RANGE=11.1.1.0/24
export FLANNEL_NET=172.16.0.0/16


The first variable nodes defines all your cluster nodes, MASTER node comes first and separated with blank space like<user_1@ip_1> <user_2@ip_2> <user_3@ip_3>
Then the roles variable defines the role of above machine in the same order, "ai" stands for machine acts as both master and minion, "a" stands for master, "i" stands for minion. So they are just defined the k8s cluster as the table above described.
The NUM_MINIONS variable defines the total number of minions.
The SERVICE_CLUSTER_IP_RANGE variable defines the kubernetes service IP range. Please make sure that you do have a valid private ip range defined here, because some IaaS provider may reserve private ips. You can use below three private network range accordin to rfc1918. Besides you'd better not choose the one that conflicts with your own private network range.

10.0.0.0        -   10.255.255.255  (10/8 prefix)
172.16.0.0      -   172.31.255.255  (172.16/12 prefix)
192.168.0.0     -   192.168.255.255 (192.168/16 prefix)

The FLANNEL_NET variable defines the IP range used for flannel overlay network, should not conflict with aboveSERVICE_CLUSTER_IP_RANGE.
After all the above variable being set correctly. We can use below command in cluster/ directory to bring up the whole cluster.
$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh
The scripts is automatically scp binaries and config files to all the machines and start the k8s service on them. The only thing you need to do is to type the sudo password when promoted. The current machine name is shown below like. So you will not type in the wrong password.


Deploying minion on machine 10.10.103.223
...
[sudo] password to copy files and start minion:

If all things goes right, you will see the below message from console Cluster validation succeeded indicating the k8s is up.
All done !
You can also use kubectl command to see if the newly created k8s is working correctly. The kubectl binary is under thecluster/ubuntu/binaries directory. You can move it into your PATH. Then you can use the below command smoothly.
For example, use $ kubectl get nodes to see if all your minion nodes are in ready status. It may take some time for the minions ready to use like below.


NAME            LABELS                                 STATUS
10.10.103.162   kubernetes.io/hostname=10.10.103.162   Ready
10.10.103.223   kubernetes.io/hostname=10.10.103.223   Ready
10.10.103.250   kubernetes.io/hostname=10.10.103.250   Ready


Also you can run kubernetes guest-example to build a redis backend cluster on the k8s.


IV. Deploy addons


After the previous parts, you will have a working k8s cluster, this part will teach you how to deploy addones like dns onto the existing cluster.
The configuration of dns is configured in cluster/ubuntu/config-default.sh.


ENABLE_CLUSTER_DNS=true
DNS_SERVER_IP="192.168.3.10"
DNS_DOMAIN="kubernetes.local"
DNS_REPLICAS=1

The DNS_SERVER_IP is defining the ip of dns server which must be in the service_cluster_ip_range.
The DNS_REPLICAS describes how many dns pod running in the cluster.
After all the above variable have been set. Just type the below command


$ cd cluster/ubuntu
$ KUBERNETES_PROVIDER=ubuntu ./deployAddons.sh

After some time, you can use $ kubectl get pods to see the dns pod is running in the cluster. Done!


IV. Trouble Shooting


Generally, what this approach did is quite simple:



  • Download and copy binaries and configuration files to proper dirctories on every node


  • Configure etcd using IPs based on input from user


  • Create and start flannel network


So, if you see a problem, check etcd configuration first
Please try:



  • Check /var/log/upstart/etcd.log for suspicious etcd log


  • Check /etc/default/etcd, as we do not have much input validation, a right config should be like:

    ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -initial-cluster-state new"

  • You can use below command $ KUBERNETES_PROVIDER=ubuntu ./kube-down.sh to bring down the cluster and run $ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh again to start again.


  • You can also customize your own settings in /etc/default/{component_name} after configured success.


about single node:
modify the config-default file, remove two sub node's ip and roles, change the host node'ip to root@127.0.0.1
 
Problems:
1、about ssh, u need to general a keygen of ssh
  http://roomfourteen224.iyunv.com/admin/blogs/2217054
2、ssh: error: connect to host localhost port 22: Connection refused & denied with root password
  http://roomfourteen224.iyunv.com/admin/blogs/2217056
  3、apt-get remove ssh-client ssh-server  apt-get install ssh-client ssh-server
 
 
 
 
 
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-207451-1-1.html 上篇帖子: Docker集群管理系统Kubernetes 下篇帖子: centos 7安装kubernetes集群
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表