################## Rancher v2.1.7 + Kubernetes 1.13.4 ################
####################### 以下为声明 #####################
此文档是在两台机上进行的实践,kubernetes处于不断开发阶段
不能保证每个步骤都能准确到同步开发进度,所以如果安装部署过程中有问题请尽量google
按照下面步骤能得到什么?
1.两台主机之一会作为Rancher的server,另外一台作为Rancher Server的node节点添加进Rancher Server,得到安装好的Rancher,并以Rancher UI进行呈现
2.作为node节点的主机会被安装kubernetes,并以kubernetes dashboard的方式呈现
3.将建立一个登陆账号登陆kubernetes dashboard 并解决kubernetes dashboard token超时的问题
4.部署测试pod 和 container,(以nginx为例)
5,认识Rancher和kubernetes,知道其长什么样子能做什么工作。
6.此文不做生产环境使用,如果使用到生产环境,责任自负。只作为学习Rancher和kubernetes使用,由于时间关系,文中有错误的地方欢迎指正交流。
7.此文分为三部分:
CentOS7安装Rancher2.0并部署kubernetes (一)---部署Rancher
CentOS7安装Rancher2.0并部署kubernetes (二)---部署kubernetes
CentOS7安装Rancher2.0并部署kubernetes (三)---解决登录kubernets超时和部署测试Pod和Containter[nginx为例]
############################## 下面为文档正文 #####################################
kubectl create deployment my-nginx --image=nginx kubectl describe deployment my-nginx kubectl create service nodeport my-nginx --tcp=80:80 kubectl get pods kubectl get svc
[root@node01 ~]# kubectl create deployment my-nginx --image=nginx deployment.apps/my-nginx created
[root@node01 ~]# kubectl describe deployment my-nginx Name: my-nginx Namespace: default CreationTimestamp: Thu, 21 Mar 2019 23:55:03 +0800 Labels: app=my-nginx Annotations: deployment.kubernetes.io/revision: 1 Selector: app=my-nginx Replicas: 1 desired | 1 updated | 1 total | 0 available | 1 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge Pod Template: Labels: app=my-nginx Containers: nginx: Image: nginx Port: <none> Host Port: <none> Environment: <none> Mounts: <none> Volumes: <none> Conditions: Type Status Reason ---- ------ ------ Available False MinimumReplicasUnavailable Progressing True ReplicaSetUpdated OldReplicaSets: <none> NewReplicaSet: my-nginx-6cc48cd8db (1/1 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 9s deployment-controller Scaled up replica set my-nginx-6cc48cd8db to 1
[root@node01 ~]# kubectl create service nodeport my-nginx --tcp=80:80 service/my-nginx created [root@node01 ~]# kubectl get pods NAME READY STATUS RESTARTS AGE my-nginx-6cc48cd8db-bnvtb 1/1 Running 0 47s nginx-demo-f77fb4b7-r9454 1/1 Running 0 21h
[root@node01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 21h
my-nginx NodePort 10.43.106.74 <none> 80:30658/TCP 45s
nginx-demo ClusterIP 10.43.52.173 <none> 80/TCP 21h
nginx-demo-nodeport NodePort 10.43.230.47 <none> 80:30147/TCP 21h
看到my-nginx NodePort 10.43.106.74 <none> 80:30658/TCP 45s 这一行

