ronething commented on code in PR #2647:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2647#discussion_r2502465558
##########
test/e2e/scaffold/apisix_deployer.go:
##########
@@ -371,6 +375,77 @@ func (s *APISIXDeployer)
CreateAdditionalGateway(namePrefix string) (string, *co
return identifier, svc, nil
}
+func (s *APISIXDeployer) CreateAdditionalGatewayWithOptions(namePrefix string,
opts DeployDataplaneOptions) (string, *corev1.Service, error) {
+ // Create a new namespace for this additional gateway
+ additionalNS := fmt.Sprintf("%s-%d", namePrefix, time.Now().Unix())
+
+ k8s.CreateNamespace(s.t, s.kubectlOptions, additionalNS)
+
+ // Create new kubectl options for the new namespace
+ kubectlOpts := &k8s.KubectlOptions{
+ ConfigPath: s.runtimeOpts.Kubeconfig,
+ Namespace: additionalNS,
+ }
+
+ s.Logf("additional gateway in namespace %s", additionalNS)
+
+ // Use the same admin key as the main gateway
+ adminKey := s.runtimeOpts.APISIXAdminAPIKey
+ s.Logf("additional gateway admin api key: %s", adminKey)
+
+ // Store gateway resources info
+ resources := &GatewayResources{
+ Namespace: additionalNS,
+ AdminAPIKey: adminKey,
+ }
+
+ // Deploy dataplane for this additional gateway
+ o := APISIXDeployOptions{
+ Namespace: additionalNS,
+ AdminKey: adminKey,
+ ServiceHTTPPort: 9080,
+ ServiceHTTPSPort: 9443,
+ }
+ if opts.Namespace != "" {
+ o.Namespace = additionalNS
+ }
+ if opts.AdminKey != "" {
+ o.AdminKey = adminKey
+ }
Review Comment:
Did you accidentally write it wrong or what?
##########
internal/adc/translator/gatewayproxy.go:
##########
@@ -44,47 +45,53 @@ func (t *Translator) TranslateGatewayProxyToConfig(tctx
*provider.TranslateConte
if provider.Type != v1alpha1.ProviderTypeControlPlane ||
provider.ControlPlane == nil {
return nil, nil
}
+ cp := provider.ControlPlane
- config := types.Config{
- Name: utils.NamespacedNameKind(gatewayProxy).String(),
+ cfg := types.Config{
+ Name: utils.NamespacedNameKind(gatewayProxy).String(),
+ BakcnedType: cp.Mode,
}
- if provider.ControlPlane.TlsVerify != nil {
- config.TlsVerify = *provider.ControlPlane.TlsVerify
+ if cp.TlsVerify != nil {
+ cfg.TlsVerify = *cp.TlsVerify
}
- if provider.ControlPlane.Auth.Type == v1alpha1.AuthTypeAdminKey &&
provider.ControlPlane.Auth.AdminKey != nil {
- if provider.ControlPlane.Auth.AdminKey.ValueFrom != nil &&
provider.ControlPlane.Auth.AdminKey.ValueFrom.SecretKeyRef != nil {
- secretRef :=
provider.ControlPlane.Auth.AdminKey.ValueFrom.SecretKeyRef
+ if cp.Auth.Type == v1alpha1.AuthTypeAdminKey && cp.Auth.AdminKey != nil
{
+ if cp.Auth.AdminKey.ValueFrom != nil &&
cp.Auth.AdminKey.ValueFrom.SecretKeyRef != nil {
+ secretRef := cp.Auth.AdminKey.ValueFrom.SecretKeyRef
secret, ok := tctx.Secrets[k8stypes.NamespacedName{
// we should use gateway proxy namespace
Namespace: gatewayProxy.GetNamespace(),
Name: secretRef.Name,
}]
if ok {
if token, ok := secret.Data[secretRef.Key]; ok {
- config.Token = string(token)
+ cfg.Token = string(token)
}
}
- } else if provider.ControlPlane.Auth.AdminKey.Value != "" {
- config.Token = provider.ControlPlane.Auth.AdminKey.Value
+ } else if cp.Auth.AdminKey.Value != "" {
+ cfg.Token = cp.Auth.AdminKey.Value
}
}
- if config.Token == "" {
+ if cfg.Token == "" {
return nil, errors.New("no token found")
}
- endpoints := provider.ControlPlane.Endpoints
+ endpoints := cp.Endpoints
if len(endpoints) > 0 {
- config.ServerAddrs = endpoints
- return &config, nil
+ cfg.ServerAddrs = endpoints
+ return &cfg, nil
}
- if provider.ControlPlane.Service != nil {
+ if cp.Mode != "" {
+ resolveEndpoints = cp.Mode ==
string(config.ProviderTypeStandalone)
+ }
Review Comment:
we can add some code comment.
##########
api/adc/types.go:
##########
@@ -779,6 +779,7 @@ type Config struct {
ServerAddrs []string
Token string
TlsVerify bool
+ BakcnedType string
Review Comment:
typo.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]