Merge pull request #13439 from prezha/fix-ingress-multinode

fix ingress (also for multinode clusters)
pull/13539/head^2
Sharif Elgamal 2022-02-07 14:04:13 -08:00 committed by GitHub
commit 6189742a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 639 additions and 612 deletions

File diff suppressed because it is too large Load Diff

View File

@ -238,11 +238,11 @@ var Addons = map[string]*Addon{
"ingress-deploy.yaml",
"0640"),
}, false, "ingress", "", map[string]string{
// https://github.com/kubernetes/ingress-nginx/blob/14f6b32032b709d3e0f614ca85954c3583c5fe3d/deploy/static/provider/kind/deploy.yaml#L330
"IngressController": "ingress-nginx/controller:v1.1.0@sha256:f766669fdcf3dc26347ed273a55e754b427eb4411ee075a53f30718b4499076a",
// https://github.com/kubernetes/ingress-nginx/blob/14f6b32032b709d3e0f614ca85954c3583c5fe3d/deploy/static/provider/kind/deploy.yaml#L620
// https://github.com/kubernetes/ingress-nginx/blob/fc38b9f2aa2d68ee00c417cf97e727b77a00c175/deploy/static/provider/kind/deploy.yaml#L331
"IngressController": "ingress-nginx/controller:v1.1.1@sha256:0bc88eb15f9e7f84e8e56c14fa5735aaa488b840983f87bd79b1054190e660de",
// https://github.com/kubernetes/ingress-nginx/blob/fc38b9f2aa2d68ee00c417cf97e727b77a00c175/deploy/static/provider/kind/deploy.yaml#L621
"KubeWebhookCertgenCreate": "k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660",
// https://github.com/kubernetes/ingress-nginx/blob/14f6b32032b709d3e0f614ca85954c3583c5fe3d/deploy/static/provider/kind/deploy.yaml#L670
// https://github.com/kubernetes/ingress-nginx/blob/fc38b9f2aa2d68ee00c417cf97e727b77a00c175/deploy/static/provider/kind/deploy.yaml#L673
"KubeWebhookCertgenPatch": "k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1@sha256:64d8c73dca984af206adf9d6d7e46aa550362b1d7a01f3a0a91b20cc67868660",
}, map[string]string{
"IngressController": "k8s.gcr.io",

View File

@ -979,6 +979,7 @@ func kubectlPath(cfg config.ClusterConfig) string {
}
// applyNodeLabels applies minikube labels to all the nodes
// but it's currently called only from kubeadm.StartCluster (via kubeadm.init) where there's only one - first node
func (k *Bootstrapper) applyNodeLabels(cfg config.ClusterConfig) error {
// time cluster was created. time format is based on ISO 8601 (RFC 3339)
// converting - and : to _ because of Kubernetes label restriction
@ -987,12 +988,19 @@ func (k *Bootstrapper) applyNodeLabels(cfg config.ClusterConfig) error {
commitLbl := "minikube.k8s.io/commit=" + version.GetGitCommitID()
nameLbl := "minikube.k8s.io/name=" + cfg.Name
// ensure that "primary" label is applied only to the 1st node in the cluster (used eg for placing ingress there)
// this is used to uniquely distinguish that from other nodes in multi-master/multi-control-plane cluster config
primaryLbl := "minikube.k8s.io/primary=false"
if len(cfg.Nodes) <= 1 {
primaryLbl = "minikube.k8s.io/primary=true"
}
ctx, cancel := context.WithTimeout(context.Background(), applyTimeoutSeconds*time.Second)
defer cancel()
// example:
// sudo /var/lib/minikube/binaries/<version>/kubectl label nodes minikube.k8s.io/version=<version> minikube.k8s.io/commit=aa91f39ffbcf27dcbb93c4ff3f457c54e585cf4a-dirty minikube.k8s.io/name=p1 minikube.k8s.io/updated_at=2020_02_20T12_05_35_0700 --all --overwrite --kubeconfig=/var/lib/minikube/kubeconfig
cmd := exec.CommandContext(ctx, "sudo", kubectlPath(cfg),
"label", "nodes", verLbl, commitLbl, nameLbl, createdAtLbl, "--all", "--overwrite",
"label", "nodes", verLbl, commitLbl, nameLbl, createdAtLbl, primaryLbl, "--all", "--overwrite",
fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")))
if _, err := k.c.RunCmd(cmd); err != nil {

View File

@ -28,10 +28,10 @@ spec:
app: hello-world-app
spec:
containers:
- name: hello-world-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
- name: hello-world-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
@ -41,26 +41,26 @@ metadata:
spec:
ingressClassName: nginx
rules:
- host: hello-john.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-world-app
port:
number: 80
- host: hello-jane.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-world-app
port:
number: 80
- host: hello-john.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-world-app
port:
number: 80
- host: hello-jane.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-world-app
port:
number: 80
---
apiVersion: v1
kind: Service

View File

@ -28,10 +28,10 @@ spec:
app: hello-world-app
spec:
containers:
- name: hello-world-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
- name: hello-world-app
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
@ -43,22 +43,22 @@ metadata:
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
- 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

View File

@ -1,3 +1,17 @@
# Copyright 2022 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: networking.k8s.io/v1
kind: Ingress
metadata:

View File

@ -1,3 +1,17 @@
# Copyright 2022 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: networking.k8s.io/v1beta1
kind: Ingress
metadata: