Secure workstation onboarding

Yuma 内部服务与 K3s 集群接入

通过受控 CLI 加载集群的最小权限 kubeconfig。DevOps Center 和 CLI 的公共入口使用公共 CA,无需先安装 Yuma Root CA;仅访问仍使用内部 PKI 的兼容服务时才需要安装。

开始之前 安装系统根证书和写入 kubeconfig 都会修改本机配置。请先检查下载内容与证书 SHA-256 指纹;执行 --apply 前确认 target 和 access 符合你的授权范围。

证书身份

名称
Yuma Intranet Root CA
版本
20260909-cli-0.4.9
SHA-256
13:D2:F1:79:47:C9:61:DC:C9:99:3D:A0:5C:26:83:C0:CA:95:D9:E2:6E:21:4F:D4:E2:9C:81:2A:72:33:D3:D7
用途
访问 *.yuma.intra 内部 HTTPS 服务

安装 Root CA

仅访问使用 Yuma 内部 PKI 的 HTTPS 服务时执行。只安装 Root 公共证书,不安装 Issuing CA 或任何私钥。Root CA 用于验证服务端证书,不能替代 Kubernetes Token 认证或延长其有效期。

Linux

curl -fsSLO https://trust.yuma.technology/install/linux.sh
less linux.sh
sudo sh linux.sh

macOS

curl -fsSLO https://trust.yuma.technology/install/macos.sh
less macos.sh
sudo sh macos.sh
export SSL_CERT_FILE='/Library/Application Support/Yuma/trust/ca-bundle.pem'

Homebrew、Conda 或 Python.org Python 通常不读取 System Keychain。请按安装器输出,在当前 shell 设置 SSL_CERT_FILE

Windows

以管理员身份启动 PowerShell,下载并检查脚本后执行:

Invoke-WebRequest -UseBasicParsing `
  -Uri "https://trust.yuma.technology/install/windows.ps1" `
  -OutFile "$env:TEMP\install-yuma-ca.ps1"
notepad "$env:TEMP\install-yuma-ca.ps1"
Get-ExecutionPolicy -List
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
& "$env:TEMP\install-yuma-ca.ps1"

Scope Process 只对当前 PowerShell 进程生效。不要修改 CurrentUserLocalMachine 的长期 Execution Policy;如策略由组织 Group Policy 强制,请联系管理员通过 Intune/GPO 下发。

K3s 集群访问配置

以下流程从 stable target catalog 加载明确声明的 developer identity。不要手工拼接凭据,也不要用环境名代替完整的 cluster target。

1

安装集群 Target CLI

curl -fsSL https://center.devops.yuma.technology/install/cli/yuma-cluster-target-ops-cli.sh | sh
yuma-cluster-target-ops-cli --version
2

同步 stable catalog 并查看可用 Target

yuma-cluster-target-ops-cli targets sync --channel stable
yuma-cluster-target-ops-cli targets list

列表会展示 metadata 来源,以及 adminlive-deployreadonly 三种 identity 的显式状态。只有 catalog 声明可用的 access 才能继续同步。

3

原子加载三套 live-deploy kubeconfig

yuma-cluster-target-ops-cli sync-kubeconfig-set \
  --access live-deploy \
  --target hydros-cluster-testing \
  --target hydros-cluster-staging \
  --target hydros-cluster-production \
  --allow-production-deploy \
  --apply
Production 权限提示 --allow-production-deploy 是 production live-deploy 的显式安全确认,不会绕过 target catalog 的权限声明。若 production 只发布了 readonly,此命令会安全失败;请改为单独同步 readonly,或联系 operator 完成正式授权与发布。

批量命令会先预检全部 target,再备份并原子替换默认的 ~/.kube/config。任一 target 失败时不会提交本地变更。

Production 使用 readonly 时的最小权限方案
yuma-cluster-target-ops-cli sync-kubeconfig-set \
  --access live-deploy \
  --target hydros-cluster-testing \
  --target hydros-cluster-staging \
  --apply

yuma-cluster-target-ops-cli sync-kubeconfig \
  hydros-cluster-production \
  --access readonly \
  --apply

验证连接

先确认 context 已写入,再用每个 identity 访问目标 namespace。不要仅凭能够访问另一个集群的入口判断当前 target 成功。

kubectl config get-contexts

kubectl --context hydros-cluster-testing-live-deploy -n hydros get pods
kubectl --context hydros-cluster-staging-live-deploy -n hydros get pods
kubectl --context hydros-cluster-production-live-deploy -n hydros get pods
  • context 名称、cluster target 和 access 后缀一致。
  • 命令仅访问预期集群与 namespace。
  • production 的实际 access 与 target catalog 声明一致。

live-deploy / readonly 凭据过期

以下错误表示 Kubernetes 没有接受当前 identity,常见原因是 kubeconfig 内的短期 JWT 已过期,不能按 RBAC 问题处理:

the server has asked for the client to provide credentials
You must be logged in to the server

开发者:先预检,再重新同步同一 identity

yuma-cluster-target-ops-cli sync-kubeconfig \
  hydros-cluster-staging \
  --target-source catalog \
  --access live-deploy

# 仅当预检中的 credential expiry 和 API authentication 均为 ok 时写入
yuma-cluster-target-ops-cli sync-kubeconfig \
  hydros-cluster-staging \
  --target-source catalog \
  --access live-deploy \
  --apply

kubectl --context hydros-cluster-staging-live-deploy auth whoami
kubectl --context hydros-cluster-staging-live-deploy \
  -n hydros get deployments

请把示例 target 和 access 替换为实际授权。live-deploy 的常规授权范围是业务 namespace;不要用无权读取的 hydros-system 资源判断凭据是否有效。

production live-deploy 的预检与同步还必须显式传 --allow-production-deploy

yuma-cluster-target-ops-cli sync-kubeconfig \
  hydros-cluster-production \
  --target-source catalog \
  --access live-deploy \
  --allow-production-deploy
同步成功但认证仍失败 这通常表示 stable kubeconfig artifact 本身已经过期或被 API Server 拒绝。请联系 cluster operator 重新签发并发布该 target/access 的 stable developer kubeconfig;重新发布后开发者再次执行上述同步。不得复制或回退使用 admin kubeconfig。

Operator:重新签发并发布 stable

自 CLI 0.4.9 起,live-deploy / readonly 的默认有效期为 90 天(2160h),适用于 candidate / stable,不是三个自然月。先确认 target、access 和现有 RBAC。下面是 production live-deploy 故障恢复示例;production 访问仍需显式授权:

yuma-cluster-target-ops-cli kubeconfig publish-developer \
  hydros-cluster-production \
  --target-source deployment-local \
  --kube-context hydros-cluster-production-admin \
  --access-mode live-deploy \
  --allow-production-deploy \
  --channel stable \
  --token-duration 2160h \
  --skip-rbac \
  --artifact-center-url <artifact-center-url> \
  --apply \
  --json

--skip-rbac 只适用于现有 ServiceAccount 和 RBAC 绑定已验证、此次仅轮换凭据的场景。非默认命名必须显式传 --service-account <existing-service-account>。示例显式传入 --token-duration 2160h 以兼容旧 CLI。API Server 可能缩短请求期限,以发布后 consumer 预检输出的实际 credential expires at 为准。升级 CLI 不会延长已有凭据,必须重新签发、发布并同步同一 access。

发布后验证与轮换

yuma-cluster-target-ops-cli sync-kubeconfig \
  hydros-cluster-production \
  --target-source catalog \
  --access live-deploy \
  --allow-production-deploy \
  --json
  • 必须看到新的 version/artifact ID、credential expiry: okAPI authentication: ok,再通知开发者执行带 --apply 的同步。
  • target catalog 的 available 只表示存在 stable artifact 引用,不证明其中 JWT 尚未过期。
  • operator 应在到期前 7 天、3 天和 1 天巡检并告警,在到期前完成新 stable 制品发布和 consumer 验证。

如何区分认证与 RBAC

  • Unauthorizedprovide credentialsYou must be logged in:先处理凭据同步/重发。
  • Forbidden:身份已经通过认证,但目标 namespace 的 RBAC 不足,请 operator 检查对应 ServiceAccount 和 RoleBinding。

Windows 与 WSL

Windows 原生终端与 WSL 使用不同的 home、Root CA trust store 和 kubeconfig。在哪个环境执行 kubectl,就必须在哪个环境安装信任并同步 kubeconfig;只更新其中一侧不会自动更新另一侧。

常见问题

TLS 或证书校验失败

重新核对本页指纹,并确认实际运行 CLI 的 Python、Conda、Java、WSL、容器或 CI runner 已加载同一个 Root CA。不要使用 curl -k 或关闭 TLS verify。

Target 不存在或 metadata 过期

重新运行 targets sync --channel stabletargets list。如果 target 仍未出现,请联系 operator 检查 stable catalog 发布状态。

缺少 kubeconfig artifact

目标 access 尚未发布,或 target 明确声明为不可用。不得回退使用 admin 凭据或手工复制 kubeconfig。

kubectl: command not found

先按团队工具链基线安装 kubectl,再执行连接验证。