# @codefresh-io/kube-integration 中文文档

规范地址：https://npmcn.com/package/%40codefresh-io/kube-integration/

版本：2\.1\.19
npm 元数据更新时间：2026-11-03T07:15:39.051Z
中文译文更新时间：2026-11-10T09:25:56.772Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40codefresh-io/kube-integration
原文对照：https://npmcn.com/package/%40codefresh-io/kube-integration/?lang=original
项目主页：https://github.com/codefresh-io/kube-integration#readme
源码仓库：https://github.com/codefresh-io/kube-integration

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：633 kB，136 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：^24
- 运行依赖：22 个
- 首次发布：2017-10-24T13:16:45.612Z
- 最新版本发布：2026-11-03T07:15:38.880Z
- 近 30 天下载量：1863（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：209（近 12 个月 19 个）

## 中文简介

-   此示例将在默认名称空间中打印所有服务并创建mongo `Project` \* 获取集群证书: \* 运行“ 出口 CURRENT CONTEXT = $( kubectl 配置当前文本) + 输出 CURRENT CLUSTER = $( kubectl conf)

## 安装

```sh
npm install @codefresh-io/kube-integration
```

也可以使用：`pnpm add @codefresh-io/kube-integration`、`yarn add @codefresh-io/kube-integration`、`bun add @codefresh-io/kube-integration`

## README

# 与 K8 合并于 GKE

### 法学研究

### 示例

-   此示例将在默认名称空间中打印所有服务并创建mongo `Project` (关于以下项目的更多信息)
-   获得集群证书:
    -   运行 `export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUSTER=$(kubectl config view -o go-template="{{\$curr_context := \"$CURRENT_CONTEXT\" }}{{range .contexts}}{{if eq .name \$curr_context}}{{.context.cluster}}{{end}}{{end}}") && export KUBE_HOST=$(kubectl config view -o go-template="{{\$cluster_context := \"$CURRENT_CLUSTER\"}}{{range .clusters}}{{if eq .name \$cluster_context}}{{.cluster.server}}{{end}}{{end}}")`
    -   运行 : `export KUBE_CA_CERT=$(kubectl get secret -o go-template='{{index .data "ca.crt" }}' $(kubectl get sa default -o go-template="{{range .secrets}}{{.name}}{{end}}"))`
    -   运行 : `export KUBE_ACCOUNT_TOKEN=$(kubectl get secret -o go-template='{{index .data "token" }}' $(kubectl get sa default -o go-template="{{range .secrets}}{{.name}}{{end}}"))`
-   运行 `example.js`

### 最新的api相容版本(参见 api 使用 Node.js v10.15.3) :

-   1.15.18 联合国
-   1.6.4 (中文(简体) )

### 项目

#### 定义

项目是一组资源的一种抽象,它们共同具有实用性的目的.

目前,项目必须有一个服务

#### 结构

```
{
    selector,
    namespace,
    stauts,
    resources,
    name,
    metadata
}
```

-   选择器 - 以 Codefresh 为代表的组逻辑名称
-   命名空间 - 项目所在的命名空间
-   现况 -- -- 项目现况`{type: String("SUCCESS", "FAILED", "WARNING", "IN_PROGRESS" ,"UNKNOWN")}`(中文(简体) )
-   资源 - 确定项目的一组资源
-   元数据 -- -- 可能的话,从资源中和从重新编码的其他服务中分析和汇总额外数据(`{labels: Object, projectSelectors: Object, containers: Object[{image: String, name: String, status: Object[]}]}`) (中文(简体) ).

#### 项目 API (REST 呼叫)

```
* GET `/projects` - returns an array of all projects with minimal information about the project
* GET `/projects/:name` - return specific project with full description
* POST `/projects` - create a project
* DELETE `/projects/:name` - delete a project (deletion means, delete all the resources)
* PUT `/projects/:name` - update project resources
```

#### 工程 API( 作为对象)

```
* Evenets:
    * ['SERVICE.ADDED', 'DEPLOYMENT.ADDED', 'REPLICASET.SET.ADDED', 'POD.SET.ADDED']
* Functions:
    * setName(name: String) - Set the project name, project automatically sets his name when adding service
    * getName - return the projects name
    * getNamespace - return the projects namespace
    * analyzeStatus - traverse all the current resources and analyze the project status
    * setService(svc: Service) - set the projects service
    * setDeployment(deploy: Deployment) - set the projects deployment
    * setPods(pods: Pod || Pod[]) - set the projects pods
    * setReplicaSets(rss: Replicaset || Replicaset[]) - set the projects
    * toMinifiedJson - return minified representation of project (`{name, namespace, selector, metadata, status}`)
    * toJson - return full representation of the project
```

## 常见问题

### @codefresh-io/kube-integration 是什么？

此示例将在默认名称空间中打印所有服务并创建mongo Project \* 获取集群证书: \* 运行“ 出口 CURRENT CONTEXT = $\( kubectl 配置当前文本\) \+ 输出 CURRENT CLUSTER = $\( kubectl conf\)

### 如何安装 @codefresh-io/kube-integration？

在项目目录运行 npm install @codefresh-io/kube-integration，或使用 pnpm add / yarn add / bun add。

### @codefresh-io/kube-integration 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/codefresh-io\_\_kube-integration 是否存在。

### @codefresh-io/kube-integration 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @codefresh-io/kube-integration 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^24。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @codefresh-io/kube-integration 可以商用吗？

@codefresh-io/kube-integration 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @codefresh-io/kube-integration 的下载量有多少？

根据 npm 官方下载统计，@codefresh-io/kube-integration 在 2026/10/10 – 2026/11/08 这 30 天内被下载 1,863 次，日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @codefresh-io/kube-integration 还在维护吗？

最新版本 2\.1\.19 发布于 2026/11/03（7 天前）；至今共发布 209 个版本，其中过去 12 个月发布了 19 个；首次发布于 2017/10/24。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

