Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pod mutating webhook to auto inject the pod network resources #4179

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

cyclinder
Copy link
Collaborator

@cyclinder cyclinder commented Oct 17, 2024

Thanks for contributing!

Notice:

What issue(s) does this PR fix:

Fixes #4177

Special notes for your reviewer:

@cyclinder cyclinder marked this pull request as draft October 17, 2024 11:02
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 54.96183% with 118 lines in your changes missing coverage. Please review.

Project coverage is 79.21%. Comparing base (b63d30e) to head (c997b6c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/podmanager/utils.go 66.97% 65 Missing and 6 partials ⚠️
pkg/podmanager/pod_webhook.go 0.00% 47 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4179      +/-   ##
==========================================
- Coverage   80.34%   79.21%   -1.13%     
==========================================
  Files          51       52       +1     
  Lines        5637     5899     +262     
==========================================
+ Hits         4529     4673     +144     
- Misses        941     1053     +112     
- Partials      167      173       +6     
Flag Coverage Δ
unittests 79.21% <54.96%> (-1.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/podmanager/pod_manager.go 94.38% <ø> (ø)
pkg/podmanager/pod_webhook.go 0.00% <0.00%> (ø)
pkg/podmanager/utils.go 65.98% <66.97%> (+7.36%) ⬆️

@cyclinder cyclinder marked this pull request as ready for review October 18, 2024 11:31
@cyclinder cyclinder force-pushed the webhook/auto_smc branch 2 times, most recently from f0c5d90 to 5effe3c Compare October 21, 2024 07:30
@cyclinder cyclinder temporarily deployed to release-base-images October 21, 2024 07:30 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 21, 2024 08:56 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 21, 2024 12:43 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 21, 2024 12:44 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 21, 2024 14:37 — with GitHub Actions Inactive
@cyclinder cyclinder added the release/feature-new release note for new feature label Oct 22, 2024
@@ -214,7 +214,9 @@

3. 创建 CNI 配置和对应的 ippool 资源
Copy link
Collaborator

@weizhoublue weizhoublue Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 不建议 修改 保底方案,而是开一个小节 单独说明 新的方式
2 没看到 helm 安装 要开 开关

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没看到 webhook 的 namespace 级别的 安装 或者 配置选项 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

希望把过滤 namespace 列表作为可配选项么?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

肯定是需要的,支持 白名单或黑名单,通过 helm value 和 configmap 暴露,可调

@@ -51,7 +51,8 @@ const (
)

const (
AnnotationPre = "ipam.spidernet.io"
AnnotationPre = "ipam.spidernet.io"
Copy link
Collaborator

@weizhoublue weizhoublue Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key prefix 是否定义太多了,或者尽量复用
spidernet.io/...... 就够了, 前缀是一个组织名 ,一个后缀足以区分出不同的功能

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只是觉得 ipam.spidernet.io 不太恰当,就 spidernet.io 比较合适

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实 spidernet.io/**** 就完事了,基于目前已经发出去的版本,可以只保留两个

ipam.spidernet.io/***
cni.spidernet.io/***

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以前老的保留,以后新的都统一为:spidernet.io


// webhook
PodMutatingWebhookName = "pods.spiderpool.spidernet.io"
AnnoMutatingPodWebhook = AnnotationSpinderPre + "/multus-config-label"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multus-config-label -》 resource-inject-key

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

---
apiVersion: spiderpool.spidernet.io/v2beta1
kind: SpiderMultusConfig
metadata:
name: gpu1-macvlan
namespace: spiderpool
labels:
shared-rdma-gpu: ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 label 不应该是这么打的。从其它项目的实践来说, 它应该是

pod 打
netresources.spidernet.io/resource-inject-key: myKeyName

SpiderMultusConfig 打
netresources.spidernet.io/resource-inject-key: myKeyName

为什么呢?应该双方应该都应该用 netresources.spidernet.io/resource-inject-key 作为key 名,这样这不至于 和 其它项目相互污染,也才看那名字知道 这个 annotation 是什么用途

spidernet.io/shared_cx5_gpu7: 1
spidernet.io/shared_cx5_gpu8: 1
#nvidia.com/gpu: 1
netresources.spidernet.io/multus-config-label: shared-rdma-gpu
Copy link
Collaborator

@weizhoublue weizhoublue Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以考虑2 个

netresources.spidernet.io/resource-inject-key: myKeyName
netresources.spidernet.io/resource-inject-amount: 1 (default,默认可不写)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource-inject-amount: 1 是网卡数量还是 resources 的值?感觉是后者,但似乎没必要?什么场景会有 大于 1 的需求?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否是之前谈到的 gpu 和 nic 亲和性的实现时可能需要

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weizhoublue
Copy link
Collaborator

如果 multusconfig 配置中没有 rdma resource, 是否也能 正常工作 ?

@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 03:13 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 03:24 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 03:35 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 03:49 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 03:52 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 04:27 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 04:32 — with GitHub Actions Inactive
@cyclinder cyclinder temporarily deployed to release-base-images October 30, 2024 06:13 — with GitHub Actions Inactive
spidernet.io/gpu6sriov: 1
spidernet.io/gpu7sriov: 1
spidernet.io/gpu8sriov: 1
#nvidia.com/gpu: 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行 不应该出现

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以后PR 改

@cyclinder cyclinder merged commit 0a14405 into spidernet-io:main Oct 30, 2024
61 of 62 checks passed
@cyclinder cyclinder deleted the webhook/auto_smc branch October 30, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/feature-new release note for new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a mutating webhook for pods to auto inject the pod network resources
3 participants