Skip to content

Commit

Permalink
feat: ApisixUpstream v2 (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan committed Jul 11, 2022
1 parent a73b52d commit a649751
Show file tree
Hide file tree
Showing 18 changed files with 1,722 additions and 393 deletions.
1 change: 1 addition & 0 deletions cmd/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ For example, no available LB exists in the bare metal environment.`)
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixTlsVersion, "apisix-tls-version", config.ApisixV2beta3, "the supported apisixtls api group version, can be \"apisix.apache.org/v2beta3\" or \"apisix.apache.org/v2\"")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixClusterConfigVersion, "apisix-cluster-config-version", config.ApisixV2beta3, "the supported ApisixClusterConfig api group version, can be \"apisix.apache.org/v2beta3\" or \"apisix.apache.org/v2\"")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixConsumerVersion, "apisix-consumer-version", config.ApisixV2beta3, "the supported ApisixConsumer api group version, can be \"apisix.apache.org/v2beta3\" or \"apisix.apache.org/v2\"")
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.APIVersion, "api-version", config.DefaultAPIVersion, config.APIVersionDescribe)
cmd.PersistentFlags().BoolVar(&cfg.Kubernetes.WatchEndpointSlices, "watch-endpointslices", false, "whether to watch endpointslices rather than endpoints")
cmd.PersistentFlags().BoolVar(&cfg.Kubernetes.EnableGatewayAPI, "enable-gateway-api", false, "whether to enable support for Gateway API")
cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterBaseURL, "default-apisix-cluster-base-url", "", "the base URL of admin api / manager api for the default APISIX cluster")
Expand Down
1 change: 1 addition & 0 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ kubernetes:
# Note: This feature is currently under development and may not work as expected.
# It is not recommended to use it in a production environment.
# Before we announce support for it to reach Beta level or GA.
api_version: apisix.apache.org/v2beta3 # the default value of API version is "apisix.apache.org/v2beta3", support "apisix.apache.org/v2beta3" and "apisix.apache.org/v2".

# APISIX related configurations.
apisix:
Expand Down
11 changes: 9 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const (
ApisixV2beta3 = "apisix.apache.org/v2beta3"
// ApisixV2 represents apisix.apache.org/v2
ApisixV2 = "apisix.apache.org/v2"
// DefaultApisixVersion refers to the default resource version
DefaultApisixVersion = ApisixV2beta3
// DefaultAPIVersion refers to the default resource version
DefaultAPIVersion = ApisixV2beta3

_minimalResyncInterval = 30 * time.Second

Expand All @@ -67,6 +67,11 @@ const (
ControllerName = "apisix.apache.org/gateway-controller"
)

var (
// Description information of API version, including default values and supported API version.
APIVersionDescribe = fmt.Sprintf(`the default value of API version is "%s", support "%s" and "%s".`, DefaultAPIVersion, ApisixV2beta3, ApisixV2)
)

// Config contains all config items which are necessary for
// apisix-ingress-controller's running.
type Config struct {
Expand Down Expand Up @@ -99,6 +104,7 @@ type KubernetesConfig struct {
ApisixConsumerVersion string `json:"apisix_consumer_version" yaml:"apisix_consumer_version"`
ApisixTlsVersion string `json:"apisix_tls_version" yaml:"apisix_tls_version"`
ApisixClusterConfigVersion string `json:"apisix_cluster_config_version" yaml:"apisix_cluster_config_version"`
APIVersion string `json:"api_version" yaml:"api_version"`
EnableGatewayAPI bool `json:"enable_gateway_api" yaml:"enable_gateway_api"`
}

Expand Down Expand Up @@ -139,6 +145,7 @@ func NewDefaultConfig() *Config {
ApisixConsumerVersion: ApisixV2beta3,
ApisixTlsVersion: ApisixV2beta3,
ApisixClusterConfigVersion: ApisixV2beta3,
APIVersion: DefaultAPIVersion,
WatchEndpointSlices: false,
EnableGatewayAPI: false,
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestNewConfigFromFile(t *testing.T) {
ApisixConsumerVersion: ApisixV2beta3,
ApisixTlsVersion: ApisixV2beta3,
ApisixClusterConfigVersion: ApisixV2beta3,
APIVersion: DefaultAPIVersion,
},
APISIX: APISIXConfig{
DefaultClusterName: "default",
Expand Down Expand Up @@ -94,6 +95,7 @@ kubernetes:
election_id: my-election-id
ingress_class: apisix
ingress_version: networking/v1
api_version: apisix.apache.org/v2beta3
apisix:
default_cluster_base_url: http://127.0.0.1:8080/apisix
default_cluster_admin_key: "123456"
Expand Down Expand Up @@ -137,6 +139,7 @@ func TestConfigWithEnvVar(t *testing.T) {
ApisixConsumerVersion: ApisixV2beta3,
ApisixTlsVersion: ApisixV2beta3,
ApisixClusterConfigVersion: ApisixV2beta3,
APIVersion: DefaultAPIVersion,
},
APISIX: APISIXConfig{
DefaultClusterName: "default",
Expand Down
Loading

0 comments on commit a649751

Please sign in to comment.