fix: add initContainers to verify if apisix is ready (#660)
diff --git a/Makefile b/Makefile
index 8b4b4a1..1697554 100644
--- a/Makefile
+++ b/Makefile
@@ -104,6 +104,10 @@
docker pull jmalloc/echo-server:latest
docker tag jmalloc/echo-server:latest $(LOCAL_REGISTRY)/jmalloc/echo-server:latest
docker push $(LOCAL_REGISTRY)/jmalloc/echo-server:latest
+
+ docker pull busybox:1.28
+ docker tag busybox:1.28 $(LOCAL_REGISTRY)/busybox:1.28
+ docker push $(LOCAL_REGISTRY)/busybox:1.28
endif
### kind-up: Launch a Kubernetes cluster with a image registry by Kind.
diff --git a/docs/en/latest/practices/the-hard-way.md b/docs/en/latest/practices/the-hard-way.md
index 5442af6..5b990cb 100644
--- a/docs/en/latest/practices/the-hard-way.md
+++ b/docs/en/latest/practices/the-hard-way.md
@@ -750,6 +750,10 @@
items:
- key: config.yaml
path: config.yaml
+ initContainers:
+ - name: wait-apisix-admin
+ image: busybox:1.28
+ command: ['sh', '-c', "until nc -z apisix-service.apisix.svc.cluster.local 9180 ; do echo waiting for apisix-admin; sleep 2; done;"]
containers:
- name: ingress-controller
command:
diff --git a/pkg/api/validation/apisix_route_test.go b/pkg/api/validation/apisix_route_test.go
index 2e01c0e..90a5e0a 100644
--- a/pkg/api/validation/apisix_route_test.go
+++ b/pkg/api/validation/apisix_route_test.go
@@ -41,6 +41,16 @@
return nil, fmt.Errorf("can't find the plugin schema")
}
+func (c fakeSchemaClient) GetRouteSchema(context.Context) (*api.Schema, error) {
+ return nil, nil
+}
+func (c fakeSchemaClient) GetUpstreamSchema(context.Context) (*api.Schema, error) {
+ return nil, nil
+}
+func (c fakeSchemaClient) GetConsumerSchema(context.Context) (*api.Schema, error) {
+ return nil, nil
+}
+
func newFakeSchemaClient() apisix.Schema {
testData := map[string]string{
"api-breaker": `{"required":["break_response_code"],"$comment":"this is a mark for our injected plugin schema","type":"object","properties":{"healthy":{"properties":{"successes":{"minimum":1,"type":"integer","default":3},"http_statuses":{"items":{"minimum":200,"type":"integer","maximum":499},"uniqueItems":true,"type":"array","minItems":1,"default":[200]}},"type":"object","default":{"successes":3,"http_statuses":[200]}},"break_response_code":{"minimum":200,"type":"integer","maximum":599},"max_breaker_sec":{"minimum":3,"type":"integer","default":300},"unhealthy":{"properties":{"failures":{"minimum":1,"type":"integer","default":3},"http_statuses":{"items":{"minimum":500,"type":"integer","maximum":599},"uniqueItems":true,"type":"array","minItems":1,"default":[500]}},"type":"object","default":{"failures":3,"http_statuses":[500]}},"disable":{"type":"boolean"}}}`,
diff --git a/test/e2e/scaffold/ingress.go b/test/e2e/scaffold/ingress.go
index 85f448c..c31bfde 100644
--- a/test/e2e/scaffold/ingress.go
+++ b/test/e2e/scaffold/ingress.go
@@ -214,6 +214,10 @@
app: ingress-apisix-controller-deployment-e2e-test
spec:
terminationGracePeriodSeconds: 0
+ initContainers:
+ - name: wait-apisix-admin
+ image: localhost:5000/busybox:1.28
+ command: ['sh', '-c', "until nc -z apisix-service-e2e-test.%s.svc.cluster.local 9180 ; do echo waiting for apisix-admin; sleep 2; done;"]
containers:
- livenessProbe:
failureThreshold: 3
@@ -343,7 +347,7 @@
assert.Nil(s.t, err, "deleting ClusterRole")
})
- ingressAPISIXDeployment := fmt.Sprintf(_ingressAPISIXDeploymentTemplate, s.opts.IngressAPISIXReplicas, s.namespace, s.opts.APISIXRouteVersion, _webhookCertSecret)
+ ingressAPISIXDeployment := fmt.Sprintf(_ingressAPISIXDeploymentTemplate, s.opts.IngressAPISIXReplicas, s.namespace, s.namespace, s.opts.APISIXRouteVersion, _webhookCertSecret)
err = k8s.KubectlApplyFromStringE(s.t, s.kubectlOptions, ingressAPISIXDeployment)
assert.Nil(s.t, err, "create deployment")