Skip to content

Commit

Permalink
feat: ApisixRoute v2alpha1 (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
tokers authored Mar 3, 2021
1 parent 0c8f306 commit c65cc23
Show file tree
Hide file tree
Showing 43 changed files with 1,990 additions and 278 deletions.
1 change: 1 addition & 0 deletions cmd/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ the apisix cluster and others are created`,
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressClass, "ingress-class", config.IngressClass, "the class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation \"kubernetes.io/ingress.class\" (deprecated)")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ElectionID, "election-id", config.IngressAPISIXLeader, "election id used for campaign the controller leader")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressVersion, "ingress-version", config.IngressNetworkingV1, "the supported ingress api group version, can be \"networking/v1beta1\" or \"networking/v1\" (for Kubernetes version v1.19.0 or higher)")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixRouteVersion, "apisix-route-version", config.ApisixRouteV2alpha1, "the supported apisixroute api group version, can be \"apisix.apache.org/v1\" or \"apisix.apache.org/v2alpha1\"")
cmd.PersistentFlags().StringVar(&cfg.APISIX.BaseURL, "apisix-base-url", "", "the base URL for APISIX admin api / manager api")
cmd.PersistentFlags().StringVar(&cfg.APISIX.AdminKey, "apisix-admin-key", "", "admin key used for the authorization of APISIX admin api / manager api")

Expand Down
3 changes: 3 additions & 0 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ kubernetes:
# or "networking/v1" (for Kubernetes version v1.19.0 or higher), default
# is "networking/v1".

apisix_route_version: "apisix.apache.org/v2alpha1" # the supported apisixroute api group version, can be
# "apisix.apache.org/v1" or "apisix.apache.org/v2alpha1",
# default is "apisix.apache.org/v2alpha1".
# APISIX related configurations.
apisix:
base_url: "http://127.0.0.1:9080/apisix/admin" # the APISIX admin api / manager api
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module github.com/apache/apisix-ingress-controller
go 1.13

require (
github.com/gavv/httpexpect/v2 v2.2.0 // indirect
github.com/gin-gonic/gin v1.6.3
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/gruntwork-io/terratest v0.32.7 // indirect
github.com/gruntwork-io/terratest v0.32.8 // indirect
github.com/hashicorp/go-memdb v1.0.4
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
Expand Down
56 changes: 54 additions & 2 deletions go.sum

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const (
IngressNetworkingV1 = "networking/v1"
// IngressNetworkingV1beta1 represents ingress.networking/v1beta1
IngressNetworkingV1beta1 = "networking/v1beta1"
// ApisixRouteV1 represents apisixroute.apisix.apache.org/v1
ApisixRouteV1 = "apisix.apache.org/v1"
// ApisixRouteV2alpha1 represents apisixroute.apisix.apache.org/v2alpha1
ApisixRouteV2alpha1 = "apisix.apache.org/v2alpha1"

_minimalResyncInterval = 30 * time.Second
)
Expand All @@ -59,12 +63,13 @@ type Config struct {

// KubernetesConfig contains all Kubernetes related config items.
type KubernetesConfig struct {
Kubeconfig string `json:"kubeconfig" yaml:"kubeconfig"`
ResyncInterval types.TimeDuration `json:"resync_interval" yaml:"resync_interval"`
AppNamespaces []string `json:"app_namespaces" yaml:"app_namespaces"`
ElectionID string `json:"election_id" yaml:"election_id"`
IngressClass string `json:"ingress_class" yaml:"ingress_class"`
IngressVersion string `json:"ingress_version" yaml:"ingress_version"`
Kubeconfig string `json:"kubeconfig" yaml:"kubeconfig"`
ResyncInterval types.TimeDuration `json:"resync_interval" yaml:"resync_interval"`
AppNamespaces []string `json:"app_namespaces" yaml:"app_namespaces"`
ElectionID string `json:"election_id" yaml:"election_id"`
IngressClass string `json:"ingress_class" yaml:"ingress_class"`
IngressVersion string `json:"ingress_version" yaml:"ingress_version"`
ApisixRouteVersion string `json:"apisix_route_version" yaml:"apisix_route_version"`
}

// APISIXConfig contains all APISIX related config items.
Expand All @@ -83,12 +88,13 @@ func NewDefaultConfig() *Config {
HTTPListen: ":8080",
EnableProfiling: true,
Kubernetes: KubernetesConfig{
Kubeconfig: "", // Use in-cluster configurations.
ResyncInterval: types.TimeDuration{Duration: 6 * time.Hour},
AppNamespaces: []string{v1.NamespaceAll},
ElectionID: IngressAPISIXLeader,
IngressClass: IngressClass,
IngressVersion: IngressNetworkingV1,
Kubeconfig: "", // Use in-cluster configurations.
ResyncInterval: types.TimeDuration{Duration: 6 * time.Hour},
AppNamespaces: []string{v1.NamespaceAll},
ElectionID: IngressAPISIXLeader,
IngressClass: IngressClass,
IngressVersion: IngressNetworkingV1,
ApisixRouteVersion: ApisixRouteV2alpha1,
},
}
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ func TestNewConfigFromFile(t *testing.T) {
HTTPListen: ":9090",
EnableProfiling: true,
Kubernetes: KubernetesConfig{
ResyncInterval: types.TimeDuration{time.Hour},
Kubeconfig: "/path/to/foo/baz",
AppNamespaces: []string{""},
ElectionID: "my-election-id",
IngressClass: IngressClass,
IngressVersion: IngressNetworkingV1,
ResyncInterval: types.TimeDuration{time.Hour},
Kubeconfig: "/path/to/foo/baz",
AppNamespaces: []string{""},
ElectionID: "my-election-id",
IngressClass: IngressClass,
IngressVersion: IngressNetworkingV1,
ApisixRouteVersion: ApisixRouteV2alpha1,
},
APISIX: APISIXConfig{
BaseURL: "http://127.0.0.1:8080/apisix",
Expand Down
Loading

0 comments on commit c65cc23

Please sign in to comment.