[原]CentOS7安裝Rancher2.1並部署kubernetes (三)---解決登錄kubernets超時和部署測試Pod和Containter[nginx為例]


##################    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為例]

##############################   下面為文檔正文  #####################################

【啟動一個服務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 這一行
 
 
End
 
 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM