-
Notifications
You must be signed in to change notification settings - Fork 71
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
alibabacloud slb support map same TCP and UDP port , eg 8000/TCPUDP #197
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e69fef
create svc use port + protocol as name to fix when use same port but …
gaopeiliang 09f504c
alibabacloud slb support TCP/UDP
gaopeiliang afbc8ef
add log info
gaopeiliang eee7cf7
fix alibabacloud slb init same port svc
gaopeiliang dbd00a8
add doc
gaopeiliang b4bd057
clear log print, avoid too many info
gaopeiliang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,12 +144,16 @@ func initLbCache(svcList []corev1.Service, minPort, maxPort int32, blockPorts [] | |
var ports []int32 | ||
for _, port := range getPorts(svc.Spec.Ports) { | ||
if port <= maxPort && port >= minPort { | ||
newCache[lbId][port] = true | ||
ports = append(ports, port) | ||
value, ok := newCache[lbId][port] | ||
if !ok || !value { | ||
newCache[lbId][port] = true | ||
ports = append(ports, port) | ||
} | ||
} | ||
} | ||
if len(ports) != 0 { | ||
newPodAllocate[svc.GetNamespace()+"/"+svc.GetName()] = lbId + ":" + util.Int32SliceToString(ports, ",") | ||
log.Infof("svc %s/%s allocate slb %s ports %v", svc.Namespace, svc.Name, lbId, ports) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log is unnecessary, cause podAllocate will be printed when finished the initialization. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes ,,, |
||
} | ||
} | ||
} | ||
|
@@ -577,12 +581,29 @@ func (s *SlbPlugin) consSvc(sc *slbConfig, pod *corev1.Pod, c client.Client, ctx | |
|
||
svcPorts := make([]corev1.ServicePort, 0) | ||
for i := 0; i < len(sc.targetPorts); i++ { | ||
svcPorts = append(svcPorts, corev1.ServicePort{ | ||
Name: strconv.Itoa(sc.targetPorts[i]), | ||
Port: ports[i], | ||
Protocol: sc.protocols[i], | ||
TargetPort: intstr.FromInt(sc.targetPorts[i]), | ||
}) | ||
if sc.protocols[i] == ProtocolTCPUDP { | ||
svcPorts = append(svcPorts, corev1.ServicePort{ | ||
Name: fmt.Sprintf("%s-%s", strconv.Itoa(sc.targetPorts[i]), corev1.ProtocolTCP), | ||
Port: ports[i], | ||
Protocol: corev1.ProtocolTCP, | ||
TargetPort: intstr.FromInt(sc.targetPorts[i]), | ||
}) | ||
|
||
svcPorts = append(svcPorts, corev1.ServicePort{ | ||
Name: fmt.Sprintf("%s-%s", strconv.Itoa(sc.targetPorts[i]), corev1.ProtocolUDP), | ||
Port: ports[i], | ||
Protocol: corev1.ProtocolUDP, | ||
TargetPort: intstr.FromInt(sc.targetPorts[i]), | ||
}) | ||
|
||
} else { | ||
svcPorts = append(svcPorts, corev1.ServicePort{ | ||
Name: fmt.Sprintf("%s-%s", strconv.Itoa(sc.targetPorts[i]), sc.protocols[i]), | ||
Port: ports[i], | ||
Protocol: sc.protocols[i], | ||
TargetPort: intstr.FromInt(sc.targetPorts[i]), | ||
}) | ||
} | ||
} | ||
|
||
svcAnnotations := map[string]string{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot redeploy the service that not controlled by kruise-game but use same port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache just save lbId + port when design, it has no Protocol Attribute;
when use 8000/TCPUDP, cache just lbid:8000 and map to tcp:8000 udp:8000 two svc items;
when reinit cache , list tcp:8000 and udp:8000 should repeat to lbid:8000
else when 8000/TCPUDP, 9000/TCP will map error ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here svc all filter by SlbIdLabelKey , all controlled by kruise-game ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a problem to set map true for two times. And the svc using SlbIdLabelKey may be deployed by user self, not all controlled by kruise-game.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set cache map true two times has no problem , but append
podAllocate
two times maybe problem; eg: when config 8000/TCPUDP,9000/TCP , first createpodAllocate
is lb:8000,9000 , when reinitpodAllocate
with append two times, result is lb:8000,8000,9000, it will be error when resync svc;filter all svc by SlbIdLabelKey manager by kruise-game or not, record lb port to cache avoid allocated; I think is right ,
podAllocate
svc item not control by kruise-game never used ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point