Skip to content

Commit

Permalink
write back subnet name to ip label
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Aug 12, 2019
1 parent 1c7121d commit ea451a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/daemon/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
if err != nil && k8serrors.IsNotFound(err) {
_, err := csh.KubeOvnClient.KubeovnV1().IPs().Create(&kubeovnv1.IP{
ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%s.%s", podRequest.PodName, podRequest.PodNamespace)},
Name: fmt.Sprintf("%s.%s", podRequest.PodName, podRequest.PodNamespace),
Labels: map[string]string{
util.SubnetNameLabel: subnet,
},
},
Spec: kubeovnv1.IPSpec{
PodName: podRequest.PodName,
Namespace: podRequest.PodNamespace,
Expand All @@ -94,6 +98,13 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
}
} else {
if err != nil {
if ipCrd.Labels != nil {
ipCrd.Labels[util.SubnetNameLabel] = subnet
} else {
ipCrd.Labels = map[string]string{
util.SubnetNameLabel: subnet,
}
}
ipCrd.Spec.PodName = podRequest.PodName
ipCrd.Spec.Namespace = podRequest.PodNamespace
ipCrd.Spec.Subnet = subnet
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const (

LogicalSwitchAnnotation = "ovn.kubernetes.io/logical_switch"

SubnetNameLabel = "ovn.kubernetes.io/subnet"

ProtocolTCP = "tcp"
ProtocolUDP = "udp"

Expand Down

0 comments on commit ea451a1

Please sign in to comment.