日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

K8S的HelloWorld之旅

發布時間:2023/11/30 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 K8S的HelloWorld之旅 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 安裝kubectl。
  • 使用Google提供商(如Google Container Engine或Amazon Web Services)創建Kubernetes群集。本教程創建一個?外部負載均衡器,它需要一個云提供商。
  • 配置kubectl與Kubernetes API服務器通信。有關說明,請參閱云提供商的文檔。

在五個pod中運行的應用程序創建一個Service

1、在群集中運行Hello World應用程序:

kubectl run hello-world --replicas=5 --labels="run=load-balancer-example" --image=gcr.io/google-samples/node-hello:1.0 --port=8080

以上命令創建一個?Deployment?對象和一個關聯的?ReplicaSet?對象。ReplicaSet?有五個?Pods,每個Pods都運行Hello World應用程序。

2、顯示有關Deployment的信息:

kubectl get deployments hello-worldkubectl describe deployments hello-world

3、顯示有關ReplicaSet對象的信息:

kubectl get replicasetskubectl describe replicasets

4、使用deployment創建暴露的Service對象

kubectl expose deployment hello-world --type=LoadBalancer --name=my-service

5、顯示有關Service的信息:

kubectl get services my-service

輸出:

NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGEmy-service 10.3.245.137 104.198.205.71 8080/TCP 54s

注意:如果外部IP地址顯示為<pending>,請等待一分鐘再次輸入相同的命令。

6、顯示Service有關詳細信息:

kubectl describe services my-service

輸出:

Name: my-serviceNamespace: defaultLabels: run=load-balancer-exampleSelector: run=load-balancer-exampleType: LoadBalancerIP: 10.3.245.137LoadBalancer Ingress: 104.198.205.71Port: <unset> 8080/TCPNodePort: <unset> 32377/TCPEndpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...Session Affinity: NoneEvents:

記錄Service公開的外部IP地址。在此例子中,外部IP地址為104.198.205.71。還要注意Port的值。在這個例子中,端口是8080。

7、在上面的輸出中,您可以看到該服務有多個端點:10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more…。這些是運行Hello World應用程序的pod的內部地址。要驗證這些是pod地址,請輸入以下命令:

kubectl get pods --output=wide

輸出類似于:

NAME ... IP NODEhello-world-2895499144-1jaz9 ... 10.0.1.6 gke-cluster-1-default-pool-e0b8d269-1afchello-world-2895499144-2e5uh ... 0.0.1.8 gke-cluster-1-default-pool-e0b8d269-1afchello-world-2895499144-9m4h1 ... 10.0.0.6 gke-cluster-1-default-pool-e0b8d269-5v7ahello-world-2895499144-o4z13 ... 10.0.1.7 gke-cluster-1-default-pool-e0b8d269-1afchello-world-2895499144-segjf ... 10.0.2.5 gke-cluster-1-default-pool-e0b8d269-cpuc

8、使用外部IP地址訪問Hello World應用程序:

curl http://<external-ip>:<port>

<external-ip>是你Service的外部IP地址,并且<port>是Port你的Service描述中的值。

對成功請求的響應是一個hello消息:

Hello Kubernetes!

刪除方法

要刪除服務,請輸入以下命令:

kubectl delete services my-service

要刪除Deployment,ReplicaSet和運行Hello World應用程序的Pods,請輸入以下命令:

kubectl delete deployment hello-world

原文?https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/

總結

以上是生活随笔為你收集整理的K8S的HelloWorld之旅的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。