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

Automated cherry pick of #24180 #24581

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@ type LoadBalancerIngress struct {
type ServiceSpec struct {
// The list of ports that are exposed by this service.
// More info: http://releases.k8s.io/release-1.2/docs/user-guide/services.md#virtual-ips-and-service-proxies
Ports []ServicePort `json:"ports"`
Ports []ServicePort `json:"ports" patchStrategy:"merge" patchMergeKey:"port"`

// This service will route traffic to pods having labels matching this selector.
// Label keys and values that must match in order to receive traffic for this service.
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,25 @@ var _ = Describe("Kubectl client", func() {
By("checking the result")
forEachReplicationController(c, ns, "app", "redis", validateReplicationControllerConfiguration)
})
It("should reuse nodePort when apply to an existing SVC", func() {
mkpath := func(file string) string {
return filepath.Join(testContext.RepoRoot, "examples/guestbook-go", file)
}
serviceJson := mkpath("redis-master-service.json")
nsFlag := fmt.Sprintf("--namespace=%v", ns)
By("creating Redis SVC")
runKubectlOrDie("create", "-f", serviceJson, nsFlag)
By("getting the original nodePort")
originalNodePort := runKubectlOrDie("get", "service", "redis-master", nsFlag, "-o", "jsonpath={.spec.ports[0].nodePort}")
By("applying the same configuration")
runKubectlOrDie("apply", "-f", serviceJson, nsFlag)
By("getting the nodePort after applying configuration")
currentNodePort := runKubectlOrDie("get", "service", "redis-master", nsFlag, "-o", "jsonpath={.spec.ports[0].nodePort}")
By("checking the result")
if originalNodePort != currentNodePort {
Failf("nodePort should keep the same")
}
})
})

Describe("Kubectl cluster-info", func() {
Expand Down