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

推荐订阅源

SecWiki News
SecWiki News
H
Help Net Security
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
L
LangChain Blog
K
Kaspersky official blog
I
Intezer
Martin Fowler
Martin Fowler
爱范儿
爱范儿
AWS News Blog
AWS News Blog
The Hacker News
The Hacker News
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
U
Unit 42
N
News and Events Feed by Topic
A
Arctic Wolf
G
GRAHAM CLULEY
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
F
Fortinet All Blogs
C
Cisco Blogs
美团技术团队
Vercel News
Vercel News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Hacker News: Front Page
T
Tailwind CSS Blog
I
InfoQ
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
P
Palo Alto Networks Blog
A
About on SuperTechFans
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
O
OpenAI News
博客园 - Franky
Scott Helme
Scott Helme

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.