惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Scott Helme
Scott Helme
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
O
OpenAI News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
PCI Perspectives
PCI Perspectives
GbyAI
GbyAI
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
T
Troy Hunt's Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
腾讯CDC
C
Check Point Blog
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
P
Palo Alto Networks Blog
Hacker News: Ask HN
Hacker News: Ask HN
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Hacker News
The Hacker News
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
T
Tor Project blog
Martin Fowler
Martin Fowler
博客园 - 叶小钗
罗磊的独立博客
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Heimdal Security Blog
V
Vulnerabilities – Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
Latest news
Latest news
WordPress大学
WordPress大学
G
Google Developers Blog
N
Netflix TechBlog - Medium
S
Security Affairs
S
Secure Thoughts
Know Your Adversary
Know Your Adversary

Hunsh's Blog

生成个人的 Github PR List 如何选择合适的加密手段 Nginx SNI Proxy Make Go mod and Git to use specify .netrc 多架构镜像的体积优化 使用 buildkit 进行多架构构建并提取产物 如何修改镜像 layer(以 sourcemap-less grafana 为例) acme.sh 自动化 Google CA 申请证书 微信小程序嵌入任意公众号文章 k8s && bazel 项目从 go1.20 升级 go1.21 go serve http and https on same port typecho 迁移到 hexo 实现 hexo 文章和资源在同一目录下 golang mitm 遇到的问题 流式数据专用的 mine-type Golang 正向代理对于 Host 的处理 (RFC 7230) 分享 MacOS 的一些系统fix脚本(dns、sleep) prometheus rate/increase/delta/sum等函数不符合预期或出现小数的原理 [油猴脚本] USTB Everywhere 为校外访问添加访问任意网站的能力
如何优雅导入 k8s.io/kubernetes
2024-09-16 · via Hunsh's Blog

kubernetes 项目结构

主仓库一般简称为 k/k,当前使用 go work 进行项目组织。

staging/src/k8s.io/* 将由 publishing-bot 发布到 github.com/kubernetes/*(importpath k8s.io/*)。

Use of the k8s.io/kubernetes module or k8s.io/kubernetes/… packages as libraries is not supported.

k/k 的导入将不会得到支持。

问题

但是在实际使用中,某些情况依然会需要导入 k/k 的代码,比如使用 Custom Scheduler Plugin

社区讨论后,k/k 的导入不受支持的问题得到明确。

现状

如果我们需要导入 k/k,需要从 k/kgo.mod 复制所有的 replace 并且替换 version 为所需版本。这很丑而且很麻烦。
一个例子就是 kube-scheduler-simulator

解决方案

按照上方 issue 的讨论,其实只需要让 k/k,不使用 replace,而是将 k8s.io/* 版本固定到发布的版本即可。

我写了一个工具专门来完成这个事情:kksyncer

只需要一次替换即可导入 k/k

example:

1
2
3
4
5
6
7
8
// in go.mod
require (
k8s.io/kubernetes v1.29.0
)

replace (
k8s.io/kubernetes => github.com/hunshcn/kubernetes v1.29.0-mod
)

Notice: Only version >= 1.26.0 will be provided.