Skip to content

IP冲突检测

oilbeater edited this page Jun 27, 2022 · 5 revisions

Wiki 下的中文文档将不在维护,请访问我们最新的中文文档网站,获取最新的文档更新。

Deprecated: Webhook 功能暂时不能使用

kube-ovn 可以通过安装 webhook 来拦截有冲突的固定IP的 Deployment/StatefulSet/DaemonSet/Pod 创建。

安装 kube-ovn webhook

相对于其他webhook,作为基础网络插件的 webhook,安装稍显繁琐。因为webhook需要用https证书与apiserver通信,所以我们引入cert-manager来自动生成自签名证书。而默认情况下cert-manager又是非host网络模式启动,因此我们安装的顺序为先安装kube-ovn网络插件,再安装cert-manager,最后安装webhook。

先参考快速安装,安装好kube-ovn。

安装cert-manager

# Create a namespace to run cert-manager in
kubectl create namespace cert-manager

# Disable resource validation on the cert-manager namespace
kubectl label namespace cert-manager certmanager.k8s.io/disable-validation=true

# Install the CustomResourceDefinitions and cert-manager itself
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.9.1/cert-manager.yaml

安装kube-ovn webhook

kubectl apply -f yamls/webhook.yaml

使用

webhook安装好后会自动拦截 Deployment/StatefulSet/DaemonSet/Pod 的创建/更新/删除请求。

对于annotation中指定的IP已经被使用的情况,会拦截创建/更新/删除请求。若未被使用,则会将这个地址写入 logical_switch 的 exclude_ip 中,是得自动分配 IP 的 POD 不会使用到这个地址。直到删除时,再将这个IP地址释放出来。

Clone this wiki locally