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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

结合使用 Draft 与 Tencent Kubernetes Engine (TKE)

發(fā)布時(shí)間:2023/12/4 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 结合使用 Draft 与 Tencent Kubernetes Engine (TKE) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Draft 是一種開(kāi)源工具,有助于在 Kubernetes 群集中打包和部署應(yīng)用程序容器,讓你專(zhuān)注于開(kāi)發(fā)周期 - 專(zhuān)注開(kāi)發(fā)的“內(nèi)部循環(huán)”。 在開(kāi)發(fā)代碼期間,但尚未將代碼提交到版本控制之前,Draft 將會(huì)運(yùn)行。 借助 Draft,可在代碼發(fā)生更改時(shí)快速將應(yīng)用程序重新部署到 Kubernetes。本文介紹如何對(duì) TKE上的 Kubernetes 群集使用 Draft。

必備組件

本文中所有的步驟假設(shè)已創(chuàng)建 TKE群集并已與該群集建立 kubectl 連接。 如果你還沒(méi)有,請(qǐng)參閱 TKE快速入門(mén)https://cloud.tencent.com/product/tke/getting-started 。

Tencent Hub容器注冊(cè)表 (tencenthub) 中需有一個(gè)專(zhuān)用 Docker 注冊(cè)表。 有關(guān)創(chuàng)建 tencenthub實(shí)例的步驟,請(qǐng)參閱 TencentHub容器注冊(cè)表快速入門(mén)https://cloud.tencent.com/document/product/857/17143 。

Helm 也必須安裝在 TKE群集中。 TKE的新版本還在內(nèi)測(cè)中,需求申請(qǐng)內(nèi)測(cè)開(kāi)通 https://cloud.tencent.com/document/product/457/31699。

最后,必須安裝 Docker: https://www.docker.com/ 。

安裝 Draft

Draft CLI 是一個(gè)在開(kāi)發(fā)環(huán)境上運(yùn)行的客戶(hù)端,可將代碼部署到 Kubernetes 群集中。 ?請(qǐng)參閱 Draft 安裝指南:https://github.com/Azure/draft/tree/master/docs 。本文我們使用windows環(huán)境。

從https://github.com/Azure/draft/releases 下載最新的0.16版本,我把它解壓放在目錄C:\workshop\draft,把這個(gè)目錄路徑加入到環(huán)境變量Path 即完成客戶(hù)端的安裝。

使用 draft init 命令初始化 Draft。

接下來(lái)也需要安裝draft 依賴(lài)的Helm ,Helm的安裝參考 https://helm.sh/docs/using_helm/#installing-helm,我直接從https://github.com/helm/helm/releases 下載,我也把它解壓在C:\workshop\draft。

c:\workshop\draft>helm init

Creating C:\Users\geffzhang\.helm\repository\repositories.yaml

Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com

Error: Looks like "https://kubernetes-charts.storage.googleapis.com" is not a valid chart repository or cannot be reached: Get https://kubernetes-charts.storage.googleapis.com/index.yaml: read tcp 192.168.5.238:50765->172.217.160.80:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

helm init會(huì)連接kubectl默認(rèn)連接的kubernetes集群(可以通過(guò)kubectl config view查看),一旦連接集群成功,tiller會(huì)被安裝到kube-system namespace中。

但是,在國(guó)內(nèi)環(huán)境中,我們直接使用helm init會(huì)無(wú)法拉取到tiller鏡像,需要手動(dòng)指定鏡像地址,同時(shí)如果Kubernetes集群開(kāi)啟了rbac,還需要指定運(yùn)行tiller的servicaccount,并為該serviceaccount作合適的授權(quán)。

從https://github.com/Azure/draft/releases 下載最新的0.16版本,我把它解壓放在目錄C:\workshop\draft,把這個(gè)目錄路徑加入到環(huán)境變量Path 即完成客戶(hù)端的安裝。

使用 draft init 命令初始化 Draft。

接下來(lái)也需要安裝draft 依賴(lài)的Helm ,Helm的安裝參考 https://helm.sh/docs/using_helm/#installing-helm,我直接從https://github.com/helm/helm/releases 下載,我也把它解壓在C:\workshop\draft。

c:\workshop\draft>helm init

Creating C:\Users\geffzhang\.helm\repository\repositories.yaml

Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com

Error: Looks like "https://kubernetes-charts.storage.googleapis.com" is not a valid chart repository or cannot be reached: Get https://kubernetes-charts.storage.googleapis.com/index.yaml: read tcp 192.168.5.238:50765->172.217.160.80:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

helm init會(huì)連接kubectl默認(rèn)連接的kubernetes集群(可以通過(guò)kubectl config view查看),一旦連接集群成功,tiller會(huì)被安裝到kube-system namespace中。

但是,在國(guó)內(nèi)環(huán)境中,我們直接使用helm init會(huì)無(wú)法拉取到tiller鏡像,需要手動(dòng)指定鏡像地址,同時(shí)如果Kubernetes集群開(kāi)啟了rbac,還需要指定運(yùn)行tiller的servicaccount,并為該serviceaccount作合適的授權(quán)。

最簡(jiǎn)單方法是手動(dòng)訪問(wèn)https://kubernetes-charts.storage.googleapis.com/index.yaml, 下載保存到C:\Users\geffzhang\.helm\repository\repositories.yaml

配置 Draft

Draft 在本地生成容器映像,然后從本地注冊(cè)表部署這些映像(例如使用 Minikube),或使用指定的映像注冊(cè)表。 本文使用 Tencent Hub容器注冊(cè)表 (Tecenthub),因此,必須在 TKE群集與 TencentHub注冊(cè)表之間建立信任關(guān)系,然后將 Draft 配置為向 TencentHub推送容器映像。

c:\workshop\Github\draft\examples\example-dotnet>docker login --username=geffzhang_weyhd_com hub.tencentyun.com

Password:

Login Succeeded

c:\workshop\Github\draft\examples\example-dotnet>draft up

Draft Up Started: 'example-dotnet': 01D7BCHQ4HK1P67582WWFZ92W6

example-dotnet: Building Docker Image: SUCCESS ? (0.9996s)

example-dotnet: Pushing Docker Image: SUCCESS ? (2.5611s)

example-dotnet: Releasing Application: SUCCESS ? (3.5553s)

Inspect the logs with `draft logs 01D7BCHQ4HK1P67582WWFZ92W6`

在本地測(cè)試應(yīng)用程序

若要測(cè)試應(yīng)用程序,請(qǐng)使用 draft connect 命令。 此命令將代理與 Kubernetes pod 之間的安全連接。 完成后,可在提供的 URL 上訪問(wèn)應(yīng)用程序。

c:\workshop\Github\draft\examples\example-dotnet>draft connect

Connect to example-dotnet:80 on localhost:52672

[example-dotnet]: Hosting environment: Production

[example-dotnet]: Content root path: /app

[example-dotnet]: Now listening on: http://[::]:80

[example-dotnet]: Application started. Press Ctrl+C to shut down.

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]

[example-dotnet]: Request starting HTTP/1.1 GET http://localhost:52672/

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]

[example-dotnet]: Request finished in 67.1166ms 200

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]

[example-dotnet]: Request starting HTTP/1.1 GET http://localhost:52672/favicon.ico

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]

[example-dotnet]: Request finished in 0.1648ms 200

循環(huán)訪問(wèn)應(yīng)用程序

已配置 Draft 并且應(yīng)用程序正在 Kubernetes 中運(yùn)行,現(xiàn)在應(yīng)開(kāi)始迭代代碼。 每當(dāng)要測(cè)試更新的代碼時(shí),請(qǐng)運(yùn)行 draft up 命令來(lái)更新正在運(yùn)行的應(yīng)用程序。

c:\workshop\Github\draft\examples\example-dotnet>draft up

Draft Up Started: 'example-dotnet': 01D7BCR2AHENBZHGYMPHMKQ9VD

example-dotnet: Building Docker Image: SUCCESS ? (26.0217s)

example-dotnet: Pushing Docker Image: SUCCESS ? (293.0051s)

example-dotnet: Releasing Application: SUCCESS ? (4.1565s)

Inspect the logs with `draft logs 01D7BCR2AHENBZHGYMPHMKQ9VD`

c:\workshop\Github\draft\examples\example-dotnet>draft connect

Connect to example-dotnet:80 on localhost:52980

[example-dotnet]: Hosting environment: Production

[example-dotnet]: Content root path: /app

[example-dotnet]: Now listening on: http://[::]:80

[example-dotnet]: Application started. Press Ctrl+C to shut down.

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]

[example-dotnet]: Request starting HTTP/1.1 GET http://localhost:52980/

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]

[example-dotnet]: Request finished in 63.1118ms 200

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]

[example-dotnet]: Request starting HTTP/1.1 GET http://localhost:52980/favicon.ico

[example-dotnet]: [40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]

[example-dotnet]: Request finished in 0.1467ms 200

原文地址:https://cloud.tencent.com/developer/article/1409013

.NET社區(qū)新聞,深度好文,歡迎訪問(wèn)公眾號(hào)文章匯總 http://www.csharpkit.com

總結(jié)

以上是生活随笔為你收集整理的结合使用 Draft 与 Tencent Kubernetes Engine (TKE)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。