<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>保护 Dapr 部署 on Dapr 文档库</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/security/</link><description>Recent content in 保护 Dapr 部署 on Dapr 文档库</description><generator>Hugo</generator><language>zh-hans</language><atom:link href="https://v1-18.docs.dapr.io/zh-hans/operations/security/index.xml" rel="self" type="application/rss+xml"/><item><title>设置和配置 mTLS 证书</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/security/mtls/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/operations/security/mtls/</guid><description>&lt;p>Dapr 支持通过 Dapr 控制平面的 Sentry 服务对 Dapr 实例之间的通信进行传输加密。Sentry 服务是一个中央证书颁发机构 (CA)。&lt;/p>
&lt;p>Dapr 允许操作员和开发人员使用自己的证书，或者让 Dapr 自动创建并保存自签名的根证书和颁发者证书。&lt;/p>
&lt;p>有关 mTLS 的详细信息，请阅读&lt;a href="https://v1-18.docs.dapr.io/zh-hans/concepts/security-concept/">安全概念部分&lt;/a>。&lt;/p>
&lt;p>如果没有提供自定义证书，Dapr 会自动创建并保存有效期为一年的自签名证书。
在 Kubernetes 中，证书会保存到 Dapr 系统 pod 所在命名空间的 secret 中，仅对它们可访问。
在自托管模式中，证书会保存到磁盘。&lt;/p>
&lt;h2 id="控制平面-sentry-服务配置">控制平面 Sentry 服务配置&lt;/h2>
&lt;p>mTLS 设置位于 Dapr 控制平面配置文件中。例如，当您将 Dapr 控制平面部署到 Kubernetes 时，此配置文件会自动创建，然后您可以编辑它。以下文件显示了在 &lt;code>daprsystem&lt;/code> 命名空间中部署的配置资源中可用的 mTLS 设置：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">dapr.io/v1alpha1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Configuration&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">daprsystem&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">namespace&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">default&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">mtls&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">enabled&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">workloadCertTTL&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;24h&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">allowedClockSkew&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;15m&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>此文件显示了默认的 &lt;code>daprsystem&lt;/code> 配置设置。下面的示例向您展示如何在 Kubernetes 和自托管模式下更改和应用此配置到控制平面 Sentry 服务。&lt;/p></description></item><item><title>使用 OAuth 配置端点授权</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/security/oauth/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/operations/security/oauth/</guid><description>&lt;p>Dapr 的 OAuth 2.0 中间件允许您在 Dapr 端点上为 Web API 启用 OAuth 授权，支持 &lt;a href="https://tools.ietf.org/html/rfc6749#section-4.1">授权码模式&lt;/a>。您还可以将授权令牌注入到端点 API 中，这些令牌可用于通过 &lt;a href="https://tools.ietf.org/html/rfc6749#section-4.4">客户端凭证模式&lt;/a>对 API 调用的外部 API 进行授权。启用中间件后，所有通过 Dapr 的方法调用在传递给用户代码之前都需要进行授权。&lt;/p>
&lt;p>这两种模式的主要区别在于，&lt;code>授权码模式&lt;/code>需要用户交互并授权用户，而&lt;code>客户端凭证模式&lt;/code>不需要用户交互，授权的是服务或应用程序。&lt;/p>
&lt;h2 id="在授权服务器上注册您的应用程序">在授权服务器上注册您的应用程序&lt;/h2>
&lt;p>不同的授权服务器提供不同的应用程序注册体验。以下是一些示例：&lt;/p>
&lt;!-- IGNORE_LINKS -->
&lt;ul>
&lt;li>&lt;a href="https://docs.microsoft.com/azure/active-directory/develop/v1-protocols-oauth-code">Microsoft Entra ID&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://developers.facebook.com/apps">Facebook&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://dev.fitbit.com/build/reference/web-api/oauth2/">Fitbit&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/">GitHub&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://console.developers.google.com/apis/credentials/consen">Google APIs&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://api.slack.com/docs/oauth">Slack&lt;/a>&lt;/li>
&lt;li>&lt;a href="http://apps.twitter.com/">Twitter&lt;/a>&lt;/li>
&lt;/ul>
&lt;!-- END_IGNORE -->
&lt;p>要配置 Dapr OAuth 中间件，您需要收集以下信息：&lt;/p>
&lt;ul>
&lt;li>客户端 ID (参见 &lt;a href="https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/">这里&lt;/a>)&lt;/li>
&lt;li>客户端密钥 (参见 &lt;a href="https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/">这里&lt;/a>)&lt;/li>
&lt;li>范围 (参见 &lt;a href="https://oauth.net/2/scope/">这里&lt;/a>)&lt;/li>
&lt;li>授权 URL&lt;/li>
&lt;li>令牌 URL&lt;/li>
&lt;/ul>
&lt;p>一些流行的授权服务器的授权/令牌 URL：&lt;/p>
&lt;!-- IGNORE_LINKS -->
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>服务器&lt;/th>
 &lt;th>授权 URL&lt;/th>
 &lt;th>令牌 URL&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Microsoft Entra ID&lt;/td>
 &lt;td>&lt;a href="https://login.microsoftonline.com/%7Btenant%7D/oauth2/authorize">https://login.microsoftonline.com/{tenant}/oauth2/authorize&lt;/a>&lt;/td>
 &lt;td>&lt;a href="https://login.microsoftonline.com/%7Btenant%7D/oauth2/token">https://login.microsoftonline.com/{tenant}/oauth2/token&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>GitHub&lt;/td>
 &lt;td>&lt;a href="https://github.com/login/oauth/authorize">https://github.com/login/oauth/authorize&lt;/a>&lt;/td>
 &lt;td>&lt;a href="https://github.com/login/oauth/access_token">https://github.com/login/oauth/access_token&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Google&lt;/td>
 &lt;td>&lt;a href="https://accounts.google.com/o/oauth2/v2/auth">https://accounts.google.com/o/oauth2/v2/auth&lt;/a>&lt;/td>
 &lt;td>&lt;a href="https://accounts.google.com/o/oauth2/token">https://accounts.google.com/o/oauth2/token&lt;/a> &lt;a href="https://www.googleapis.com/oauth2/v4/token">https://www.googleapis.com/oauth2/v4/token&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Twitter&lt;/td>
 &lt;td>&lt;a href="https://api.twitter.com/oauth/authorize">https://api.twitter.com/oauth/authorize&lt;/a>&lt;/td>
 &lt;td>&lt;a href="https://api.twitter.com/oauth2/token">https://api.twitter.com/oauth2/token&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;!-- END_IGNORE -->
&lt;h2 id="定义中间件组件">定义中间件组件&lt;/h2>
&lt;h3 id="定义授权码模式组件">定义授权码模式组件&lt;/h3>
&lt;p>OAuth 中间件（授权码模式）由以下组件定义：&lt;/p></description></item><item><title>在 Dapr 中启用 API 令牌认证</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/security/api-token/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/operations/security/api-token/</guid><description>&lt;p>默认情况下，Dapr 通过网络边界限制对其公共 API 的访问。如果您计划在该边界之外公开 Dapr API，或者您的部署需要额外的安全级别，请考虑为 Dapr API 启用令牌认证。这意味着 Dapr 将要求每个传入的 gRPC 和 HTTP 请求在通过之前包含认证令牌。&lt;/p>
&lt;h2 id="创建令牌">创建令牌&lt;/h2>
&lt;p>Dapr 通过共享令牌进行 API 认证。您可以自由定义要使用的 API 令牌。&lt;/p>
&lt;p>虽然 Dapr 对共享令牌的格式没有具体要求，但一个好的做法是生成一个随机字节序列并将其编码为 Base64。例如，以下命令生成一个随机的 32 字节密钥并将其编码为 Base64：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>openssl rand &lt;span style="color:#0000cf;font-weight:bold">16&lt;/span> &lt;span style="color:#000;font-weight:bold">|&lt;/span> base64
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="在-dapr-中配置-api-令牌认证">在 Dapr 中配置 API 令牌认证&lt;/h2>
&lt;p>对于 Kubernetes 或自托管 Dapr 部署，令牌认证配置略有不同：&lt;/p>
&lt;h3 id="自托管">自托管&lt;/h3>
&lt;p>在自托管场景中，Dapr 会检查 &lt;code>DAPR_API_TOKEN&lt;/code> 环境变量是否存在。如果在 &lt;code>daprd&lt;/code> 进程启动时设置了该环境变量，Dapr 将对其公共 API 强制执行认证：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87">export&lt;/span> &lt;span style="color:#000">DAPR_API_TOKEN&lt;/span>&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>&amp;lt;token&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>要更新配置的令牌，请将 &lt;code>DAPR_API_TOKEN&lt;/code> 环境变量更新为新值并重新启动 &lt;code>daprd&lt;/code> 进程。&lt;/p>
&lt;h3 id="kubernetes">Kubernetes&lt;/h3>
&lt;p>在 Kubernetes 部署中，Dapr 使用 Kubernetes secret 存储来保存共享令牌。要配置 Dapr API 认证，首先创建一个新的 secret：&lt;/p></description></item><item><title>使用令牌认证对Dapr请求进行身份验证</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/security/app-api-token/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/operations/security/app-api-token/</guid><description>&lt;p>对于一些构建块，例如pubsub、service-invocation和输入bindings，Dapr与应用程序通过HTTP或gRPC进行通信。
为了让应用程序能够验证来自Dapr sidecar的请求，您可以配置Dapr在HTTP请求的头部或gRPC请求的元数据中发送一个API令牌。&lt;/p>
&lt;h2 id="创建令牌">创建令牌&lt;/h2>
&lt;p>Dapr使用共享令牌进行API认证。您可以自由定义API令牌。&lt;/p>
&lt;p>虽然Dapr对共享令牌没有强制格式，但一个好的做法是生成一个随机字节序列并将其编码为Base64。例如，这个命令生成一个随机的32字节密钥并将其编码为Base64：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>openssl rand &lt;span style="color:#0000cf;font-weight:bold">16&lt;/span> &lt;span style="color:#000;font-weight:bold">|&lt;/span> base64
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="在dapr中配置应用api令牌认证">在Dapr中配置应用API令牌认证&lt;/h2>
&lt;p>令牌认证配置在Kubernetes或selfhosted Dapr部署中略有不同：&lt;/p>
&lt;h3 id="selfhosted">Selfhosted&lt;/h3>
&lt;p>在selfhosted场景中，Dapr会检查&lt;code>APP_API_TOKEN&lt;/code>环境变量是否存在。如果在&lt;code>daprd&lt;/code>进程启动时设置了该环境变量，Dapr在调用应用程序时会包含该令牌：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87">export&lt;/span> &lt;span style="color:#000">APP_API_TOKEN&lt;/span>&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>&amp;lt;token&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>要更新配置的令牌，修改&lt;code>APP_API_TOKEN&lt;/code>环境变量为新值并重启&lt;code>daprd&lt;/code>进程。&lt;/p>
&lt;h3 id="kubernetes">Kubernetes&lt;/h3>
&lt;p>在Kubernetes部署中，Dapr使用Kubernetes secrets存储来保存共享令牌。首先，创建一个新的secret：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>kubectl create secret generic app-api-token --from-literal&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>&lt;span style="color:#000">token&lt;/span>&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>&amp;lt;token&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>注意，您需要在每个希望启用应用令牌认证的命名空间中创建上述secret&lt;/p>&lt;/blockquote>
&lt;p>要指示Dapr在向应用程序发送请求时使用secret中的令牌，请在您的Deployment模板规范中添加一个注解：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">annotations&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dapr.io/enabled&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dapr.io/app-token-secret&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;app-api-token&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># Kubernetes secret的名称&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>部署时，Dapr Sidecar Injector会自动创建一个secret引用并将实际值注入到&lt;code>APP_API_TOKEN&lt;/code>环境变量中。&lt;/p>
&lt;h2 id="轮换令牌">轮换令牌&lt;/h2>
&lt;h3 id="selfhosted-1">Selfhosted&lt;/h3>
&lt;p>要在selfhosted中更新配置的令牌，修改&lt;code>APP_API_TOKEN&lt;/code>环境变量为新值并重启&lt;code>daprd&lt;/code>进程。&lt;/p>
&lt;h3 id="kubernetes-1">Kubernetes&lt;/h3>
&lt;p>要在Kubernetes中更新配置的令牌，修改之前创建的secret中的新令牌在每个命名空间中。您可以使用&lt;code>kubectl patch&lt;/code>命令来完成此操作，但更简单的方法是使用清单更新这些：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">v1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Secret&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">app-api-token&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">type&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Opaque&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">data&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">token&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">&amp;lt;your-new-token&amp;gt;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>然后将其应用到每个命名空间：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>kubectl apply --file token-secret.yaml --namespace &amp;lt;namespace-name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>要让Dapr开始使用新令牌，请触发对每个部署的滚动升级：&lt;/p></description></item></channel></rss>