跳到正文
Skillpedia
部署与云(DevOps)17k · #10768

kubesphere-devops-credentials

它能做什么

这个技能帮助 AI 智能体为 KubeSphere DevOps 流水线设置凭据。适合需要让流水线安全访问 Git 仓库、集群或外部服务的运维人员。

适用场景

  • ✓当你需要使用 SSH 或用户名和密码,将 Git 仓库添加到 DevOps 项目时。
  • ✓当流水线需要 kubeconfig 或 API 令牌来访问集群或服务时。
  • ✓当凭据需要迁移到另一个 DevOps 项目,或某个凭据无法使用时。

技能链接

https://github.com/kubesphere/kubesphere/blob/master/skills/kubesphere-devops-credentials/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/kubesphere/kubesphere/blob/master/skills/kubesphere-devops-credentials/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我用 SSH 密钥把我们的私有 GitHub 仓库添加到 DevOps 项目中。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会说明适合的凭据类型,然后将其创建为带有 KubeSphere 所需标签的 Kubernetes 密钥。同步到 Jenkins 之后,流水线就可以使用它了。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

KubeSphere DevOps Credentials

Overview

Credentials in KubeSphere DevOps are Kubernetes Secrets with specific labels and annotations. They are synced to Jenkins for use in pipelines. Supported types include SSH keys, username/password, and secret tokens.

When to Use

  • Creating credentials for Git repositories
  • Setting up deployment credentials (kubeconfig, registry)
  • Managing API tokens for external services
  • Troubleshooting credential access issues
  • Migrating credentials between DevOps projects

Credential Types

Type Use Case Secret Key
SSH Git repositories username, privatekey
Basic Username/password username, password
Secret API tokens, secrets secret
Kubeconfig Kubernetes clusters kubeconfig (v1.1.x only)
SSH Username/Pass Git with user/pass username, password
String Generic text/tokens secret

Resource Structure

Credentials are stored as Kubernetes Secrets with DevOps labels:

apiVersion: v1
kind: Secret
metadata:
  name: my-credential
  namespace: project-xxx  # DevOps project namespace
  labels:
    devops.kubesphere.io/credential: "true"
  annotations:
    credential.devops.kubesphere.io/syncstatus: successful
    credential.devops.kubesphere.io/type: ssh|basic-auth|secret-text
stringData:
  username: git-user
  privatekey: |
    -----BEGIN OPENSSH PRIVATE KEY-----
    ...
    -----END OPENSSH PRIVATE KEY-----
type: credential.devops.kubesphere.io/ssh  # CRITICAL: Must use credential.devops.kubesphere.io/* type, NOT Opaque!

⚠️ CRITICAL: Secret Type Must Be credential.devops.kubesphere.io/*

The type field must be one of:

  • credential.devops.kubesphere.io/basic-auth
  • credential.devops.kubesphere.io/ssh-auth
  • credential.devops.kubesphere.io/secret-text
  • credential.devops.kubesphere.io/kubeconfig

Using type: Opaque will result in:

  • Credential sync status stuck at "pending"
  • Jenkins cannot find the credential
  • Pipeline builds fail with "CredentialId could not be found"

Controller Logic: The credential controller only watches secrets with types starting with credential.devops.kubesphere.io/ (see devopscredential_controller.go line 102). Secrets with type: Opaque are completely ignored.

API Endpoints

Operation Method Endpoint
List Credentials GET /kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials
Create Credential POST /kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials
Get Credential GET /kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials/{credential}
Update Credential PUT /kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials/{credential}
Delete Credential DELETE /kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials/{credential}
Get Usage GET /kapis/devops.kubesphere.io/v1alpha2/namespaces/{devops}/credentials/{credential}/usage

Common Operations

List Credentials

curl "https://kubesphere-api/kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials" \
  -H "Authorization: Bearer $TOKEN"

Create SSH Credential

curl -X POST "https://kubesphere-api/kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "apiVersion": "v1",
    "kind": "Secret",
    "metadata": {
      "name": "github-ssh-key",
      "annotations": {
        "credential.devops.kubesphere.io/type": "ssh"
      }
    },
    "stringData": {
      "username": "git",
      "privatekey": "-----BEGIN OPENSSH PRIVATE KEY-----\n...\n-----END OPENSSH PRIVATE KEY-----"
    },
    "type": "credential.devops.kubesphere.io/ssh-auth"
  }'

Create Basic Auth Credential

curl -X POST "https://kubesphere-api/kapis/devops.kubesphere.io/v1alpha3/namespaces/{devops}/credentials" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "apiVersion": "v1",
    "kind": "Secret",
    "metadata": {
      "name": "docker-registry",
      "annotations": {
        "credential.devops.kubesphere.io/type": "basic-auth"
      }
    },
    "stringData": {
      "username": "docker-user",
      "password": "docker-password"
    },
    "type": "credential.devops.kubesphere.io/basic-auth"
  }'

常见问题

支持哪些凭据类型?

该技能列出了 SSH、用户名和密码、密钥令牌、kubeconfig 和通用文本。

凭据存放在哪里?

它们以带有 DevOps 标签的 Kubernetes 密钥形式存储,并同步到 Jenkins。

智能体能检查凭据为什么失败吗?

可以。该技能涵盖排查访问问题和同步状态。

详情

作者的原始描述

Use when managing credentials in KubeSphere DevOps, including repository credentials, kubeconfig, and API tokens

repo: kubesphere/kubesphere

热度

GitHub 星标
17k
排名
#10768
许可证
—
更新时间
2026/7/14

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能