自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

聊聊 Linkerd Service Mesh 授權(quán)策略 (Server & ServerAuthorization)

開發(fā) 前端
Server 和 ServerAuthorization 是 Linkerd 中的兩種策略資源, 用于控制對(duì) mesh 應(yīng)用程序的入站訪問。

[[439865]]

簡(jiǎn)介

Server 和 ServerAuthorization 是 Linkerd 中的兩種策略資源, 用于控制對(duì) mesh 應(yīng)用程序的入站訪問。

在 linkerd 安裝期間,policyController.defaultAllowPolicy 字段用于指定當(dāng)沒有 Server 選擇 pod 時(shí)的默認(rèn)策略。此字段可以是以下之一:

  • all-unauthenticated: 允許所有請(qǐng)求。這是默認(rèn)設(shè)置。
  • all-authenticated: 允許來自相同或不同集群(使用 multi-cluster)中的 mesh 客戶端的請(qǐng)求。
  • cluster-authenticated: 允許來自同一集群中的 mesh 客戶端的請(qǐng)求。
  • cluster-unauthenticated: 允許來自同一集群中的 mesh 和非 mesh 客戶端的請(qǐng)求。
  • deny: 所有請(qǐng)求都被拒絕。(然后應(yīng)創(chuàng)建 Policy 資源以允許服務(wù)之間的特定通信)。

可以通過在 pod spec 或其命名空間上設(shè)置注釋 config.linkerd.io/default-inbound-policy 來覆蓋此默認(rèn)值。

為 pod & port 配置 Server 后,其默認(rèn)行為是 deny 流量, 并且必須創(chuàng)建 ServerAuthorization 資源以允許 Server 上的流量。

系列

中文手冊(cè)(https://hacker-linner.com)

Server

Server 在與 server 相同的命名空間中的一組 pod 上選擇一個(gè)端口。它通常選擇 pod 上的單個(gè)端口,但在按名稱引用端口時(shí)它可能會(huì)選擇多個(gè)端口(例如 admin-http)。雖然 Server 資源類似于 Kubernetes 的 Service, 但它增加了多個(gè) Server 實(shí)例不能重疊的限制:它們不能選擇相同的 pod/port 對(duì)。 Linkerd 附帶了一個(gè) admission controller,試圖防止創(chuàng)建重疊的 server。

當(dāng)服務(wù)器選擇一個(gè)端口時(shí),默認(rèn)情況下會(huì)拒絕流量, 并且必須使用 ServerAuthorization 來授權(quán) Server 選擇的端口上的流量。

Spec

Server spec 可能包含以下頂級(jí)字段:

field value
podSelector podSelector 選擇相同命名空間中的 pod。
port 端口名稱或編號(hào)。僅考慮 pod spec 的 ports 中的端口。
proxyProtocol 為入站連接配置協(xié)議發(fā)現(xiàn)。取代 config.linkerd.io/opaque-ports annotation。必須是 unknown、HTTP/1HTTP/2、gRPC、opaque、TLS 之一。如果未設(shè)置,則默認(rèn)為 unknown

podSelector

這與 Kubernetes 中的 labelSelector 字段相同。屬于此選擇器的所有 pod 都將屬于 Server 組。podSelector 對(duì)象必須恰好包含以下字段之一:

field value
matchExpressions matchExpressions 是 label selector 要求的列表。要求是 AND 組合。
matchLabels matchLabels 是 {key,value} 對(duì)的映射。

有關(guān)更多詳細(xì)信息,請(qǐng)參閱 Kubernetes LabelSelector reference。

  • https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/label-selector/#LabelSelector

Server 示例

一個(gè) Server 選擇具有特定標(biāo)簽的 pod,使用 gRPC 作為 proxyProtocol。

  1. apiVersion: policy.linkerd.io/v1beta1 
  2. kind: Server 
  3. metadata: 
  4.   namespace: emojivoto 
  5.   name: emoji-grpc 
  6. spec: 
  7.   podSelector: 
  8.     matchLabels: 
  9.       app: emoji-svc 
  10.   port: grpc 
  11.   proxyProtocol: gRPC 

一個(gè) Server 選擇帶有 matchExpressions 的 pod,HTTP/2 作為 proxyProtocol,在端口 8080 上。

  1. apiVersion: policy.linkerd.io/v1beta1 
  2. kind: Server 
  3. metadata: 
  4.   namespace: emojivoto 
  5.   name: backend-services 
  6. spec: 
  7.   podSelector: 
  8.     matchExpressions: 
  9.     - {key: app, operator: Invalues: [voting-svc, emoji-svc]} 
  10.     - {key: environment, operator: NotIn, values: [dev]} 
  11.   port: 8080 
  12.   proxyProtocol: "HTTP/2" 

ServerAuthorization

ServerAuthorization 提供了一種向一個(gè)或多個(gè) Server 授權(quán)流量的方法。

Spec

ServerAuthorization spec 必須包含以下頂級(jí)字段:

field value
client client 描述授權(quán)訪問 server 的客戶端。
server server 在此授權(quán)適用的同一命名空間中標(biāo)識(shí) Servers。

Server

Server 對(duì)象必須包含以下字段之一:

field value
name 按名稱引用 Server 實(shí)例。
selector selector 選擇在同一命名空間中應(yīng)用此授權(quán)的 server

selector

這與 Kubernetes 中的 labelSelector 字段相同。屬于此選擇器的所有服務(wù)器都將應(yīng)用此授權(quán)。 selector 對(duì)象必須恰好包含以下字段之一:

field value
matchExpressions matchExpressions 是標(biāo)簽選擇器要求的列表。要求是 AND 組合。
matchLabels matchLabels 是 {key,value} 對(duì)的映射。

client

client 對(duì)象必須包含以下字段之一:

field value
meshTLS meshTLS 用于授權(quán) mesh 客戶端訪問服務(wù)器
unauthenticated 授權(quán)未經(jīng)身份驗(yàn)證的客戶端訪問服務(wù)器的布爾值。

或者,它還可以包含 networks 字段:

field value
networks 限制此授權(quán)適用的客戶端 IP 地址。如果未設(shè)置,服務(wù)器將選擇默認(rèn)值(通常為所有 IP 或集群的 pod 網(wǎng)絡(luò))。

meshTLS

meshTLS 對(duì)象必須恰好包含以下字段之一:

field value
unauthenticatedTLS 一個(gè)布爾值,表示通信不需要客戶端身份。這對(duì)于身份控制器非常重要,它必須終止來自尚未擁有證書的客戶端的 TLS 連接。
identities 授權(quán)的代理身份字符串列表(通過 MTLS 提供)。* 前綴可用于匹配域中的所有身份。* 標(biāo)識(shí)字符串表示所有身份驗(yàn)證客戶端都已授權(quán)。
serviceAccounts 授權(quán)客戶端 serviceAccount 的列表(通過 MTLS 提供)。

serviceAccount

serviceAccount 字段包含以下頂級(jí)字段:

field value
name ServiceAccount 的名稱。
namespace ServiceAccount 的命名空間。如果未設(shè)置,則使用授權(quán)的命名空間。

ServerAuthorization 示例

一個(gè) ServerAuthorization 允許 mesh 客戶端使用 *.emojivoto.serviceaccount.identity.linkerd.cluster.local 代理身份, 即 emojivoto 命名空間中的所有服務(wù)帳戶。

  1. apiVersion: policy.linkerd.io/v1beta1 
  2. kind: ServerAuthorization 
  3. metadata: 
  4.   namespace: emojivoto 
  5.   name: emoji-grpc 
  6. spec: 
  7.   # Allow all authenticated clients to access the (read-only) emoji service. 
  8.   server: 
  9.     selector: 
  10.       matchLabels: 
  11.         app: emoji-svc 
  12.   client: 
  13.     meshTLS: 
  14.       identities: 
  15.         - "*.emojivoto.serviceaccount.identity.linkerd.cluster.local" 

一個(gè)允許任何未經(jīng)身份驗(yàn)證的客戶端的 ServerAuthorization。

  1. apiVersion: policy.linkerd.io/v1beta1 
  2. kind: ServerAuthorization 
  3. metadata: 
  4.   namespace: emojivoto 
  5.   name: web-public 
  6. spec: 
  7.   server: 
  8.     name: web-http 
  9.   # Allow all clients to access the web HTTP port without regard for 
  10.   # authentication. If unauthenticated connections are permitted, there is no 
  11.   # need to describe authenticated clients. 
  12.   client: 
  13.     unauthenticated: true 
  14.     networks: 
  15.       - cidr: 0.0.0.0/0 
  16.       - cidr: ::/0 

一個(gè)允許具有特定服務(wù)帳戶的 mesh 客戶端的 ServerAuthorization。

  1. apiVersion: policy.linkerd.io/v1beta1 
  2. kind: ServerAuthorization 
  3. metadata: 
  4.   namespace: emojivoto 
  5.   name: prom-prometheus 
  6. spec: 
  7.   server: 
  8.     name: prom 
  9.   client: 
  10.     meshTLS: 
  11.       serviceAccounts: 
  12.         - namespace: linkerd-viz 
  13.           name: prometheus 

 

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

2021-12-08 17:54:55

架構(gòu)控制平面

2022-08-21 07:17:16

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

2021-12-11 22:21:00

服務(wù)配置文件

2021-10-31 20:56:25

Mesh ServiceAPI

2021-06-05 10:16:55

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

2021-07-21 05:23:06

Linkerd Emoji.voto服務(wù)網(wǎng)格

2021-10-03 23:45:36

gRPC授權(quán)策略

2014-07-28 14:46:40

Service

2021-06-12 07:38:21

Linkerd 2.Service Mes微服務(wù)

2021-06-10 06:24:41

K8S Service Mesemojivoto

2021-11-09 23:54:19

開發(fā)SMI Linkerd

2021-11-08 09:11:17

云計(jì)算Service Mes云應(yīng)用

2020-03-04 09:27:13

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

2022-07-15 09:20:17

性能優(yōu)化方案

2021-02-22 17:00:31

Service Mes微服務(wù)開發(fā)

2022-11-07 08:01:18

Git分支管理

2024-10-06 12:56:36

Golang策略設(shè)計(jì)模式

2021-06-30 13:26:07

Service MesHTTP協(xié)議 Oitsi

2020-07-28 08:20:06

Service Mes容器化云原生

2022-01-27 22:33:35

配置容器穩(wěn)定性
點(diǎn)贊
收藏

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