偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

騰訊云 K8S 集群實(shí)戰(zhàn) Service Mesh—Linkerd2 & Traefik2 部署 emojivoto 應(yīng)用

系統(tǒng)
服務(wù)網(wǎng)格是用于處理服務(wù)間通信的專用基礎(chǔ)設(shè)施層。它負(fù)責(zé)通過包含現(xiàn)代云原生應(yīng)用程序的復(fù)雜服務(wù)拓?fù)鋪砜煽康貍鬟f請(qǐng)求。實(shí)際上,服務(wù)網(wǎng)格通常通過一組輕量級(jí)網(wǎng)絡(luò)代理來實(shí)現(xiàn),這些代理與應(yīng)用程序代碼一起部署,而不需要感知應(yīng)用程序本身。

[[404861]]

 Linkerd 是 Kubernetes 的服務(wù)網(wǎng)格。它通過為您提供運(yùn)行時(shí)調(diào)試(runtime debugging)、可觀察性(observability)、可靠性(reliability)和安全性(security),使運(yùn)行服務(wù)更輕松、更安全 — 所有這些都不需要對(duì)您的代碼進(jìn)行任何更改。

服務(wù)網(wǎng)格是用于處理服務(wù)間通信的專用基礎(chǔ)設(shè)施層。它負(fù)責(zé)通過包含現(xiàn)代云原生應(yīng)用程序的復(fù)雜服務(wù)拓?fù)鋪砜煽康貍鬟f請(qǐng)求。實(shí)際上,服務(wù)網(wǎng)格通常通過一組輕量級(jí)網(wǎng)絡(luò)代理來實(shí)現(xiàn),這些代理與應(yīng)用程序代碼一起部署,而不需要感知應(yīng)用程序本身。— Willian Morgan Buoyant CEO

為什么我們需要 Service Mesh?

1.What's a service mesh? And why do I need one? 一文中做了詳細(xì)的解釋,這里不再贅述。擁抱云原生,微服務(wù)已進(jìn)入 Service Mesh 時(shí)代。

https://buoyant.io/2020/10/12/what-is-a-service-mesh/

為什么折騰 Linkerd2 而不是 Istio?

2.Benchmarking Linkerd and Istio

https://linkerd.io/2021/05/27/linkerd-vs-istio-benchmarks/

部署環(huán)境

  • 騰訊云 TKE K8S 集群(或你自建的私有 K8S 集群)
  • CentOS 7.x

可先快速過一個(gè)官方上手教程,本文是基于此在騰訊云的實(shí)戰(zhàn)詳解。

  • 快速上手 Linkerd v2 Service Mesh(服務(wù)網(wǎng)格)
  • Getting Started

https://linkerd.io/2.10/getting-started

查看集群版本

kubectl version --short

  1. Client Version: v1.16.9 
  2. Server Version: v1.16.9 

Linkerd2 CLI 安裝

首先我們需要下載并安裝最新版本的 linkerd CLI。

我們直接進(jìn)入 Linkerd2 版本發(fā)行頁(yè)面,查看最新版:

https://github.com/linkerd/linkerd2/releases/

這里我們下載 linkerd2-cli-edge-21.6.1-linux-amd64。

https://github.com/linkerd/linkerd2/releases/download/edge-21.6.1/linkerd2-cli-edge-21.6.1-linux-amd64

安裝:

  1. wget -c https://github.com/linkerd/linkerd2/releases/download/edge-21.6.1/linkerd2-cli-edge-21.6.1-linux-amd64 
  2.  
  3. mv linkerd2-cli-edge-21.6.1-linux-amd64 /usr/local/bin/linkerd 
  4.  
  5. chmod 755 /usr/local/bin/linkerd 

現(xiàn)在我們運(yùn)行 linkerd,會(huì)看到如下信息:

  1. Usage: 
  2.   linkerd [command] 
  3.  
  4. Available Commands: 
  5.   check        Check the Linkerd installation for potential problems 
  6.   completion   Output shell completion code for the specified shell (bash, zsh or fish) 
  7.   diagnostics  Commands used to diagnose Linkerd components 
  8.   help         Help about any command 
  9.   identity     Display the certificate(s) of one or more selected pod(s) 
  10.   inject       Add the Linkerd proxy to a Kubernetes config 
  11.   install      Output Kubernetes configs to install Linkerd 
  12.   install-cni  Output Kubernetes configs to install Linkerd CNI 
  13.   jaeger       jaeger manages the jaeger extension of Linkerd service mesh 
  14.   multicluster Manages the multicluster setup for Linkerd 
  15.   profile      Output service profile config for Kubernetes 
  16.   repair       Output the secret/linkerd-config-overrides resource if it has been deleted 
  17.   uninject     Remove the Linkerd proxy from a Kubernetes config 
  18.   uninstall    Output Kubernetes resources to uninstall Linkerd control plane 
  19.   upgrade      Output Kubernetes configs to upgrade an existing Linkerd control plane 
  20.   version      Print the client and server version information 
  21.   viz          viz manages the linkerd-viz extension of Linkerd service mesh 
  22.  
  23. Flags: 
  24.       --api-addr string            Override kubeconfig and communicate directly with the control plane at host:port (mostly for testing) 
  25.       --as string                  Username to impersonate for Kubernetes operations 
  26.       --as-group stringArray       Group to impersonate for Kubernetes operations 
  27.       --cni-namespace string       Namespace in which the Linkerd CNI plugin is installed (default "linkerd-cni") 
  28.       --context string             Name of the kubeconfig context to use 
  29.   -h, --help                       help for linkerd 
  30.       --kubeconfig string          Path to the kubeconfig file to use for CLI requests 
  31.   -L, --linkerd-namespace string   Namespace in which Linkerd is installed ($LINKERD_NAMESPACE) (default "linkerd") 
  32.       --verbose                    Turn on debug logging 
  33.  
  34. Additional help topics: 
  35.   linkerd alpha        experimental subcommands for Linkerd 
  36.  
  37. Use "linkerd [command] --help" for more information about a command. 

安裝 Linkerd2 控制平面

首先,我們需要驗(yàn)證下集群,使用 linkerd check --pre,正常會(huì)輸出如下信息:

  1. Linkerd core checks 
  2. =================== 
  3.  
  4. kubernetes-api 
  5. -------------- 
  6. √ can initialize the client 
  7. √ can query the Kubernetes API 
  8.  
  9. kubernetes-version 
  10. ------------------ 
  11. √ is running the minimum Kubernetes API version 
  12. √ is running the minimum kubectl version 
  13.  
  14. pre-kubernetes-setup 
  15. -------------------- 
  16. √ control plane namespace does not already exist 
  17. √ can create non-namespaced resources 
  18. √ can create ServiceAccounts 
  19. √ can create Services 
  20. √ can create Deployments 
  21. √ can create CronJobs 
  22. √ can create ConfigMaps 
  23. √ can create Secrets 
  24. √ can read Secrets 
  25. √ can read extension-apiserver-authentication configmap 
  26. √ no clock skew detected 
  27.  
  28. pre-kubernetes-capability 
  29. ------------------------- 
  30. √ has NET_ADMIN capability 
  31. √ has NET_RAW capability 
  32.  
  33. linkerd-version 
  34. --------------- 
  35. √ can determine the latest version 
  36. √ cli is up-to-date 
  37.  
  38. Status check results are √ 

部署控制平面:

  1. linkerd install | kubectl apply -f - 

查看 linkerd 命名空間的 pod 部署情況:

  1. kubectl get po -n linkerd 
  2.  
  3. NAME                                      READY   STATUS    RESTARTS   AGE 
  4. linkerd-destination-6c6bf4fc4-282gd       3/3     Running   0          5m 
  5. linkerd-identity-7cd9998969-cvzc8         2/2     Running   0          5m 
  6. linkerd-proxy-injector-855b9b6747-r8pcz   2/2     Running   0          5m 

同樣,我們使用 linkerd check 檢查一下。

ok, 接下來我們部署一些常用的擴(kuò)展,增強(qiáng)我們控制平面的功能。

安裝 Linkerd2 控制平面常用擴(kuò)展

grafana,prometheus,jaeger 等的部署(針對(duì) Linkerd 2 的相關(guān)指標(biāo))

使用如下命令:

  1. linkerd viz install | kubectl apply -f - # on-cluster metrics stack 
  2.  
  3. kubectl get po -n linkerd-viz #審查 namespace, 直到所 pod 都 ready 
  4.  
  5. # grafana-5659477d88-txq5b        0/2     PodInitializing   0          14m 
  6. # metrics-api-6fcb849dc-k9sw5     2/2     Running           0          14m 
  7. # prometheus-798d8d4698-4x8h2     2/2     Running           0          14m 
  8. # tap-f5984d7f7-fkpf9             0/2     PodInitializing   0          14m 
  9. # tap-injector-6b455dd64b-2c82n   0/2     PodInitializing   0          14m 
  10. # web-657dbffb8f-7d2gr            0/2     PodInitializing   0          14m 

如果出現(xiàn)某一個(gè) pod 出現(xiàn)錯(cuò)誤,我們可以通過 kubectl describe po 來獲取詳細(xì)錯(cuò)誤信息,如:

  1. kubectl describe po grafana-5659477d88-txq5b -n linkerd-viz 

比如說,我這里如下鏡像就被卡住了(騰訊云):

  1. cr.l5d.io/linkerd/grafana:edge-21.6.1 
  2. cr.l5d.io/linkerd/tap:edge-21.6.1 
  3. cr.l5d.io/linkerd/web:edge-21.6.1 

大家可以(科學(xué)上網(wǎng))手動(dòng)拉取。

同樣,我們?cè)俨渴饍蓚€(gè)可選的擴(kuò)展。

部署 jaeger:

  1. ## optional 
  2. linkerd jaeger install | kubectl apply -f - # Jaeger collector and UI 
  3.  
  4. kubectl get po -n linkerd-jaeger #審查 namespace 
  5. OR
  6. # docker pull cr.l5d.io/linkerd/jaeger-webhook:edge-21.6.1 
  7. # docker pull jaegertracing/all-in-one:1.19.2 

部署 multicluster:

  1. linkerd multicluster install | kubectl apply -f - # multi-cluster components 
  2. kubectl get po -n linkerd-multicluster 
  3.  
  4. # 果然報(bào)錯(cuò)了 
  5. linkerd-gateway-bcb5888c5-ws6wz   1/2     ErrImagePull   0          21s 

查看報(bào)錯(cuò)信息:

  1. kubectl describe po linkerd-gateway-bcb5888c5-ws6wz -n linkerd-multicluster 
  2. # Normal   BackOff    21s (x5 over 2m13s)  kubelet, k8s-master-01  Back-off pulling image "gcr.io/google_containers/pause" 
  3. # Warning  Failed     21s (x5 over 2m13s)  kubelet, k8s-master-01  Error: ImagePullBackOff 

很明顯(gcr.io/google_containers/pause),我們需要科學(xué)上網(wǎng)(具體怎么做,太多教程了,這里不討論)。

還有一個(gè)問題比較棘手的是,這里即使 gcr.io/google_containers/pause 已經(jīng)存在于本地,部署時(shí)還是回去 gcr.io 拉取。

所以,下面提供另一種方式來弄(沒連外網(wǎng)的情況下)。

使用 kustomize 解決 linkerd-gateway (騰訊云部署)不成功的問題

kustomize 如何安裝,大家自行查看 https://kustomize.io。

首先,導(dǎo)出 linkerd multicluster 部署 yaml 檔。

  1. linkerd multicluster install > linkerd-multicluster.yaml 

然后,我們給它打個(gè)補(bǔ)丁patch-linkerd-multicluster.yaml:

  1. apiVersion: apps/v1 
  2. kind: Deployment 
  3. metadata: 
  4.   annotations: 
  5.     linkerd.io/created-by: linkerd/cli edge-21.6.1 
  6.   labels: 
  7.     app.kubernetes.io/name: gateway 
  8.     app.kubernetes.io/part-of: Linkerd 
  9.     app.kubernetes.io/version: edge-21.6.1 
  10.     linkerd.io/control-plane-component: gateway 
  11.     app: linkerd-gateway 
  12.     linkerd.io/extension: multicluster 
  13.   name: linkerd-gateway 
  14.   namespace: linkerd-multicluster 
  15. spec: 
  16.   replicas: 1 
  17.   selector: 
  18.     matchLabels: 
  19.       app: linkerd-gateway 
  20.   template: 
  21.     metadata: 
  22.       annotations: 
  23.         linkerd.io/created-by: linkerd/cli edge-21.6.1 
  24.         linkerd.io/inject: enabled 
  25.         config.linkerd.io/proxy-require-identity-inbound-ports: "4191,4143" 
  26.         config.linkerd.io/enable-gateway: "true" 
  27.       labels: 
  28.         app: linkerd-gateway 
  29.     spec: 
  30.       containers: 
  31.         - name: pause 
  32.           image: ccr.ccs.tencentyun.com/cloud-native/google-pause 
  33.       serviceAccountName: linkerd-gateway 

ccr.ccs.tencentyun.com/cloud-native/google-pause,這是筆者上傳到騰訊云的公開鏡像。

新建 kustomization.yaml:

  1. resources: 
  2. - linkerd-multicluster.yaml 
  3. patchesStrategicMerge: 
  4. - patch-linkerd-multicluster.yaml 

使用 kustomize 重新部署:

  1. kustomize build . | kubectl apply -f - 

重新查看一下:

  1. kubectl get po -n linkerd-multicluster 
  2. # linkerd-gateway-6c8dc7bb49-6tghc   2/2     Running   0          92s 

完美解決。

使用 Traefik Ingressroute 導(dǎo)出 linkerd-web 管理面板

關(guān)于 traefik v2 的部署,這里不做贅述。

使用 kustomize 對(duì) linkerd viz 部署進(jìn)行更新

我這里使用的域名是 linkerd-web.hacker-linner.com。

導(dǎo)出 yaml 檔:

  1. linkerd viz install > linkerd-viz.yaml 

打補(bǔ)丁,patch-linkerd-viz-web.yaml:

  1. apiVersion: apps/v1 
  2. kind: Deployment 
  3. metadata: 
  4.   annotations: 
  5.     linkerd.io/created-by: linkerd/helm edge-21.6.1 
  6.   labels: 
  7.     linkerd.io/extension: viz 
  8.     app.kubernetes.io/name: web 
  9.     app.kubernetes.io/part-of: Linkerd 
  10.     app.kubernetes.io/version: edge-21.6.1 
  11.     component: web 
  12.     namespace: linkerd-viz 
  13.   name: web 
  14.   namespace: linkerd-viz 
  15. spec: 
  16.   replicas: 1 
  17.   selector: 
  18.     matchLabels: 
  19.       linkerd.io/extension: viz 
  20.       component: web 
  21.       namespace: linkerd-viz 
  22.   template: 
  23.     metadata: 
  24.       annotations: 
  25.         linkerd.io/created-by: linkerd/helm edge-21.6.1 
  26.       labels: 
  27.         linkerd.io/extension: viz 
  28.         component: web 
  29.         namespace: linkerd-viz 
  30.     spec: 
  31.       nodeSelector: 
  32.         beta.kubernetes.io/os: linux 
  33.       containers: 
  34.       - args: 
  35.         - -linkerd-metrics-api-addr=metrics-api.linkerd-viz.svc.cluster.local:8085 
  36.         - -cluster-domain=cluster.local 
  37.         - -grafana-addr=grafana.linkerd-viz.svc.cluster.local:3000 
  38.         - -controller-namespace=linkerd 
  39.         - -viz-namespace=linkerd-viz 
  40.         - -log-level=info 
  41.         - -enforced-host=^(linkerd-web\.hacker-linner\.com|localhost|127\.0\.0\.1|web\.linkerd-viz\.svc\.cluster\.local|web\.linkerd-viz\.svc|\[::1\])(:\d+)?$ 
  42.         image: cr.l5d.io/linkerd/web:edge-21.6.1 
  43.         imagePullPolicy: IfNotPresent 
  44.         livenessProbe: 
  45.           httpGet: 
  46.             path: /ping 
  47.             port: 9994 
  48.           initialDelaySeconds: 10 
  49.         name: web 
  50.         ports: 
  51.         - containerPort: 8084 
  52.           name: http 
  53.         - containerPort: 9994 
  54.           name: admin-http 
  55.         readinessProbe: 
  56.           failureThreshold: 7 
  57.           httpGet: 
  58.             path: /ready 
  59.             port: 9994 
  60.         resources: 
  61.         securityContext: 
  62.           runAsUser: 2103 
  63.       serviceAccountName: web 

更新 kustomization.yaml:

  1. resources: 
  2. - linkerd-viz.yaml 
  3. - linkerd-multicluster.yaml 
  4. patchesStrategicMerge: 
  5. - patch-linkerd-viz-web.yaml 
  6. - patch-linkerd-multicluster.yaml 

重新部署

  1. kustomize build . | kubectl apply -f - 

設(shè)置 Ingressroute & Basic Auth

  1. ingressroute-viz.yaml 
  1. apiVersion: v1 
  2. kind: Secret 
  3. metadata: 
  4.   name: linkerd-authsecret 
  5.   namespace: linkerd-viz 
  6. type: Opaque 
  7. stringData: 
  8.   users: # 這里使用 htpasswd -nb 進(jìn)行設(shè)置 
  9. --- 
  10. apiVersion: traefik.containo.us/v1alpha1 
  11. kind: Middleware 
  12. metadata: 
  13.   name: linkerd-basic-auth 
  14.   namespace: linkerd-viz 
  15. spec: 
  16.   basicAuth: 
  17.     secret: linkerd-authsecret 
  18. --- 
  19. apiVersion: traefik.containo.us/v1alpha1 
  20. kind: Middleware 
  21. metadata: 
  22.   name: l5d-header-middleware 
  23.   namespace: linkerd-viz 
  24. spec: 
  25.   headers: 
  26.     customRequestHeaders: 
  27.       l5d-dst-override: "web.linkerd-viz.svc.cluster.local:8084" 
  28. --- 
  29. apiVersion: traefik.containo.us/v1alpha1 
  30. kind: IngressRoute 
  31. metadata: 
  32.   name: linkerd-web-ingress-route 
  33.   namespace: linkerd-viz 
  34. spec: 
  35.   entryPoints: 
  36.     - websecure 
  37.   tls: 
  38.     secretName: hacker-linner-cert-tls 
  39.   routes: 
  40.     - match: Host(`linkerd-web.hacker-linner.com`) 
  41.       kind: Rule 
  42.       services: 
  43.         - name: web 
  44.           port: 8084 
  45.       middlewares: 
  46.         - name: l5d-header-middleware 
  47.         - name: linkerd-basic-auth 

部署:

  1. kubectl apply -f ingressroute-viz.yaml 

 

部署 emojivoto

運(yùn)行如下命令:

  1. curl -sL https://run.linkerd.io/emojivoto.yml \ 
  2.   | kubectl apply -f 

審查部署:

  1. kubectl get po -n  emojivoto 
  2. OR 
  3. # docker pull docker.l5d.io/buoyantio/emojivoto-emoji-svc:v11 
  4. # docker pull docker.l5d.io/buoyantio/emojivoto-web:v11 
  5. # docker pull docker.l5d.io/buoyantio/emojivoto-voting-svc:v11 
  6.  
  7. emoji-6b776684f5-nnflg      1/1     Running   0          6m4s 
  8. vote-bot-64695c4dc6-jn8ln   1/1     Running   0          6m4s 
  9. voting-7778876bdb-kdvsx     1/1     Running   0          6m4s 
  10. web-6f8d774656-9dsw7        1/1     Running   0          6m4s 

設(shè)置 Ingressroute

這里是:https://emojivoto.hacker-linner.com

  1. emojivoto-ingressroute.yaml 
  1. apiVersion: traefik.containo.us/v1alpha1 
  2. kind: IngressRoute 
  3. metadata: 
  4.   name: emojivoto-web-ingress-route 
  5.   namespace: emojivoto 
  6. spec: 
  7.   entryPoints: 
  8.     - websecure 
  9.   tls: 
  10.     secretName: hacker-linner-cert-tls 
  11.   routes: 
  12.     - match: Host(`emojivoto.hacker-linner.com`) 
  13.       kind: Rule 
  14.       services: 
  15.         - name: web-svc 
  16.           port: 80 

 

Service Mesh(Linkerd) 注入

添加 Linkerd 到 emojivoto:

  1. kubectl get -n emojivoto deploy -o yaml \ 
  2.   | linkerd inject - \ 
  3.   | kubectl apply -f - 

審查一下是否一切正常:

  1. linkerd -n emojivoto check --proxy 

回到面板查看 emojivoto:

完美搞定,一切正常。

最后看一下 Grafana 面板:

Refs

  • What's a service mesh? And why do I need one?
  • https://buoyant.io/2020/10/12/what-is-a-service-mesh
  • 快速上手 Linkerd v2 Service Mesh(服務(wù)網(wǎng)格)
  • Getting Started
  • https://linkerd.io/2.10/getting-started

 

責(zé)任編輯:姜華 來源: 黑客下午茶
相關(guān)推薦

2021-10-31 20:56:25

Mesh ServiceAPI

2023-09-06 08:12:04

k8s云原生

2021-12-08 17:54:55

架構(gòu)控制平面

2022-08-21 07:17:16

LinkerdKubernetes服務(wù)網(wǎng)格

2021-06-05 10:16:55

Linkerd 服務(wù)網(wǎng)格Kubernetes

2022-11-06 21:31:11

云原生Sentinel集群模式

2023-03-01 07:42:12

HBase編排部署數(shù)據(jù)

2023-08-03 08:36:30

Service服務(wù)架構(gòu)

2021-11-04 07:49:58

K8SStatefulSetMySQL

2021-12-10 18:19:14

授權(quán) Linkerd策略

2021-12-11 22:21:00

服務(wù)配置文件

2023-02-27 07:40:00

2021-08-13 07:00:41

云原生k8sspringboot

2021-08-26 07:20:05

云原生K8sSpringboot

2022-01-02 08:42:50

架構(gòu)部署容器

2019-03-27 11:37:43

RancherK8S混合云

2023-03-06 07:19:50

2023-11-27 13:54:00

kubernetes高可用

2023-08-29 10:27:32

2023-08-04 08:19:02

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)