博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kubernetes 环境搭建(ubuntu16.04)
阅读量:4926 次
发布时间:2019-06-11

本文共 4769 字,大约阅读时间需要 15 分钟。

通过kubeadm安装kubernetes的教程:

1: 首先在每台机器上安装: docker(1.12), kubeadm(1.6), kubectl, kubelet, kubernetes-cni
apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list   
deb http://apt.kubernetes.io/ kubernetes-xenial main #将kubernetes的源加入到当前的source list中
EOF
apt-get update
# Install docker if you don't have it already.
apt-get install -y docker-engine
apt-get install -y kubelet kubeadm kubectl kubernetes-cni
~~~~~~~~~~~~~~~~~~~~~~~~
其中docker install 安装注意事项:
https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository
由于通过k8s管理containers,只需要有docker-engine部分就可以了,其它的并不需要,因此:
有两个命令可以查看当前可以安装的docker-ce版本和docker-engine版本:
apt-cache policy docker-engine
apt-cache madison docker-ce
~~~~~~~~~~~~~~~~~~~~~~~~~
2: 然后在master节点上:
kubeadm init
第一次执行等待时间比较长,卡在(Created API client, waiting for the control plane to become ready)
解决办法:kubeadm reset -> kubeadm init
当出现:
renjingui@renjg-HP-Compaq-Pro-6380-MT:~$ sudo kubeadm init
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
[init] Using Kubernetes version: v1.6.2
[init] Using Authorization mode: RBAC
[preflight] Running pre-flight checks
[preflight] Starting the kubelet service
[certificates] Generated CA certificate and key.
[certificates] Generated API server certificate and key.
[certificates] API Server serving cert is signed for DNS names [renjg-HP-Compaq-Pro-6380-MT kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 109.123.123.6]
[certificates] Generated API server kubelet client certificate and key.
[certificates] Generated service account token signing key and public key.
[certificates] Generated front-proxy CA certificate and key.
[certificates] Generated front-proxy client certificate and key.
[certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf"
[kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
[apiclient] Created API client, waiting for the control plane to become ready
[apiclient] All control plane components are healthy after 16.520114 seconds
[apiclient] Waiting for at least one node to register
[apiclient] First node has registered after 4.010585 seconds
[token] Using token: d9961d.36bce67db0c5bd3b
[apiconfig] Created RBAC rules
[addons] Created essential addon: kube-proxy
[addons] Created essential addon: kube-dns
Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run (as a regular user):
  sudo cp /etc/kubernetes/admin.conf $HOME/
  sudo chown $(id -u):$(id -g) $HOME/admin.conf
  export KUBECONFIG=$HOME/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  http://kubernetes.io/docs/admin/addons/
You can now join any number of machines by running the following on each node
as root:
  kubeadm join --token d9961d.36bce67db0c5bd3b 109.123.123.6:6443
就说明init成功了。
通过: kubectl taint nodes --all node-role.kubernetes.io/master- 可以将一个master节点映射为一个node节点
通过 kubectl get nodes 可以查看当前节点情况。
3: 配置网络环境。
由于机器的硬件环境不同,所以要采用通用的网络组件,Flannel 和 Weave Net,前面一种没有成功,原因:dns docker container启动不了
后面一种配置方法:
kubectl apply -f https://git.io/weave-kube-1.6
可以查看所有的namespace的信息:
renjingui@renjg-HP-Compaq-Pro-6380-MT:~$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                                  READY     STATUS    RESTARTS   AGE
kube-system   etcd-renjg-hp-compaq-pro-6380-mt                      1/1       Running   0          6m
kube-system   kube-apiserver-renjg-hp-compaq-pro-6380-mt            1/1       Running   0          6m
kube-system   kube-controller-manager-renjg-hp-compaq-pro-6380-mt   1/1       Running   0          6m
kube-system   kube-dns-3913472980-1j8dx                             3/3       Running   0          7m
kube-system   kube-proxy-4j745                                      1/1       Running   0          7m
kube-system   kube-scheduler-renjg-hp-compaq-pro-6380-mt            1/1       Running   0          6m
kube-system   weave-net-r4b8d                                       2/2       Running   0          5m
renjingui@renjg-HP-Compaq-Pro-6380-MT:~$
4:部署应用/调试信息
kubectl describe -n kube-system po kube-flannel-ds-rr7xv
                    (NAMESPACE)            (NAME)
5:删除一个节点:
Master:
    kubectl drain maoxj-optiplex-7010 --delete-local-data --force --ignore-daemonsets
    kubectl delete node <node name>
node:
    kubeadm reset
6:加入Cluster的方式为:
在node节点上执行:
    kubeadm join --token a93f59.e500af089136cc83 109.123.123.6:6443
    
7:添加dashboard:
    在master节点上执行
    参看链接:
    https://github.com/kubernetes/dashboard#kubernetes-dashboard
    apache 转发代理配置:
    <VirtualHost *:8081>
        ProxyRequests On
        ProxyPass / http://127.0.0.1:8001/
    </VirtualHost>

转载于:https://www.cnblogs.com/Spider-spiders/p/6841088.html

你可能感兴趣的文章
计算机网络介绍,TCP协议,Socket网络编程
查看>>
移动端页面输入法挡住input输入框的解决方法
查看>>
操作系统--进程
查看>>
LWP::UserAgent - Web user agent class Web 用户agent 类:
查看>>
zookeeper 手动T掉已挂节点
查看>>
apache commons io入门
查看>>
在OS X 10.9配置WebDAV服务器联合NSURLSessionUploadTask实现文件上传
查看>>
C语言位运算
查看>>
OSI七层协议模型、TCP/IP四层模型学习笔记
查看>>
windown vs2012 编译ffplay
查看>>
RTMP协议规范(转载)
查看>>
盘点那些大牌互联网公司内部使用的JavaScript库
查看>>
CentOS 7.0下使用yum安装MySQL
查看>>
vue初级学习--路由router的编写(resolve的使用)
查看>>
批处理学习01
查看>>
java 继承练习题5
查看>>
英媒:滴滴和优步每年烧钱64亿
查看>>
HTMLParser-简单HTML和XHTML解析
查看>>
Java_基础_关键字_volatile
查看>>
American Heritage usaco
查看>>