部署
1. Kubernetes是什么
- Kubernetes是一個用于自動部署、擴(kuò)展和管理容器化應(yīng)用程序的開源系統(tǒng)
2. Kubernetes的優(yōu)勢
- 自動化容器部署
- 資源管理與容器調(diào)度
- 服務(wù)注冊發(fā)現(xiàn)與負(fù)載均衡
- 內(nèi)置配置與秘鑰管理
- 豐富的社區(qū)組件
- 極強(qiáng)的可擴(kuò)展性
3. 環(huán)境搭建
- 安裝Docker Desktop
- 安裝Kubernetes
- 安裝Helm
- 部署基礎(chǔ)設(shè)施
Docker Desktop內(nèi)置了Kubernetes,勾選并確定即可啟用
Helm是在Kubernetes中部署應(yīng)用的包管理,可以將應(yīng)用像Nuget包一樣打包,然后將部署文件打包成Helm目錄,使用Helm命令去部署應(yīng)用程序,這樣可以版本化管理部署腳本
安裝Helm之前需要安裝Chocolatey,官方安裝腳本如下:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
安裝Helm,安裝腳本
//Use Chocolatey on Windows //注:安裝的時候需要保證網(wǎng)絡(luò)能夠訪問googleapis這個域名 //本行命令需要需要管理員身份 choco install kubernetes-helm //Change helm repo helm repo add stable http://mirror.azure.cn/kubernetes/charts/ //Update charts repo helm repo update
安裝Ingress,dashboard
?kubectl apply -f mandatory.yaml kubectl apply -f ingress-port.yaml kubectl apply -f kubernetes-dashboard.yaml kubectl apply -f kubernetes-dashboard-ingress.yaml $TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1] kubectl config set-credentials docker-for-desktop --token="${TOKEN}" echo $TOKEN "Any key to exit" ; Read-Host | Out-Null ; Exit
安裝Prometheus,alertManager和Grafana到集群腳本
helm repo add stable http://mirror.azure.cn/kubernetes/charts/ helm repo update helm upgrade prometheus-operator stable/prometheus-operator --version 8.10.0 --values .\prometheus-operator\values.yaml --namespace kube-system
4. 應(yīng)用部署
- 準(zhǔn)備Dockerfile
- 構(gòu)建鏡像
- 準(zhǔn)備部署
- 部署應(yīng)用
應(yīng)用入口基于Ingress,其內(nèi)置實際是Nginx,實現(xiàn)了網(wǎng)絡(luò)復(fù)雜均衡并且支持一定的路由策略;
Prometheus是一個持續(xù)數(shù)據(jù)庫,作用是收集監(jiān)控的指標(biāo)數(shù)據(jù);
AlertManager是與Prometheus結(jié)合,檢測指標(biāo)是否有異常,當(dāng)指標(biāo)異常是負(fù)責(zé)發(fā)起告警
Granfana則是將AlertManager和Prometheus展示出來,最強(qiáng)大的能力就是制作監(jiān)控看板文章來源:http://www.zghlxwxcb.cn/news/detail-687712.html
注意點文章來源地址http://www.zghlxwxcb.cn/news/detail-687712.html
- 使用Nuget.config配置編譯時的私有包倉庫
- 時區(qū)設(shè)置
到了這里,關(guān)于【微服務(wù)部署】01-Kubernetes部署流程的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!