-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add support for apisix backend mode
#181
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
Changes from 3 commits
d5d228a
9c55597
e9df775
9ed3758
de499ee
4a8d3c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filename can be changed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: etcd | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: etcd | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: etcd | ||
| spec: | ||
| containers: | ||
| - name: etcd | ||
| image: quay.io/coreos/etcd:v3.5.0 | ||
| command: | ||
| - etcd | ||
| - --data-dir=/etcd-data | ||
| - --name=node1 | ||
| - --initial-advertise-peer-urls=http://0.0.0.0:2380 | ||
| - --listen-peer-urls=http://0.0.0.0:2380 | ||
| - --advertise-client-urls=http://0.0.0.0:2379 | ||
| - --listen-client-urls=http://0.0.0.0:2379 | ||
| - --initial-cluster=node1=http://0.0.0.0:2380 | ||
| ports: | ||
| - containerPort: 2379 | ||
| - containerPort: 2380 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: etcd | ||
| spec: | ||
| ports: | ||
| - port: 2379 | ||
| targetPort: 2379 | ||
| selector: | ||
| app: etcd | ||
|
ronething marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ package scaffold | |
|
|
||
| import ( | ||
| "bytes" | ||
| "cmp" | ||
| "fmt" | ||
| "os" | ||
| "time" | ||
|
|
@@ -24,6 +25,7 @@ import ( | |
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| "github.com/apache/apisix-ingress-controller/internal/provider/adc" | ||
| "github.com/apache/apisix-ingress-controller/pkg/utils" | ||
| "github.com/apache/apisix-ingress-controller/test/e2e/framework" | ||
| ) | ||
|
|
@@ -36,6 +38,8 @@ type APISIXDeployOptions struct { | |
| ServiceType string | ||
| ServiceHTTPPort int | ||
| ServiceHTTPSPort int | ||
|
|
||
| ConfigProvider string | ||
| } | ||
|
|
||
| type APISIXDeployer struct { | ||
|
|
@@ -186,12 +190,25 @@ func (s *APISIXDeployer) deployDataplane(opts *APISIXDeployOptions) *corev1.Serv | |
| if opts.ServiceHTTPSPort == 0 { | ||
| opts.ServiceHTTPSPort = 443 | ||
| } | ||
| opts.ConfigProvider = "yaml" | ||
|
|
||
| kubectlOpts := k8s.NewKubectlOptions("", "", opts.Namespace) | ||
|
|
||
| if os.Getenv(framework.EnvKeyProviderType) == adc.BackendModeAPISIX { | ||
| opts.ServiceName = "apisix" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why serviceName should be fixed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 其实不是必要的。但打印日志中 ServiceName 是 "apisix-standalone" 的话那么一瞬间有点令人误解,怀疑是不是自己 ProviderType 没写对。所以改一下。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| opts.ConfigProvider = "etcd" | ||
| // deploy etcd | ||
| k8s.KubectlApplyFromString(s.GinkgoT, kubectlOpts, framework.EtcdSpec) | ||
| err := framework.WaitPodsAvailable(s.GinkgoT, kubectlOpts, metav1.ListOptions{ | ||
| LabelSelector: "app=etcd", | ||
| }) | ||
| Expect(err).ToNot(HaveOccurred(), "waiting for etcd pod ready") | ||
| } | ||
|
|
||
| buf := bytes.NewBuffer(nil) | ||
| err := framework.APISIXStandaloneTpl.Execute(buf, opts) | ||
| Expect(err).ToNot(HaveOccurred(), "executing template") | ||
|
|
||
| kubectlOpts := k8s.NewKubectlOptions("", "", opts.Namespace) | ||
| k8s.KubectlApplyFromString(s.GinkgoT, kubectlOpts, buf.String()) | ||
|
|
||
| err = framework.WaitPodsAvailable(s.GinkgoT, kubectlOpts, metav1.ListOptions{ | ||
|
|
@@ -218,17 +235,19 @@ func (s *APISIXDeployer) deployDataplane(opts *APISIXDeployOptions) *corev1.Serv | |
|
|
||
| func (s *APISIXDeployer) DeployIngress() { | ||
| s.Framework.DeployIngress(framework.IngressDeployOpts{ | ||
| ProviderSyncPeriod: 200 * time.Millisecond, | ||
| ControllerName: s.opts.ControllerName, | ||
| ProviderType: cmp.Or(os.Getenv(framework.EnvKeyProviderType), "apisix-standalone"), | ||
| ProviderSyncPeriod: 200 * time.Millisecond, | ||
| Namespace: s.namespace, | ||
| Replicas: 1, | ||
| }) | ||
| } | ||
|
|
||
| func (s *APISIXDeployer) ScaleIngress(replicas int) { | ||
| s.Framework.DeployIngress(framework.IngressDeployOpts{ | ||
| ProviderSyncPeriod: 200 * time.Millisecond, | ||
| ControllerName: s.opts.ControllerName, | ||
| ProviderType: cmp.Or(os.Getenv(framework.EnvKeyProviderType), "apisix-standalone"), | ||
| ProviderSyncPeriod: 200 * time.Millisecond, | ||
| Namespace: s.namespace, | ||
| Replicas: replicas, | ||
| }) | ||
|
|
||
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.
Why not return?
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.
fixed