Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(leader_election): flag to disable leader election feature on …
…controller
- Loading branch information
Showing
11 changed files
with
196 additions
and
19 deletions.
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
test/e2e-image/namespace-overlays/disableleaderelection/values.yaml
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# TODO: remove the need to use fullnameOverride | ||
fullnameOverride: nginx-ingress | ||
controller: | ||
image: | ||
repository: ingress-controller/controller | ||
chroot: true | ||
tag: 1.0.0-dev | ||
digest: | ||
digestChroot: | ||
scope: | ||
# Necessary to allow the ingress controller to get the topology information from the nodes | ||
enabled: false | ||
config: | ||
worker-processes: "1" | ||
readinessProbe: | ||
initialDelaySeconds: 3 | ||
periodSeconds: 1 | ||
livenessProbe: | ||
initialDelaySeconds: 3 | ||
periodSeconds: 1 | ||
service: | ||
type: NodePort | ||
extraArgs: | ||
# e2e tests do not require information about ingress status | ||
update-status: "false" | ||
terminationGracePeriodSeconds: 1 | ||
admissionWebhooks: | ||
enabled: false | ||
|
||
disableLeaderElection: true | ||
|
||
rbac: | ||
create: true | ||
scope: false |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package disableleaderelection | ||
|
||
import ( | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/onsi/ginkgo/v2" | ||
|
||
"k8s.io/ingress-nginx/test/e2e/framework" | ||
) | ||
|
||
var _ = framework.IngressNginxDescribe("[Disable Leader] Routing works when leader election was disabled", func() { | ||
f := framework.NewDefaultFramework("disableleaderelection") | ||
|
||
ginkgo.BeforeEach(func() { | ||
f.NewEchoDeployment() | ||
}) | ||
|
||
ginkgo.It("should create multiple ingress routings rules when leader election has disabled", func() { | ||
host1 := "leader.election.disabled.com" | ||
host2 := "leader.election.disabled2.com" | ||
|
||
ing1 := framework.NewSingleIngress(host1, "/foo", host1, f.Namespace, framework.EchoService, 80, nil) | ||
f.EnsureIngress(ing1) | ||
|
||
ing2 := framework.NewSingleIngress(host2, "/ping", host2, f.Namespace, framework.EchoService, 80, nil) | ||
f.EnsureIngress(ing2) | ||
|
||
f.WaitForNginxServer(host1, | ||
func(server string) bool { | ||
return strings.Contains(server, host1) && | ||
strings.Contains(server, "location /foo") | ||
}) | ||
|
||
f.WaitForNginxServer(host2, | ||
func(server string) bool { | ||
return strings.Contains(server, host2) && | ||
strings.Contains(server, "location /ping") | ||
}) | ||
|
||
f.HTTPTestClient(). | ||
GET("/foo"). | ||
WithHeader("Host", host1). | ||
Expect(). | ||
Status(http.StatusOK) | ||
|
||
f.HTTPTestClient(). | ||
GET("/bar"). | ||
WithHeader("Host", host1). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
f.HTTPTestClient(). | ||
GET("/foo"). | ||
WithHeader("Host", host2). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
f.HTTPTestClient(). | ||
GET("/ping"). | ||
WithHeader("Host", host2). | ||
Expect(). | ||
Status(http.StatusOK) | ||
|
||
f.HTTPTestClient(). | ||
GET("/pong"). | ||
WithHeader("Host", host2). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
f.HTTPTestClient(). | ||
GET("/ping"). | ||
WithHeader("Host", host1). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
}) | ||
}) |
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