mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #48309 from MrHohn/e2e-fix-ingress-tag
Automatic merge from submit-queue [e2e-ingress] Get node tag from instance under GKE **What this PR does / why we need it**: Making ingress CI green again. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #48167 **Special notes for your reviewer**: /assign @nicksardo **Release note**: ```release-note NONE ```
This commit is contained in:
commit
afc67bdb6c
@ -124,6 +124,16 @@ func SetInstanceTags(cloudConfig CloudConfig, instanceName, zone string, tags []
|
|||||||
return resTags.Items
|
return resTags.Items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNodeTags gets k8s node tag from one of the nodes
|
||||||
|
func GetNodeTags(c clientset.Interface, cloudConfig CloudConfig) []string {
|
||||||
|
nodes := GetReadySchedulableNodesOrDie(c)
|
||||||
|
if len(nodes.Items) == 0 {
|
||||||
|
Logf("GetNodeTags: Found 0 node.")
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return GetInstanceTags(cloudConfig, nodes.Items[0].Name).Items
|
||||||
|
}
|
||||||
|
|
||||||
// GetInstancePrefix returns the INSTANCE_PREFIX env we set for e2e cluster.
|
// GetInstancePrefix returns the INSTANCE_PREFIX env we set for e2e cluster.
|
||||||
// From cluster/gce/config-test.sh, master name is set up using below format:
|
// From cluster/gce/config-test.sh, master name is set up using below format:
|
||||||
// MASTER_NAME="${INSTANCE_PREFIX}-master"
|
// MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||||
|
@ -976,13 +976,13 @@ func (j *IngressTestJig) GetIngressNodePorts() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource
|
// ConstructFirewallForIngress returns the expected GCE firewall rule for the ingress resource
|
||||||
func (j *IngressTestJig) ConstructFirewallForIngress(gceController *GCEIngressController, nodeTag string) *compute.Firewall {
|
func (j *IngressTestJig) ConstructFirewallForIngress(gceController *GCEIngressController, nodeTags []string) *compute.Firewall {
|
||||||
nodePorts := j.GetIngressNodePorts()
|
nodePorts := j.GetIngressNodePorts()
|
||||||
|
|
||||||
fw := compute.Firewall{}
|
fw := compute.Firewall{}
|
||||||
fw.Name = gceController.GetFirewallRuleName()
|
fw.Name = gceController.GetFirewallRuleName()
|
||||||
fw.SourceRanges = gcecloud.LoadBalancerSrcRanges()
|
fw.SourceRanges = gcecloud.LoadBalancerSrcRanges()
|
||||||
fw.TargetTags = []string{nodeTag}
|
fw.TargetTags = nodeTags
|
||||||
fw.Allowed = []*compute.FirewallAllowed{
|
fw.Allowed = []*compute.FirewallAllowed{
|
||||||
{
|
{
|
||||||
IPProtocol: "tcp",
|
IPProtocol: "tcp",
|
||||||
|
@ -124,7 +124,12 @@ var _ = framework.KubeDescribe("Loadbalancing: L7", func() {
|
|||||||
|
|
||||||
By("should have correct firewall rule for ingress")
|
By("should have correct firewall rule for ingress")
|
||||||
fw := gceController.GetFirewallRule()
|
fw := gceController.GetFirewallRule()
|
||||||
expFw := jig.ConstructFirewallForIngress(gceController, cloudConfig.NodeTag)
|
nodeTags := []string{cloudConfig.NodeTag}
|
||||||
|
if framework.TestContext.Provider != "gce" {
|
||||||
|
// nodeTags would be different in GKE.
|
||||||
|
nodeTags = framework.GetNodeTags(jig.Client, cloudConfig)
|
||||||
|
}
|
||||||
|
expFw := jig.ConstructFirewallForIngress(gceController, nodeTags)
|
||||||
// Passed the last argument as `true` to verify the backend ports is a subset
|
// Passed the last argument as `true` to verify the backend ports is a subset
|
||||||
// of the allowed ports in firewall rule, given there may be other existing
|
// of the allowed ports in firewall rule, given there may be other existing
|
||||||
// ingress resources and backends we are not aware of.
|
// ingress resources and backends we are not aware of.
|
||||||
|
Loading…
Reference in New Issue
Block a user