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

##################    Rancher v2.1.7  +    Kubernetes 1.13.4  ################html

#######################    如下爲聲明  #####################node

此文檔是在兩臺機上進行的實踐,kubernetes處於不斷開發階段nginx

不能保證每一個步驟都能準確到同步開發進度,因此若是安裝部署過程當中有問題請儘可能googlegit

按照下面步驟能獲得什麼?github

1.兩臺主機之一會做爲Rancher的server,另一臺做爲Rancher Server的node節點添加進Rancher Server,獲得安裝好的Rancher,並以Rancher UI進行呈現bash

2.做爲node節點的主機會被安裝kubernetes,並以kubernetes dashboard的方式呈現app

3.將創建一個登錄帳號登錄kubernetes dashboard 並解決kubernetes dashboard token超時的問題tcp

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
 
 
相關文章
相關標籤/搜索