Ubuntu 安装 Kubernetes

Kubernetes是Google开源的容器集群管理系统。它构建于docker技术之上,为容器化的应用提供资源调度、部署运行、服务发现、扩容缩容等整一套功能,本质上可看作是基于容器技术的mini-PaaS平台。本文旨在梳理Kubernetes的架构、概念及基本工作流,并且通过运行一个简单的示例应用来介绍如何使用Kubernetes。

 

搭建环境

第一步,我们需要Kuberntes各组件的二进制可执行文件。有以下两种方式获取:

下载源代码自己编译:

git clone https://github.com/GoogleCloudPlatform/kubernetes.git
cd kubernetes/build
./release.sh  

直接下载人家已经编译打包好的tar文件:

wget https://storage.googleapis.com/kubernetes/binaries.tar.gz

自己编译源码需要先安装好golang,编译完之后在kubernetes/_output/release-tars文件夹下可以得到打包文件。直接下载的方式不需要安装其他软件,但可能得不到最新的版本。

#192.168.124.131 kubernetes server
cp
/usr/local/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin/apiserver /usr/local/bin
cp /usr/local/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin/controller-manager /usr/local/bin
cp /usr/local/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin/scheduler /usr/local/bin

 

#192.168.124.132/192.168.124.133 kubernetes minion
cp
/usr/local/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin/kubelet /usr/local/bin
cp /usr/local/kubernetes/_output/release-stage/server/linux-amd64/kubernetes/server/bin/proxy /usr/local/bin

 

API Server Unit File

cd /lib/systemd/system
vim apiserver.service

 

[Unit]
After=etcd.service
ConditionFileIsExecutable=/usr/local/bin/apiserver
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Wants=etcd.service

[Service]
ExecStart=/usr/local/bin/apiserver \
-address=192.168.124.131 \
-port=8080 \
-portal_net=172.17.0.0/16 \
-etcd_servers=http://192.168.124.131:4001 \
-logtostderr=true \
-v=0 \
-log_dir=/home/kubernetes/logs
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

 

controller-manager.service

 vim controller-manager.service
[Unit]
After=etcd.service
ConditionFileIsExecutable=/usr/local/bin/controller-manager
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Wants=etcd.service

[Service]
ExecStart=/usr/local/bin/controller-manager \
-master=192.168.124.131:8080 \
-machines=192.168.124.132,192.168.124.133
-logtostderr=true \
-v=3 \
-log_dir=/home/kubernetes/logs
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

 scheduler.service

 vim scheduler.service

 

[Unit]
After=etcd.service
ConditionFileIsExecutable=/usr/local/bin/scheduler
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Wants=etcd.service

[Service]
ExecStart=/usr/local/bin/scheduler \
-master=192.168.124.131:8080 \
-logtostderr=false \
-v=3 \
-log_dir=/home/kubernetes/logs
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

 

Minion unit file

cd /lib/systemd/system
vim kubelet.service 
[Unit]
After=etcd.service
ConditionFileIsExecutable=/usr/local/bin/kubelet
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Wants=etcd.service

[Service]
ExecStart=/usr/local/bin/kubelet \
-address=192.168.124.132 \
-port=10250 \
-hostname_override=192.168.124.132 \
-etcd_servers=http://192.168.124.132:4001 \
-logtostderr=true \
-v=3 \
-log_dir=/home/kubernetes/logs
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

proxy.service

vim proxy.service
[Unit]
After=etcd.service
ConditionFileIsExecutable=/usr/local/bin/proxy
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Wants=etcd.service

[Service]
ExecStart=/usr/local/bin/proxy \
-etcd_servers=http://192.168.124.132:4001 \
-logtostderr=true \
-v=3 \
-log_dir=/home/kubernetes/logs
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

部署完毕访问

 

 

 

posted @ 2014-11-05 16:20  saintaxl  阅读(4150)  评论(1编辑  收藏  举报