Skip to content

Commit

Permalink
Break system namespace and ingressgateway assumptions (istio#43809)
Browse files Browse the repository at this point in the history
* Custom ingress field and templatize certain tests for systemNamespace

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>

* Break assumption that the istio validating webhook is the only webhook in the cluster

Signed-off-by: Keith Mattix II <keithmattix2@gmail.com>

* Make lint

Signed-off-by: Keith Mattix II <keithmattix2@gmail.com>

* Fix line length

Signed-off-by: Keith Mattix II <keithmattix2@gmail.com>

* Default to istio-system in System.Namespace templates

* Fix camel case for ingressGatewayServiceName

Signed-off-by: Keith Mattix II <keithmattix2@gmail.com>

---------

Signed-off-by: Keith Mattix II <keithmattix@microsoft.com>
Signed-off-by: Keith Mattix II <keithmattix2@gmail.com>
  • Loading branch information
keithmattix authored Mar 9, 2023
1 parent 07b5f37 commit 1f41ab0
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 24 deletions.
6 changes: 3 additions & 3 deletions pkg/test/framework/components/istio/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ func (i *istioImpl) Dump(ctx resource.Context) {
for _, c := range ctx.Clusters().Kube().Primaries() {
c := c
g.Go(func() error {
kube2.DumpDebug(ctx, c, d, "configz")
kube2.DumpDebug(ctx, c, d, "configz", ns)
return nil
})
g.Go(func() error {
kube2.DumpDebug(ctx, c, d, "mcsz")
kube2.DumpDebug(ctx, c, d, "mcsz", ns)
return nil
})
g.Go(func() error {
kube2.DumpDebug(ctx, c, d, "clusterz")
kube2.DumpDebug(ctx, c, d, "clusterz", ns)
return nil
})
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/test/framework/components/istio/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ type Config struct {

// Custom deploymeny for east-west gateway
EastWestGatewayValues string

// IngressGatewayServiceName is the service name to use to reference the ingressgateway
// This field should only be set when DeployIstio is false
IngressGatewayServiceName string
}

func (c *Config) OverridesYAML(s *resource.Settings) string {
Expand Down Expand Up @@ -327,6 +331,7 @@ func (c *Config) String() string {
result += fmt.Sprintf("IstiodlessRemotes: %v\n", c.IstiodlessRemotes)
result += fmt.Sprintf("OperatorOptions: %v\n", c.OperatorOptions)
result += fmt.Sprintf("EnableCNI: %v\n", c.EnableCNI)
result += fmt.Sprintf("IngressGatewayServiceName: %v\n", c.IngressGatewayServiceName)

return result
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/test/framework/components/istio/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// init registers the command-line flags that we can exposed for "go test".
func init() {
flag.StringVar(&settingsFromCommandline.SystemNamespace, "istio.test.kube.systemNamespace", settingsFromCommandline.SystemNamespace,
"Deprecated, specifies the namespace where the Istio components (<=1.1) reside in a typical deployment.")
"Specifies the namespace where the istiod resides in a typical deployment. Defaults to istio-system")
flag.StringVar(&settingsFromCommandline.TelemetryNamespace, "istio.test.kube.telemetryNamespace", settingsFromCommandline.TelemetryNamespace,
"Specifies the namespace in which kiali, tracing providers, graphana, prometheus are deployed.")
flag.BoolVar(&settingsFromCommandline.DeployIstio, "istio.test.kube.deploy", settingsFromCommandline.DeployIstio,
Expand All @@ -41,4 +41,8 @@ func init() {
e.g. components.cni.enabled=true,components.cni.namespace=kube-system`)
flag.BoolVar(&settingsFromCommandline.EnableCNI, "istio.test.istio.enableCNI", settingsFromCommandline.EnableCNI,
"Deploy Istio with CNI enabled.")
flag.StringVar(&settingsFromCommandline.IngressGatewayServiceName, "istio.test.kube.ingressGatewayServiceName",
settingsFromCommandline.IngressGatewayServiceName,
`Specifies the name of the ingressgateway service to use when running tests in a preinstalled istio installation.
Should only be set when istio.test.kube.deploy=false`)
}
6 changes: 5 additions & 1 deletion pkg/test/framework/components/istio/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ func (i *istioImpl) Ingresses() ingress.Instances {
}

func (i *istioImpl) IngressFor(c cluster.Cluster) ingress.Instance {
name := types.NamespacedName{Name: defaultIngressServiceName, Namespace: i.cfg.SystemNamespace}
ingressServiceName := defaultIngressServiceName
if serviceNameOverride := i.cfg.IngressGatewayServiceName; serviceNameOverride != "" {
ingressServiceName = serviceNameOverride
}
name := types.NamespacedName{Name: ingressServiceName, Namespace: i.cfg.SystemNamespace}
return i.CustomIngressFor(c, name, defaultIngressIstioLabel)
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/test/kube/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func checkIfVM(pod corev1.Pod) bool {
return false
}

func DumpDebug(ctx resource.Context, c cluster.Cluster, workDir string, endpoint string) {
func DumpDebug(ctx resource.Context, c cluster.Cluster, workDir, endpoint, namespace string) {
ik, err := istioctl.New(ctx, istioctl.Config{Cluster: c})
if err != nil {
scopes.Framework.Warnf("failed dumping %s (cluster %s): %v", endpoint, c.Name(), err)
Expand All @@ -597,6 +597,9 @@ func DumpDebug(ctx resource.Context, c cluster.Cluster, workDir string, endpoint
if ctx.Settings().Revisions.Default() != "" {
args = append(args, "--revision", ctx.Settings().Revisions.Default())
}
if namespace != "" && namespace != "istio-system" {
args = append(args, "--istioNamespace", namespace)
}
scopes.Framework.Debugf("dump %s (cluster %s): %v", endpoint, c.Name(), args)
stdout, _, err := ik.Invoke(args)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/test/kube/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ func ValidatingWebhookConfigurationsExists(a kubernetes.Interface, names []strin
return false
}

if len(cfgs.Items) != len(names) {
// Target cluster could have other validating webhook configurations
if len(cfgs.Items) < len(names) {
return false
}

Expand Down
Loading

0 comments on commit 1f41ab0

Please sign in to comment.