-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
support k8s < v1.19 & watch-ingress-without-class #12794
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
||
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 integration | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"testing" | ||
) | ||
|
||
// TestIngressAddonLegacy tests ingress and ingress-dns addons with legacy k8s version <1.19 | ||
func TestIngressAddonLegacy(t *testing.T) { | ||
if NoneDriver() { | ||
t.Skipf("skipping: none driver does not support ingress") | ||
} | ||
|
||
profile := UniqueProfileName("ingress-addon-legacy") | ||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(10)) | ||
defer Cleanup(t, profile, cancel) | ||
|
||
t.Run("StartLegacyK8sCluster", func(t *testing.T) { | ||
args := append([]string{"start", "-p", profile, "--kubernetes-version=v1.18.20", "--memory=4096", "--wait=true", "--alsologtostderr", "-v=5"}, StartArgs()...) | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err) | ||
} | ||
}) | ||
|
||
t.Run("serial", func(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
validator validateFunc | ||
}{ | ||
{"ValidateIngressAddonActivation", validateIngressAddonActivation}, | ||
{"ValidateIngressDNSAddonActivation", validateIngressDNSAddonActivation}, | ||
{"ValidateIngressAddons", validateIngressAddon}, | ||
} | ||
for _, tc := range tests { | ||
tc := tc | ||
if ctx.Err() == context.DeadlineExceeded { | ||
t.Fatalf("Unable to run more tests (deadline exceeded)") | ||
} | ||
t.Run(tc.name, func(t *testing.T) { | ||
tc.validator(ctx, t, profile) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
// validateIngressAddonActivation tests ingress addon activation | ||
func validateIngressAddonActivation(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
if _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "ingress", "--alsologtostderr", "-v=5")); err != nil { | ||
t.Errorf("failed to enable ingress addon: %v", err) | ||
} | ||
} | ||
|
||
// validateIngressDNSAddonActivation tests ingress-dns addon activation | ||
func validateIngressDNSAddonActivation(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
if _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "ingress-dns", "--alsologtostderr", "-v=5")); err != nil { | ||
t.Errorf("failed to enable ingress-dns addon: %v", err) | ||
} | ||
} |
File renamed without changes.
85 changes: 85 additions & 0 deletions
85
test/integration/testdata/ingress-dns-example-v1beta1.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,85 @@ | ||
# Copyright 2021 The Kubernetes Authors All rights reserved. | ||
# | ||
# 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. | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: hello-world-app | ||
namespace: default | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: hello-world-app | ||
template: | ||
metadata: | ||
labels: | ||
app: hello-world-app | ||
spec: | ||
containers: | ||
- name: hello-world-app | ||
image: gcr.io/google-samples/hello-app:1.0 | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: example-ingress | ||
namespace: kube-system | ||
annotations: | ||
# needed for k8s < v1.18: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#deprecating-the-ingress-class-annotation | ||
kubernetes.io/ingress.class: nginx | ||
spec: | ||
rules: | ||
- host: hello-john.test | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
serviceName: hello-world-app | ||
servicePort: 80 | ||
- host: hello-jane.test | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
serviceName: hello-world-app | ||
servicePort: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: hello-world-app | ||
namespace: kube-system | ||
spec: | ||
type: ExternalName | ||
externalName: hello-world-app.default.svc.cluster.local | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: hello-world-app | ||
namespace: default | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: 8080 | ||
protocol: TCP | ||
type: NodePort | ||
selector: | ||
app: hello-world-app |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: nginx-ingress | ||
annotations: | ||
# needed for k8s < v1.18: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#deprecating-the-ingress-class-annotation | ||
kubernetes.io/ingress.class: nginx | ||
labels: | ||
integration-test: ingress | ||
spec: | ||
rules: | ||
- host: nginx.example.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
serviceName: nginx | ||
servicePort: 80 |
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.
I could be wrong but @prezha does this mean the cutsom addon image wont work for ingress ? why we are removing this ?
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.
@medyagh in my first attempt to maintain backward compatibility (pr #12325), i used
cc.CustomAddonImages
to pass compatible images but only in case that those were not already set by the userthat would not work because of the logic in
assets.SelectAndPersistImages
overrides it - expecting to read custom images from the viper/flags (not from thecc
):minikube/pkg/minikube/assets/addons.go
Lines 735 to 747 in 418a9a1
hence, here i've amended the
addons.supportLegacyIngress
to replace instead the default images to those compatible if the older k8s was used, ie, without using or affecting in any way the cc - the custom images user could have provided via flags, so that should continue to work as beforeon a side note, i think the current logic in
assets.SelectAndPersistImages
mentioned above could be problematic as it could override the custom images that were defined in the first run with the default ones in subsequent runs if those that follow would not use the same flag providing initial custom images, same could be for the custom registries, but if an issue at all, it would be another story :)