diff --git a/.github/workflows/cts.yaml b/.github/workflows/cts.yaml index ef96ba1cd..5ffd051fc 100644 --- a/.github/workflows/cts.yaml +++ b/.github/workflows/cts.yaml @@ -112,8 +112,8 @@ jobs: - [EmqxBroker, emqx, "config/samples/emqx/v1beta4/emqxbroker-full.yaml"] - [EmqxEnterprise, emqx-ee, "config/samples/emqx/v1beta4/emqxenterprise-slim.yaml"] - [EmqxEnterprise, emqx-ee, "config/samples/emqx/v1beta4/emqxenterprise-full.yaml"] - - [EMQX, emqx, "config/samples/emqx/v2alpha2/emqx-slim.yaml"] - - [EMQX, emqx, "config/samples/emqx/v2alpha2/emqx-full.yaml"] + - [EMQX, emqx, "config/samples/emqx/v2beta1/emqx-slim.yaml"] + - [EMQX, emqx, "config/samples/emqx/v2beta1/emqx-full.yaml"] steps: - if: matrix.kubernetes-env == 'k3s' diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index be958e89a..0f129ad96 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -30,8 +30,8 @@ jobs: - [EMQX, emqx, "config/samples/emqx/v2alpha1/emqx-slim.yaml"] - [EMQX, emqx, "config/samples/emqx/v2alpha1/emqx-full.yaml"] - - [EMQX, emqx, "config/samples/emqx/v2alpha2/emqx-slim.yaml"] - - [EMQX, emqx, "config/samples/emqx/v2alpha2/emqx-full.yaml"] + - [EMQX, emqx, "config/samples/emqx/v2beta1/emqx-slim.yaml"] + - [EMQX, emqx, "config/samples/emqx/v2beta1/emqx-full.yaml"] steps: - run: minikube start diff --git a/PROJECT b/PROJECT index 8d4b8efd4..3c999f84d 100644 --- a/PROJECT +++ b/PROJECT @@ -122,8 +122,8 @@ resources: domain: emqx.io group: apps kind: EMQX - path: github.com/emqx/emqx-operator/apis/apps/v2alpha2 - version: v2alpha2 + path: github.com/emqx/emqx-operator/apis/apps/v2beta1 + version: v2beta1 webhooks: conversion: true defaulting: true @@ -136,8 +136,8 @@ resources: domain: emqx.io group: apps kind: Rebalance - path: github.com/emqx/emqx-operator/apis/apps/v2alpha2 - version: v2alpha2 + path: github.com/emqx/emqx-operator/apis/apps/v2beta1 + version: v2beta1 webhooks: conversion: true defaulting: true diff --git a/README.md b/README.md index f9c676190..ddfa59a88 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The EMQX Operator includes, but is not limited to, the following features: | 4.4.8 (included) ~ 4.4.14 | 1.2.6, 1.2.7, 1.2.8, 2.0.0, 2.0.1, 2.0.2, 2.0.3 | [apps.emqx.io/v1beta3](./docs/en_US/reference/v1beta3-reference.md) | EmqxEnterprise | | 4.4.14 (included) or higher 4.4.x | 2.1.0, 2.1.1 | [apps.emqx.io/v1beta4](./docs/en_US/reference/v1beta4-reference.md) | EmqxEnterprise | | 5.0.0 (included) ~ 5.0.23 | 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./docs/en_US/reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2alpha2](./docs/en_US/reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2beta1](./docs/en_US/reference/v2beta1-reference.md) | EMQX | ### EMQX Open Source @@ -43,7 +43,7 @@ The EMQX Operator includes, but is not limited to, the following features: | 5.0.6 (included) ~ 5.0.8 | 2.0.0, 2.0.1, 2.0.3 | [apps.emqx.io/v2alpha1](./docs/en_US/reference/v2alpha1-reference.md) | EMQX | | 5.0.8 (included) ~ 5.0.14 | 2.0.2 | [apps.emqx.io/v2alpha1](./docs/en_US/reference/v2alpha1-reference.md) | EMQX | | 5.0.14 (included) ~ 5.0.23 | 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./docs/en_US/reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2alpha2](./docs/en_US/reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2beta1](./docs/en_US/reference/v2beta1-reference.md) | EMQX | ## How to selector Kubernetes version diff --git a/apis/apps/v1beta4/rebalance_conversion.go b/apis/apps/v1beta4/rebalance_conversion.go index bcbb7250d..b81b05e84 100644 --- a/apis/apps/v1beta4/rebalance_conversion.go +++ b/apis/apps/v1beta4/rebalance_conversion.go @@ -19,13 +19,13 @@ package v1beta4 import ( "encoding/json" - "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + "github.com/emqx/emqx-operator/apis/apps/v2beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) // ConvertTo converts this version to the Hub version (v1). func (src *Rebalance) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v2alpha2.Rebalance) + dst := dstRaw.(*v2beta1.Rebalance) b, err := json.Marshal(src) if err != nil { @@ -44,7 +44,7 @@ func (src *Rebalance) ConvertTo(dstRaw conversion.Hub) error { // ConvertFrom converts from the Hub version (v1) to this version. func (dst *Rebalance) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v2alpha2.Rebalance) + src := srcRaw.(*v2beta1.Rebalance) b, err := json.Marshal(src) if err != nil { diff --git a/apis/apps/v1beta4/rebalance_conversion_test.go b/apis/apps/v1beta4/rebalance_conversion_test.go index 0e99d9eb9..496ee4c8b 100644 --- a/apis/apps/v1beta4/rebalance_conversion_test.go +++ b/apis/apps/v1beta4/rebalance_conversion_test.go @@ -19,12 +19,12 @@ package v1beta4 import ( "testing" - "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" ) func TestConvertTo(t *testing.T) { - dst := &v2alpha2.Rebalance{} + dst := &v2beta1.Rebalance{} src := &Rebalance{} assert.Nil(t, src.ConvertTo(dst)) @@ -32,7 +32,7 @@ func TestConvertTo(t *testing.T) { func TestConvertFrom(t *testing.T) { dst := &Rebalance{} - src := &v2alpha2.Rebalance{} + src := &v2beta1.Rebalance{} assert.Nil(t, dst.ConvertFrom(src)) } diff --git a/apis/apps/v2alpha1/emqx_conversion.go b/apis/apps/v2alpha1/emqx_conversion.go index 89682376b..c3f6c7182 100644 --- a/apis/apps/v2alpha1/emqx_conversion.go +++ b/apis/apps/v2alpha1/emqx_conversion.go @@ -19,13 +19,13 @@ package v2alpha1 import ( "encoding/json" - "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + "github.com/emqx/emqx-operator/apis/apps/v2beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) // ConvertTo converts this version to the Hub version (v1). func (src *EMQX) ConvertTo(dstRaw conversion.Hub) error { - dst := dstRaw.(*v2alpha2.EMQX) + dst := dstRaw.(*v2beta1.EMQX) b, err := json.Marshal(src) if err != nil { @@ -35,7 +35,7 @@ func (src *EMQX) ConvertTo(dstRaw conversion.Hub) error { if err := json.Unmarshal(b, dst); err != nil { return err } - dst.SetGroupVersionKind(v2alpha2.GroupVersion.WithKind("EMQX")) + dst.SetGroupVersionKind(v2beta1.GroupVersion.WithKind("EMQX")) dst.Spec.ClusterDomain = "cluster.local" dst.Spec.Config.Data = src.Spec.BootstrapConfig @@ -45,7 +45,7 @@ func (src *EMQX) ConvertTo(dstRaw conversion.Hub) error { // ConvertFrom converts from the Hub version (v1) to this version. func (dst *EMQX) ConvertFrom(srcRaw conversion.Hub) error { - src := srcRaw.(*v2alpha2.EMQX) + src := srcRaw.(*v2beta1.EMQX) b, err := json.Marshal(src) if err != nil { diff --git a/apis/apps/v2alpha1/emqx_conversion_test.go b/apis/apps/v2alpha1/emqx_conversion_test.go index 8555df3e1..0a17675ba 100644 --- a/apis/apps/v2alpha1/emqx_conversion_test.go +++ b/apis/apps/v2alpha1/emqx_conversion_test.go @@ -19,21 +19,21 @@ package v2alpha1 import ( "testing" - "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" ) func TestConvertTo(t *testing.T) { - dst := &v2alpha2.EMQX{} + dst := &v2beta1.EMQX{} src := &EMQX{} assert.Nil(t, src.ConvertTo(dst)) - assert.Equal(t, v2alpha2.GroupVersion.String(), dst.GroupVersionKind().GroupVersion().String()) + assert.Equal(t, v2beta1.GroupVersion.String(), dst.GroupVersionKind().GroupVersion().String()) } func TestConvertFrom(t *testing.T) { dst := &EMQX{} - src := &v2alpha2.EMQX{} + src := &v2beta1.EMQX{} assert.Nil(t, dst.ConvertFrom(src)) assert.Equal(t, GroupVersion.String(), dst.GroupVersionKind().GroupVersion().String()) diff --git a/apis/apps/v2alpha2/const.go b/apis/apps/v2beta1/const.go similarity index 97% rename from apis/apps/v2alpha2/const.go rename to apis/apps/v2beta1/const.go index eed164e08..0b6f2f2f3 100644 --- a/apis/apps/v2alpha2/const.go +++ b/apis/apps/v2beta1/const.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import corev1 "k8s.io/api/core/v1" diff --git a/apis/apps/v2alpha2/emqx_conversion.go b/apis/apps/v2beta1/emqx_conversion.go similarity index 97% rename from apis/apps/v2alpha2/emqx_conversion.go rename to apis/apps/v2beta1/emqx_conversion.go index 6050554cf..8879dadc1 100644 --- a/apis/apps/v2alpha2/emqx_conversion.go +++ b/apis/apps/v2beta1/emqx_conversion.go @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 func (*EMQX) Hub() {} diff --git a/apis/apps/v2alpha2/emqx_types.go b/apis/apps/v2beta1/emqx_types.go similarity index 99% rename from apis/apps/v2alpha2/emqx_types.go rename to apis/apps/v2beta1/emqx_types.go index d0b02aa8f..a5df35afb 100644 --- a/apis/apps/v2alpha2/emqx_types.go +++ b/apis/apps/v2beta1/emqx_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( corev1 "k8s.io/api/core/v1" diff --git a/apis/apps/v2alpha2/emqx_webhook.go b/apis/apps/v2beta1/emqx_webhook.go similarity index 94% rename from apis/apps/v2alpha2/emqx_webhook.go rename to apis/apps/v2beta1/emqx_webhook.go index 320f97cbc..27ef1bd9e 100644 --- a/apis/apps/v2alpha2/emqx_webhook.go +++ b/apis/apps/v2beta1/emqx_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "reflect" @@ -41,7 +41,7 @@ func (r *EMQX) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -//+kubebuilder:webhook:path=/mutate-apps-emqx-io-v2alpha2-emqx,mutating=true,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=emqxes,verbs=create;update,versions=v2alpha2,name=mutating.apps.emqx.io,admissionReviewVersions={v1,v1beta1} +//+kubebuilder:webhook:path=/mutate-apps-emqx-io-v2beta1-emqx,mutating=true,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=emqxes,verbs=create;update,versions=v2beta1,name=mutating.apps.emqx.io,admissionReviewVersions={v1,v1beta1} var _ webhook.Defaulter = &EMQX{} @@ -59,7 +59,7 @@ func (r *EMQX) Default() { } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-apps-emqx-io-v2alpha2-emqx,mutating=false,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=emqxes,verbs=create;update,versions=v2alpha2,name=validator.apps.emqx.io,admissionReviewVersions={v1,v1beta1} +//+kubebuilder:webhook:path=/validate-apps-emqx-io-v2beta1-emqx,mutating=false,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=emqxes,verbs=create;update,versions=v2beta1,name=validator.apps.emqx.io,admissionReviewVersions={v1,v1beta1} var _ webhook.Validator = &EMQX{} diff --git a/apis/apps/v2alpha2/emqx_webhook_test.go b/apis/apps/v2beta1/emqx_webhook_test.go similarity index 99% rename from apis/apps/v2alpha2/emqx_webhook_test.go rename to apis/apps/v2beta1/emqx_webhook_test.go index 5c8c42886..58074b6a0 100644 --- a/apis/apps/v2alpha2/emqx_webhook_test.go +++ b/apis/apps/v2beta1/emqx_webhook_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" diff --git a/apis/apps/v2alpha2/groupversion_info.go b/apis/apps/v2beta1/groupversion_info.go similarity index 90% rename from apis/apps/v2alpha2/groupversion_info.go rename to apis/apps/v2beta1/groupversion_info.go index aa8dd8fe5..979436a6d 100644 --- a/apis/apps/v2alpha2/groupversion_info.go +++ b/apis/apps/v2beta1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v2alpha2 contains API Schema definitions for the apps v2alpha2 API group +// Package v2beta1 contains API Schema definitions for the apps v2beta1 API group // +kubebuilder:object:generate=true // +groupName=apps.emqx.io -package v2alpha2 +package v2beta1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "apps.emqx.io", Version: "v2alpha2"} + GroupVersion = schema.GroupVersion{Group: "apps.emqx.io", Version: "v2beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/apis/apps/v2alpha2/names.go b/apis/apps/v2beta1/names.go similarity index 98% rename from apis/apps/v2alpha2/names.go rename to apis/apps/v2beta1/names.go index dc6999c63..1643df411 100644 --- a/apis/apps/v2alpha2/names.go +++ b/apis/apps/v2beta1/names.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "fmt" diff --git a/apis/apps/v2alpha2/rebalance_conversion.go b/apis/apps/v2beta1/rebalance_conversion.go similarity index 97% rename from apis/apps/v2alpha2/rebalance_conversion.go rename to apis/apps/v2beta1/rebalance_conversion.go index ce089a512..05ae23298 100644 --- a/apis/apps/v2alpha2/rebalance_conversion.go +++ b/apis/apps/v2beta1/rebalance_conversion.go @@ -11,6 +11,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 func (*Rebalance) Hub() {} diff --git a/apis/apps/v2alpha2/rebalance_types.go b/apis/apps/v2beta1/rebalance_types.go similarity index 99% rename from apis/apps/v2alpha2/rebalance_types.go rename to apis/apps/v2beta1/rebalance_types.go index 2e033d175..86951f510 100644 --- a/apis/apps/v2alpha2/rebalance_types.go +++ b/apis/apps/v2beta1/rebalance_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "fmt" @@ -27,7 +27,7 @@ import ( // RebalanceSpec defines the desired state of Rebalance type RebalanceSpec struct { // InstanceKind is used to distinguish between EMQX and EMQXEnterprise. - // When it is set to "EMQX", it means that the EMQX CR is v2alpha2, + // When it is set to "EMQX", it means that the EMQX CR is v2beta1, // and when it is set to "EmqxEnterprise", it means that the EmqxEnterprise CR is v1beta4. //+kubebuilder:default:="EMQX" InstanceKind string `json:"instanceKind"` diff --git a/apis/apps/v2alpha2/rebalance_types_test.go b/apis/apps/v2beta1/rebalance_types_test.go similarity index 99% rename from apis/apps/v2alpha2/rebalance_types_test.go rename to apis/apps/v2beta1/rebalance_types_test.go index cb6a00853..1a7319ec4 100644 --- a/apis/apps/v2alpha2/rebalance_types_test.go +++ b/apis/apps/v2beta1/rebalance_types_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" diff --git a/apis/apps/v2alpha2/rebalance_webhook.go b/apis/apps/v2beta1/rebalance_webhook.go similarity index 90% rename from apis/apps/v2alpha2/rebalance_webhook.go rename to apis/apps/v2beta1/rebalance_webhook.go index f99df927f..e7faa4549 100644 --- a/apis/apps/v2alpha2/rebalance_webhook.go +++ b/apis/apps/v2beta1/rebalance_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "errors" @@ -37,7 +37,7 @@ func (r *Rebalance) SetupWebhookWithManager(mgr ctrl.Manager) error { } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-apps-emqx-io-v2alpha2-rebalance,mutating=false,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=rebalances,verbs=create;update,versions=v2alpha2,name=validator.rebalance.emqx.io,admissionReviewVersions={v1,v1beta1} +//+kubebuilder:webhook:path=/validate-apps-emqx-io-v2beta1-rebalance,mutating=false,failurePolicy=fail,sideEffects=None,groups=apps.emqx.io,resources=rebalances,verbs=create;update,versions=v2beta1,name=validator.rebalance.emqx.io,admissionReviewVersions={v1,v1beta1} var _ webhook.Validator = &Rebalance{} diff --git a/apis/apps/v2alpha2/rebalance_webhook_test.go b/apis/apps/v2beta1/rebalance_webhook_test.go similarity index 99% rename from apis/apps/v2alpha2/rebalance_webhook_test.go rename to apis/apps/v2beta1/rebalance_webhook_test.go index 51fc1fa86..cef455d4a 100644 --- a/apis/apps/v2alpha2/rebalance_webhook_test.go +++ b/apis/apps/v2beta1/rebalance_webhook_test.go @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" diff --git a/apis/apps/v2alpha2/status.go b/apis/apps/v2beta1/status.go similarity index 99% rename from apis/apps/v2alpha2/status.go rename to apis/apps/v2beta1/status.go index f5ef89590..33f950cb9 100644 --- a/apis/apps/v2alpha2/status.go +++ b/apis/apps/v2beta1/status.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "sort" diff --git a/apis/apps/v2alpha2/status_test.go b/apis/apps/v2beta1/status_test.go similarity index 99% rename from apis/apps/v2alpha2/status_test.go rename to apis/apps/v2beta1/status_test.go index 98b59b46d..0fa5165ed 100644 --- a/apis/apps/v2alpha2/status_test.go +++ b/apis/apps/v2beta1/status_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" diff --git a/apis/apps/v2alpha2/util.go b/apis/apps/v2beta1/util.go similarity index 99% rename from apis/apps/v2alpha2/util.go rename to apis/apps/v2beta1/util.go index d0a0e84d0..113164bde 100644 --- a/apis/apps/v2alpha2/util.go +++ b/apis/apps/v2beta1/util.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "fmt" diff --git a/apis/apps/v2alpha2/util_test.go b/apis/apps/v2beta1/util_test.go similarity index 99% rename from apis/apps/v2alpha2/util_test.go rename to apis/apps/v2beta1/util_test.go index b4ab4dcf1..3dc44257f 100644 --- a/apis/apps/v2alpha2/util_test.go +++ b/apis/apps/v2beta1/util_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" diff --git a/apis/apps/v2alpha2/webhook_suite_test.go b/apis/apps/v2beta1/webhook_suite_test.go similarity index 99% rename from apis/apps/v2alpha2/webhook_suite_test.go rename to apis/apps/v2beta1/webhook_suite_test.go index e369c212d..da970c1c1 100644 --- a/apis/apps/v2alpha2/webhook_suite_test.go +++ b/apis/apps/v2beta1/webhook_suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "context" diff --git a/apis/apps/v2alpha2/zz_generated.deepcopy.go b/apis/apps/v2beta1/zz_generated.deepcopy.go similarity index 99% rename from apis/apps/v2alpha2/zz_generated.deepcopy.go rename to apis/apps/v2beta1/zz_generated.deepcopy.go index d1caa30b5..05531413b 100644 --- a/apis/apps/v2alpha2/zz_generated.deepcopy.go +++ b/apis/apps/v2beta1/zz_generated.deepcopy.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v2alpha2 +package v2beta1 import ( "k8s.io/api/core/v1" diff --git a/config/crd/bases/apps.emqx.io_emqxes.yaml b/config/crd/bases/apps.emqx.io_emqxes.yaml index d9908d6ba..8de2ba04d 100644 --- a/config/crd/bases/apps.emqx.io_emqxes.yaml +++ b/config/crd/bases/apps.emqx.io_emqxes.yaml @@ -6470,7 +6470,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v2alpha2 + name: v2beta1 schema: openAPIV3Schema: properties: diff --git a/config/crd/bases/apps.emqx.io_rebalances.yaml b/config/crd/bases/apps.emqx.io_rebalances.yaml index 63b524f63..16bceaafc 100644 --- a/config/crd/bases/apps.emqx.io_rebalances.yaml +++ b/config/crd/bases/apps.emqx.io_rebalances.yaml @@ -146,7 +146,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v2alpha2 + name: v2beta1 schema: openAPIV3Schema: properties: diff --git a/config/dev/kustomization.yaml b/config/dev/kustomization.yaml index 9cadfbe57..040443f0b 100644 --- a/config/dev/kustomization.yaml +++ b/config/dev/kustomization.yaml @@ -112,7 +112,7 @@ patches: - op: "add" path: "/webhooks/3/clientConfig/url" - value: "https://host.docker.internal:9443/mutate-apps-emqx-io-v2alpha2-emqx" + value: "https://host.docker.internal:9443/mutate-apps-emqx-io-v2beta1-emqx" - op: "remove" path: "/webhooks/3/clientConfig/service" - op: "add" @@ -286,7 +286,7 @@ patches: - op: "add" path: "/webhooks/4/clientConfig/url" - value: "https://host.docker.internal:9443/validate-apps-emqx-io-v2alpha2-emqx" + value: "https://host.docker.internal:9443/validate-apps-emqx-io-v2beta1-emqx" - op: "remove" path: "/webhooks/4/clientConfig/service" - op: "add" diff --git a/config/samples/emqx/v2alpha2/emqx-full.yaml b/config/samples/emqx/v2beta1/emqx-full.yaml similarity index 99% rename from config/samples/emqx/v2alpha2/emqx-full.yaml rename to config/samples/emqx/v2beta1/emqx-full.yaml index d47c5b489..14ea5ac4a 100644 --- a/config/samples/emqx/v2alpha2/emqx-full.yaml +++ b/config/samples/emqx/v2beta1/emqx-full.yaml @@ -1,4 +1,4 @@ -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/config/samples/emqx/v2alpha2/emqx-slim.yaml b/config/samples/emqx/v2beta1/emqx-slim.yaml similarity index 63% rename from config/samples/emqx/v2alpha2/emqx-slim.yaml rename to config/samples/emqx/v2beta1/emqx-slim.yaml index c4abb44ba..7912fef1e 100644 --- a/config/samples/emqx/v2alpha2/emqx-slim.yaml +++ b/config/samples/emqx/v2beta1/emqx-slim.yaml @@ -1,4 +1,4 @@ -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/config/samples/emqx/v2alpha2/rebalance.yaml b/config/samples/emqx/v2beta1/rebalance.yaml similarity index 89% rename from config/samples/emqx/v2alpha2/rebalance.yaml rename to config/samples/emqx/v2beta1/rebalance.yaml index fa53a3d5d..3a2a0fcd3 100644 --- a/config/samples/emqx/v2alpha2/rebalance.yaml +++ b/config/samples/emqx/v2beta1/rebalance.yaml @@ -1,4 +1,4 @@ -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: Rebalance metadata: name: rebalance-sample diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 3c87433f2..787bf69fb 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -12,14 +12,14 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-apps-emqx-io-v2alpha2-emqx + path: /mutate-apps-emqx-io-v2beta1-emqx failurePolicy: Fail name: mutating.apps.emqx.io rules: - apiGroups: - apps.emqx.io apiVersions: - - v2alpha2 + - v2beta1 operations: - CREATE - UPDATE @@ -103,14 +103,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-apps-emqx-io-v2alpha2-emqx + path: /validate-apps-emqx-io-v2beta1-emqx failurePolicy: Fail name: validator.apps.emqx.io rules: - apiGroups: - apps.emqx.io apiVersions: - - v2alpha2 + - v2beta1 operations: - CREATE - UPDATE @@ -124,14 +124,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-apps-emqx-io-v2alpha2-rebalance + path: /validate-apps-emqx-io-v2beta1-rebalance failurePolicy: Fail name: validator.rebalance.emqx.io rules: - apiGroups: - apps.emqx.io apiVersions: - - v2alpha2 + - v2beta1 operations: - CREATE - UPDATE diff --git a/controllers/apps/v2alpha2/add_bootstrap_resource.go b/controllers/apps/v2beta1/add_bootstrap_resource.go similarity index 84% rename from controllers/apps/v2alpha2/add_bootstrap_resource.go rename to controllers/apps/v2beta1/add_bootstrap_resource.go index 6fbf1d44a..2aaf3eee8 100644 --- a/controllers/apps/v2alpha2/add_bootstrap_resource.go +++ b/controllers/apps/v2beta1/add_bootstrap_resource.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -10,7 +10,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" "github.com/rory-z/go-hocon" "github.com/sethvargo/go-password/password" @@ -20,7 +20,7 @@ type addBootstrap struct { *EMQXReconciler } -func (a *addBootstrap) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ innerReq.RequesterInterface) subResult { +func (a *addBootstrap) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ innerReq.RequesterInterface) subResult { for _, resource := range []client.Object{ generateNodeCookieSecret(instance), generateBootstrapAPIKeySecret(instance), @@ -38,7 +38,7 @@ func (a *addBootstrap) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ return subResult{} } -func generateNodeCookieSecret(instance *appsv2alpha2.EMQX) *corev1.Secret { +func generateNodeCookieSecret(instance *appsv2beta1.EMQX) *corev1.Secret { var cookie string config, _ := hocon.ParseString(instance.Spec.Config.Data) @@ -63,14 +63,14 @@ func generateNodeCookieSecret(instance *appsv2alpha2.EMQX) *corev1.Secret { } } -func generateBootstrapAPIKeySecret(instance *appsv2alpha2.EMQX) *corev1.Secret { +func generateBootstrapAPIKeySecret(instance *appsv2beta1.EMQX) *corev1.Secret { bootstrapAPIKeys := "" for _, apiKey := range instance.Spec.BootstrapAPIKeys { bootstrapAPIKeys += apiKey.Key + ":" + apiKey.Secret + "\n" } defPassword, _ := password.Generate(64, 10, 0, true, true) - bootstrapAPIKeys += appsv2alpha2.DefaultBootstrapAPIKey + ":" + defPassword + bootstrapAPIKeys += appsv2beta1.DefaultBootstrapAPIKey + ":" + defPassword return &corev1.Secret{ TypeMeta: metav1.TypeMeta{ diff --git a/controllers/apps/v2alpha2/add_bootstrap_resource_test.go b/controllers/apps/v2beta1/add_bootstrap_resource_test.go similarity index 80% rename from controllers/apps/v2alpha2/add_bootstrap_resource_test.go rename to controllers/apps/v2beta1/add_bootstrap_resource_test.go index 39da99b6a..2781bebf6 100644 --- a/controllers/apps/v2alpha2/add_bootstrap_resource_test.go +++ b/controllers/apps/v2beta1/add_bootstrap_resource_test.go @@ -1,16 +1,16 @@ -package v2alpha2 +package v2beta1 import ( "strings" "testing" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestGenerateNodeCookieSecret(t *testing.T) { - instance := &appsv2alpha2.EMQX{ + instance := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", Namespace: "emqx", @@ -35,13 +35,13 @@ func TestGenerateNodeCookieSecret(t *testing.T) { } func TestGenerateBootstrapAPIKeySecret(t *testing.T) { - instance := &appsv2alpha2.EMQX{ + instance := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", Namespace: "emqx", }, - Spec: appsv2alpha2.EMQXSpec{ - BootstrapAPIKeys: []appsv2alpha2.BootstrapAPIKey{ + Spec: appsv2beta1.EMQXSpec{ + BootstrapAPIKeys: []appsv2beta1.BootstrapAPIKey{ { Key: "test_key", Secret: "secret", @@ -60,5 +60,5 @@ func TestGenerateBootstrapAPIKeySecret(t *testing.T) { for _, user := range users { usernames = append(usernames, user[:strings.Index(user, ":")]) } - assert.ElementsMatch(t, usernames, []string{appsv2alpha2.DefaultBootstrapAPIKey, "test_key"}) + assert.ElementsMatch(t, usernames, []string{appsv2beta1.DefaultBootstrapAPIKey, "test_key"}) } diff --git a/controllers/apps/v2alpha2/add_emqx_core.go b/controllers/apps/v2beta1/add_emqx_core.go similarity index 87% rename from controllers/apps/v2alpha2/add_emqx_core.go rename to controllers/apps/v2beta1/add_emqx_core.go index 5825abb10..ea1f000b0 100644 --- a/controllers/apps/v2alpha2/add_emqx_core.go +++ b/controllers/apps/v2beta1/add_emqx_core.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -7,7 +7,7 @@ import ( emperror "emperror.dev/errors" "github.com/cisco-open/k8s-objectmatcher/patch" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -23,7 +23,7 @@ type addCore struct { *EMQXReconciler } -func (a *addCore) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ innerReq.RequesterInterface) subResult { +func (a *addCore) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ innerReq.RequesterInterface) subResult { preSts := a.getNewStatefulSet(ctx, instance) if preSts.UID == "" { _ = ctrl.SetControllerReference(instance, preSts, a.Scheme) @@ -39,15 +39,15 @@ func (a *addCore) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ return subResult{err: emperror.Wrap(err, "failed to create statefulSet")} } instance.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.CoreNodesProgressing, + Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue, Reason: "CreateNewStatefulSet", Message: "Create new statefulSet", }) - instance.Status.RemoveCondition(appsv2alpha2.Ready) - instance.Status.RemoveCondition(appsv2alpha2.Available) - instance.Status.RemoveCondition(appsv2alpha2.CoreNodesReady) - instance.Status.CoreNodesStatus.UpdateRevision = preSts.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.RemoveCondition(appsv2beta1.Ready) + instance.Status.RemoveCondition(appsv2beta1.Available) + instance.Status.RemoveCondition(appsv2beta1.CoreNodesReady) + instance.Status.CoreNodesStatus.UpdateRevision = preSts.Labels[appsv2beta1.PodTemplateHashLabelKey] _ = a.Client.Status().Update(ctx, instance) } else { storageSts := &appsv1.StatefulSet{} @@ -65,14 +65,14 @@ func (a *addCore) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ } instance.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.CoreNodesProgressing, + Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue, Reason: "CreateNewStatefulSet", Message: "Create new statefulSet", }) - instance.Status.RemoveCondition(appsv2alpha2.Ready) - instance.Status.RemoveCondition(appsv2alpha2.Available) - instance.Status.RemoveCondition(appsv2alpha2.CoreNodesReady) + instance.Status.RemoveCondition(appsv2beta1.Ready) + instance.Status.RemoveCondition(appsv2beta1.Available) + instance.Status.RemoveCondition(appsv2beta1.CoreNodesReady) _ = a.Client.Status().Update(ctx, instance) } } @@ -80,13 +80,13 @@ func (a *addCore) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ return subResult{} } -func (a *addCore) getNewStatefulSet(ctx context.Context, instance *appsv2alpha2.EMQX) *appsv1.StatefulSet { +func (a *addCore) getNewStatefulSet(ctx context.Context, instance *appsv2beta1.EMQX) *appsv1.StatefulSet { preSts := generateStatefulSet(instance) podTemplateSpecHash := computeHash(preSts.Spec.Template.DeepCopy(), instance.Status.CoreNodesStatus.CollisionCount) preSts.Name = preSts.Name + "-" + podTemplateSpecHash - preSts.Labels = appsv2alpha2.CloneAndAddLabel(preSts.Labels, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) - preSts.Spec.Template.Labels = appsv2alpha2.CloneAndAddLabel(preSts.Spec.Template.Labels, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) - preSts.Spec.Selector = appsv2alpha2.CloneSelectorAndAddLabel(preSts.Spec.Selector, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) + preSts.Labels = appsv2beta1.CloneAndAddLabel(preSts.Labels, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) + preSts.Spec.Template.Labels = appsv2beta1.CloneAndAddLabel(preSts.Spec.Template.Labels, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) + preSts.Spec.Selector = appsv2beta1.CloneSelectorAndAddLabel(preSts.Spec.Selector, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) updateSts, _, _ := getStateFulSetList(ctx, a.Client, instance) if updateSts == nil { @@ -110,7 +110,7 @@ func (a *addCore) getNewStatefulSet(ctx context.Context, instance *appsv2alpha2. return preSts } -func generateStatefulSet(instance *appsv2alpha2.EMQX) *appsv1.StatefulSet { +func generateStatefulSet(instance *appsv2beta1.EMQX) *appsv1.StatefulSet { sts := &appsv1.StatefulSet{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps/v1", @@ -136,7 +136,7 @@ func generateStatefulSet(instance *appsv2alpha2.EMQX) *appsv1.StatefulSet { Spec: corev1.PodSpec{ ReadinessGates: []corev1.PodReadinessGate{ { - ConditionType: appsv2alpha2.PodOnServing, + ConditionType: appsv2beta1.PodOnServing, }, }, ImagePullSecrets: instance.Spec.ImagePullSecrets, @@ -149,7 +149,7 @@ func generateStatefulSet(instance *appsv2alpha2.EMQX) *appsv1.StatefulSet { InitContainers: instance.Spec.CoreTemplate.Spec.InitContainers, Containers: append([]corev1.Container{ { - Name: appsv2alpha2.DefaultContainerName, + Name: appsv2beta1.DefaultContainerName, Image: instance.Spec.Image, ImagePullPolicy: corev1.PullPolicy(instance.Spec.ImagePullPolicy), Command: instance.Spec.CoreTemplate.Spec.Command, diff --git a/controllers/apps/v2alpha2/add_emqx_core_suite_test.go b/controllers/apps/v2beta1/add_emqx_core_suite_test.go similarity index 73% rename from controllers/apps/v2alpha2/add_emqx_core_suite_test.go rename to controllers/apps/v2beta1/add_emqx_core_suite_test.go index 6aeca6477..8572492f2 100644 --- a/controllers/apps/v2alpha2/add_emqx_core_suite_test.go +++ b/controllers/apps/v2beta1/add_emqx_core_suite_test.go @@ -1,10 +1,10 @@ -package v2alpha2 +package v2beta1 import ( "context" "time" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -19,14 +19,14 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { var a *addCore var ns *corev1.Namespace = &corev1.Namespace{} - var instance *appsv2alpha2.EMQX = new(appsv2alpha2.EMQX) + var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX) BeforeEach(func() { a = &addCore{emqxReconciler} ns = &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ - Name: "controller-v2alpha2-add-emqx-core-test", + Name: "controller-v2beta1-add-emqx-core-test", Labels: map[string]string{ "test": "e2e", }, @@ -37,12 +37,12 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { instance.Namespace = ns.Name instance.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Ready, + Type: appsv2beta1.Ready, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, { - Type: appsv2alpha2.CoreNodesReady, + Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, @@ -81,7 +81,7 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { sts.Status.Replicas = 2 Expect(k8sClient.Status().Update(ctx, sts)).Should(Succeed()) - instance.Status.CoreNodesStatus.UpdateRevision = sts.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.CoreNodesStatus.UpdateRevision = sts.Labels[appsv2beta1.PodTemplateHashLabelKey] instance.Spec.CoreTemplate.Spec.Replicas = pointer.Int32(4) }) @@ -98,14 +98,14 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { WithTransform(func(s appsv1.StatefulSet) int32 { return *s.Spec.Replicas }, Equal(*instance.Spec.CoreTemplate.Spec.Replicas)), )) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(ctx, client.ObjectKeyFromObject(instance), instance) return instance }).Should(And( - WithTransform(func(emqx *appsv2alpha2.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2alpha2.CoreNodesProgressing)), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Ready) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Available) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.CoreNodesReady) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2beta1.CoreNodesProgressing)), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Ready) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Available) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.CoreNodesReady) }, BeFalse()), )) }) }) @@ -130,14 +130,14 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { WithTransform(func(s appsv1.StatefulSet) string { return s.Spec.Template.Spec.Containers[0].Image }, Equal(instance.Spec.Image)), )) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(ctx, client.ObjectKeyFromObject(instance), instance) return instance }).Should(And( - WithTransform(func(emqx *appsv2alpha2.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2alpha2.CoreNodesProgressing)), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Ready) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Available) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.CoreNodesReady) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2beta1.CoreNodesProgressing)), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Ready) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Available) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.CoreNodesReady) }, BeFalse()), )) }) }) diff --git a/controllers/apps/v2alpha2/add_emqx_core_test.go b/controllers/apps/v2beta1/add_emqx_core_test.go similarity index 97% rename from controllers/apps/v2alpha2/add_emqx_core_test.go rename to controllers/apps/v2beta1/add_emqx_core_test.go index 58230769f..7b59c9aec 100644 --- a/controllers/apps/v2alpha2/add_emqx_core_test.go +++ b/controllers/apps/v2beta1/add_emqx_core_test.go @@ -1,9 +1,9 @@ -package v2alpha2 +package v2beta1 import ( "testing" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -14,18 +14,18 @@ import ( ) var coreLabels = map[string]string{ - appsv2alpha2.InstanceNameLabelKey: "emqx", - appsv2alpha2.ManagerByLabelKey: "emqx-operator", - appsv2alpha2.DBRoleLabelKey: "core", + appsv2beta1.InstanceNameLabelKey: "emqx", + appsv2beta1.ManagerByLabelKey: "emqx-operator", + appsv2beta1.DBRoleLabelKey: "core", } func TestGenerateStatefulSet(t *testing.T) { - instance := &appsv2alpha2.EMQX{ + instance := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", Namespace: "emqx", }, - Spec: appsv2alpha2.EMQXSpec{ + Spec: appsv2beta1.EMQXSpec{ Image: "emqx/emqx:5.1", ClusterDomain: "cluster.local", }, diff --git a/controllers/apps/v2alpha2/add_emqx_repl.go b/controllers/apps/v2beta1/add_emqx_repl.go similarity index 86% rename from controllers/apps/v2alpha2/add_emqx_repl.go rename to controllers/apps/v2beta1/add_emqx_repl.go index 24ef2fda3..8fd1bb54c 100644 --- a/controllers/apps/v2alpha2/add_emqx_repl.go +++ b/controllers/apps/v2beta1/add_emqx_repl.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -6,7 +6,7 @@ import ( emperror "emperror.dev/errors" "github.com/cisco-open/k8s-objectmatcher/patch" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -22,11 +22,11 @@ type addRepl struct { *EMQXReconciler } -func (a *addRepl) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ innerReq.RequesterInterface) subResult { +func (a *addRepl) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ innerReq.RequesterInterface) subResult { if instance.Spec.ReplicantTemplate == nil { return subResult{} } - if !instance.Status.IsConditionTrue(appsv2alpha2.CoreNodesReady) { + if !instance.Status.IsConditionTrue(appsv2beta1.CoreNodesReady) { return subResult{} } @@ -45,15 +45,15 @@ func (a *addRepl) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ return subResult{err: emperror.Wrap(err, "failed to create replicaSet")} } instance.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, Reason: "CreateNewReplicaSet", Message: "Create new replicaSet", }) - instance.Status.RemoveCondition(appsv2alpha2.Ready) - instance.Status.RemoveCondition(appsv2alpha2.Available) - instance.Status.RemoveCondition(appsv2alpha2.ReplicantNodesReady) - instance.Status.ReplicantNodesStatus.UpdateRevision = preRs.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.RemoveCondition(appsv2beta1.Ready) + instance.Status.RemoveCondition(appsv2beta1.Available) + instance.Status.RemoveCondition(appsv2beta1.ReplicantNodesReady) + instance.Status.ReplicantNodesStatus.UpdateRevision = preRs.Labels[appsv2beta1.PodTemplateHashLabelKey] _ = a.Client.Status().Update(ctx, instance) } else { storageRs := &appsv1.ReplicaSet{} @@ -71,14 +71,14 @@ func (a *addRepl) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ } instance.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, Reason: "CreateNewReplicaSet", Message: "Create new replicaSet", }) - instance.Status.RemoveCondition(appsv2alpha2.Ready) - instance.Status.RemoveCondition(appsv2alpha2.Available) - instance.Status.RemoveCondition(appsv2alpha2.ReplicantNodesReady) + instance.Status.RemoveCondition(appsv2beta1.Ready) + instance.Status.RemoveCondition(appsv2beta1.Available) + instance.Status.RemoveCondition(appsv2beta1.ReplicantNodesReady) _ = a.Client.Status().Update(ctx, instance) } } @@ -86,13 +86,13 @@ func (a *addRepl) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ return subResult{} } -func (a *addRepl) getNewReplicaSet(ctx context.Context, instance *appsv2alpha2.EMQX) *appsv1.ReplicaSet { +func (a *addRepl) getNewReplicaSet(ctx context.Context, instance *appsv2beta1.EMQX) *appsv1.ReplicaSet { preRs := generateReplicaSet(instance) podTemplateSpecHash := computeHash(preRs.Spec.Template.DeepCopy(), instance.Status.ReplicantNodesStatus.CollisionCount) preRs.Name = preRs.Name + "-" + podTemplateSpecHash - preRs.Labels = appsv2alpha2.CloneAndAddLabel(preRs.Labels, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) - preRs.Spec.Template.Labels = appsv2alpha2.CloneAndAddLabel(preRs.Spec.Template.Labels, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) - preRs.Spec.Selector = appsv2alpha2.CloneSelectorAndAddLabel(preRs.Spec.Selector, appsv2alpha2.PodTemplateHashLabelKey, podTemplateSpecHash) + preRs.Labels = appsv2beta1.CloneAndAddLabel(preRs.Labels, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) + preRs.Spec.Template.Labels = appsv2beta1.CloneAndAddLabel(preRs.Spec.Template.Labels, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) + preRs.Spec.Selector = appsv2beta1.CloneSelectorAndAddLabel(preRs.Spec.Selector, appsv2beta1.PodTemplateHashLabelKey, podTemplateSpecHash) updateRs, _, _ := getReplicaSetList(ctx, a.Client, instance) if updateRs == nil { @@ -116,7 +116,7 @@ func (a *addRepl) getNewReplicaSet(ctx context.Context, instance *appsv2alpha2.E return preRs } -func generateReplicaSet(instance *appsv2alpha2.EMQX) *appsv1.ReplicaSet { +func generateReplicaSet(instance *appsv2beta1.EMQX) *appsv1.ReplicaSet { return &appsv1.ReplicaSet{ TypeMeta: metav1.TypeMeta{ Kind: "ReplicaSet", @@ -140,7 +140,7 @@ func generateReplicaSet(instance *appsv2alpha2.EMQX) *appsv1.ReplicaSet { Spec: corev1.PodSpec{ ReadinessGates: []corev1.PodReadinessGate{ { - ConditionType: appsv2alpha2.PodOnServing, + ConditionType: appsv2beta1.PodOnServing, }, }, ImagePullSecrets: instance.Spec.ImagePullSecrets, @@ -153,7 +153,7 @@ func generateReplicaSet(instance *appsv2alpha2.EMQX) *appsv1.ReplicaSet { InitContainers: instance.Spec.ReplicantTemplate.Spec.InitContainers, Containers: append([]corev1.Container{ { - Name: appsv2alpha2.DefaultContainerName, + Name: appsv2beta1.DefaultContainerName, Image: instance.Spec.Image, ImagePullPolicy: instance.Spec.ImagePullPolicy, Command: instance.Spec.ReplicantTemplate.Spec.Command, diff --git a/controllers/apps/v2alpha2/add_emqx_repl_suite_test.go b/controllers/apps/v2beta1/add_emqx_repl_suite_test.go similarity index 77% rename from controllers/apps/v2alpha2/add_emqx_repl_suite_test.go rename to controllers/apps/v2beta1/add_emqx_repl_suite_test.go index 72c12e2d7..4ba753874 100644 --- a/controllers/apps/v2alpha2/add_emqx_repl_suite_test.go +++ b/controllers/apps/v2beta1/add_emqx_repl_suite_test.go @@ -1,10 +1,10 @@ -package v2alpha2 +package v2beta1 import ( "context" "time" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,7 +17,7 @@ import ( var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { var a *addRepl - var instance *appsv2alpha2.EMQX = new(appsv2alpha2.EMQX) + var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX) var ns *corev1.Namespace = &corev1.Namespace{} BeforeEach(func() { @@ -25,7 +25,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { ns = &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ - Name: "controller-v2alpha2-add-emqx-repl-test", + Name: "controller-v2beta1-add-emqx-repl-test", Labels: map[string]string{ "test": "e2e", }, @@ -34,23 +34,23 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { instance = emqx.DeepCopy() instance.Namespace = ns.Name - instance.Spec.ReplicantTemplate = &appsv2alpha2.EMQXReplicantTemplate{ - Spec: appsv2alpha2.EMQXReplicantTemplateSpec{ + instance.Spec.ReplicantTemplate = &appsv2beta1.EMQXReplicantTemplate{ + Spec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32(3), }, } - instance.Status = appsv2alpha2.EMQXStatus{ - ReplicantNodesStatus: &appsv2alpha2.EMQXNodesStatus{ + instance.Status = appsv2beta1.EMQXStatus{ + ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{ Replicas: 3, }, Conditions: []metav1.Condition{ { - Type: appsv2alpha2.Ready, + Type: appsv2beta1.Ready, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, { - Type: appsv2alpha2.CoreNodesReady, + Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, @@ -83,7 +83,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { Context("core nodes is not ready", func() { JustBeforeEach(func() { - instance.Status.RemoveCondition(appsv2alpha2.CoreNodesReady) + instance.Status.RemoveCondition(appsv2beta1.CoreNodesReady) }) It("should do nothing", func() { @@ -129,7 +129,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { rs.Status.Replicas = 3 Expect(k8sClient.Status().Update(ctx, rs)).Should(Succeed()) - instance.Status.ReplicantNodesStatus.UpdateRevision = rs.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.ReplicantNodesStatus.UpdateRevision = rs.Labels[appsv2beta1.PodTemplateHashLabelKey] instance.Spec.ReplicantTemplate.Spec.Replicas = pointer.Int32(0) }) @@ -158,7 +158,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { ) return list.Items }).Should(HaveLen(1)) - instance.Status.ReplicantNodesStatus.UpdateRevision = list.Items[0].Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.ReplicantNodesStatus.UpdateRevision = list.Items[0].Labels[appsv2beta1.PodTemplateHashLabelKey] instance.Spec.ReplicantTemplate.Spec.Replicas = pointer.Int32(4) }) @@ -176,15 +176,15 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { WithTransform(func(rs appsv1.ReplicaSet) int32 { return *rs.Spec.Replicas }, Equal(*instance.Spec.ReplicantTemplate.Spec.Replicas)), )) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(ctx, client.ObjectKeyFromObject(instance), instance) return instance }).Should(And( - WithTransform(func(emqx *appsv2alpha2.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2alpha2.ReplicantNodesProgressing)), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Ready) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Available) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { - return emqx.Status.IsConditionTrue(appsv2alpha2.ReplicantNodesReady) + WithTransform(func(emqx *appsv2beta1.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2beta1.ReplicantNodesProgressing)), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Ready) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Available) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { + return emqx.Status.IsConditionTrue(appsv2beta1.ReplicantNodesReady) }, BeFalse()), )) }) @@ -210,15 +210,15 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { WithTransform(func(rs appsv1.ReplicaSet) string { return rs.Spec.Template.Spec.Containers[0].Image }, Equal(instance.Spec.Image)), )) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(ctx, client.ObjectKeyFromObject(instance), instance) return instance }).Should(And( - WithTransform(func(emqx *appsv2alpha2.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2alpha2.ReplicantNodesProgressing)), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Ready) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2alpha2.Available) }, BeFalse()), - WithTransform(func(emqx *appsv2alpha2.EMQX) bool { - return emqx.Status.IsConditionTrue(appsv2alpha2.ReplicantNodesReady) + WithTransform(func(emqx *appsv2beta1.EMQX) string { return emqx.Status.GetLastTrueCondition().Type }, Equal(appsv2beta1.ReplicantNodesProgressing)), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Ready) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { return emqx.Status.IsConditionTrue(appsv2beta1.Available) }, BeFalse()), + WithTransform(func(emqx *appsv2beta1.EMQX) bool { + return emqx.Status.IsConditionTrue(appsv2beta1.ReplicantNodesReady) }, BeFalse()), )) }) diff --git a/controllers/apps/v2alpha2/add_svc.go b/controllers/apps/v2beta1/add_svc.go similarity index 85% rename from controllers/apps/v2alpha2/add_svc.go rename to controllers/apps/v2beta1/add_svc.go index df62a5a01..4769081b8 100644 --- a/controllers/apps/v2alpha2/add_svc.go +++ b/controllers/apps/v2beta1/add_svc.go @@ -1,10 +1,10 @@ -package v2alpha2 +package v2beta1 import ( "context" emperror "emperror.dev/errors" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,7 +17,7 @@ type addSvc struct { *EMQXReconciler } -func (a *addSvc) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ innerReq.RequesterInterface) subResult { +func (a *addSvc) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, _ innerReq.RequesterInterface) subResult { resources := []client.Object{ generateHeadlessService(instance), generateDashboardService(instance), @@ -31,7 +31,7 @@ func (a *addSvc) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ i return subResult{err: emperror.Wrap(err, "failed to get configmap")} } - ports, err := appsv2alpha2.GetListenersServicePorts(configMap.Data["emqx.conf"]) + ports, err := appsv2beta1.GetListenersServicePorts(configMap.Data["emqx.conf"]) if err != nil { return subResult{err: emperror.Wrap(err, "failed to get listeners service ports")} } @@ -48,7 +48,7 @@ func (a *addSvc) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, _ i return subResult{} } -func generateHeadlessService(instance *appsv2alpha2.EMQX) *corev1.Service { +func generateHeadlessService(instance *appsv2beta1.EMQX) *corev1.Service { headlessSvc := &corev1.Service{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", @@ -84,7 +84,7 @@ func generateHeadlessService(instance *appsv2alpha2.EMQX) *corev1.Service { return headlessSvc } -func generateDashboardService(instance *appsv2alpha2.EMQX) *corev1.Service { +func generateDashboardService(instance *appsv2beta1.EMQX) *corev1.Service { return &corev1.Service{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", @@ -100,9 +100,9 @@ func generateDashboardService(instance *appsv2alpha2.EMQX) *corev1.Service { } } -func generateListenerService(instance *appsv2alpha2.EMQX, ports []corev1.ServicePort) *corev1.Service { +func generateListenerService(instance *appsv2beta1.EMQX, ports []corev1.ServicePort) *corev1.Service { listener := instance.Spec.ListenersServiceTemplate.DeepCopy() - listener.Spec.Ports = appsv2alpha2.MergeServicePorts( + listener.Spec.Ports = appsv2beta1.MergeServicePorts( listener.Spec.Ports, ports, ) diff --git a/controllers/apps/v2alpha2/add_svc_test.go b/controllers/apps/v2beta1/add_svc_test.go similarity index 86% rename from controllers/apps/v2alpha2/add_svc_test.go rename to controllers/apps/v2beta1/add_svc_test.go index ed8b6e84d..2b383272e 100644 --- a/controllers/apps/v2alpha2/add_svc_test.go +++ b/controllers/apps/v2beta1/add_svc_test.go @@ -1,9 +1,9 @@ -package v2alpha2 +package v2beta1 import ( "testing" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -11,13 +11,13 @@ import ( ) func TestGenerateHeadlessSVC(t *testing.T) { - instance := &appsv2alpha2.EMQX{ + instance := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", Namespace: "emqx", }, - Spec: appsv2alpha2.EMQXSpec{ - CoreTemplate: appsv2alpha2.EMQXCoreTemplate{ + Spec: appsv2beta1.EMQXSpec{ + CoreTemplate: appsv2beta1.EMQXCoreTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: coreLabels, }, @@ -61,13 +61,13 @@ func TestGenerateHeadlessSVC(t *testing.T) { } func TestGenerateDashboardService(t *testing.T) { - instance := &appsv2alpha2.EMQX{ + instance := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", Namespace: "emqx", }, - Spec: appsv2alpha2.EMQXSpec{ - CoreTemplate: appsv2alpha2.EMQXCoreTemplate{ + Spec: appsv2beta1.EMQXSpec{ + CoreTemplate: appsv2beta1.EMQXCoreTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: coreLabels, }, @@ -76,7 +76,7 @@ func TestGenerateDashboardService(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "emqx-dashboard", Labels: map[string]string{ - appsv2alpha2.InstanceNameLabelKey: "emqx", + appsv2beta1.InstanceNameLabelKey: "emqx", }, Annotations: map[string]string{ "foo": "bar", @@ -106,7 +106,7 @@ func TestGenerateDashboardService(t *testing.T) { Name: "emqx-dashboard", Namespace: "emqx", Labels: map[string]string{ - appsv2alpha2.InstanceNameLabelKey: "emqx", + appsv2beta1.InstanceNameLabelKey: "emqx", }, Annotations: map[string]string{ "foo": "bar", diff --git a/controllers/apps/v2alpha2/emqx_controller.go b/controllers/apps/v2beta1/emqx_controller.go similarity index 89% rename from controllers/apps/v2alpha2/emqx_controller.go rename to controllers/apps/v2beta1/emqx_controller.go index f7f7d32c5..25b0e0c28 100644 --- a/controllers/apps/v2alpha2/emqx_controller.go +++ b/controllers/apps/v2beta1/emqx_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "context" @@ -39,7 +39,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/predicate" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/emqx/emqx-operator/internal/handler" k8sErrors "k8s.io/apimachinery/pkg/api/errors" ) @@ -51,7 +51,7 @@ type subResult struct { } type subReconciler interface { - reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) subResult + reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult } // EMQXReconciler reconciles a EMQX object @@ -89,7 +89,7 @@ func NewEMQXReconciler(mgr manager.Manager) *EMQXReconciler { func (r *EMQXReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { _ = log.FromContext(ctx) - instance := &appsv2alpha2.EMQX{} + instance := &appsv2beta1.EMQX{} if err := r.Client.Get(ctx, req.NamespacedName, instance); err != nil { if k8sErrors.IsNotFound(err) { return ctrl.Result{}, nil @@ -135,7 +135,7 @@ func (r *EMQXReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. } } - if !instance.Status.IsConditionTrue(appsv2alpha2.Ready) { + if !instance.Status.IsConditionTrue(appsv2beta1.Ready) { return ctrl.Result{RequeueAfter: time.Second}, nil } return ctrl.Result{RequeueAfter: time.Duration(30) * time.Second}, nil @@ -144,7 +144,7 @@ func (r *EMQXReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. // SetupWithManager sets up the controller with the Manager. func (r *EMQXReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&appsv2alpha2.EMQX{}). + For(&appsv2beta1.EMQX{}). WithEventFilter(predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { // Ignore updates to CR status in which case metadata.Generation does not change @@ -154,14 +154,14 @@ func (r *EMQXReconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -func newRequester(k8sClient client.Client, instance *appsv2alpha2.EMQX) (innerReq.RequesterInterface, error) { +func newRequester(k8sClient client.Client, instance *appsv2beta1.EMQX) (innerReq.RequesterInterface, error) { username, password, err := getBootstrapAPIKey(context.Background(), k8sClient, instance) if err != nil { return nil, err } var port string - dashboardPort, err := appsv2alpha2.GetDashboardServicePort(instance.Spec.Config.Data) + dashboardPort, err := appsv2beta1.GetDashboardServicePort(instance.Spec.Config.Data) if err != nil || dashboardPort == nil { port = "18083" } @@ -172,9 +172,9 @@ func newRequester(k8sClient client.Client, instance *appsv2alpha2.EMQX) (innerRe labels := instance.Spec.CoreTemplate.Labels if instance.Status.CoreNodesStatus.CurrentRevision != "" { - labels = appsv2alpha2.CloneAndAddLabel( + labels = appsv2beta1.CloneAndAddLabel( labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision, ) } @@ -201,7 +201,7 @@ func newRequester(k8sClient client.Client, instance *appsv2alpha2.EMQX) (innerRe return nil, nil } -func getBootstrapAPIKey(ctx context.Context, client client.Client, instance *appsv2alpha2.EMQX) (username, password string, err error) { +func getBootstrapAPIKey(ctx context.Context, client client.Client, instance *appsv2beta1.EMQX) (username, password string, err error) { bootstrapAPIKey := &corev1.Secret{} if err = client.Get(ctx, types.NamespacedName{ Namespace: instance.GetNamespace(), @@ -215,7 +215,7 @@ func getBootstrapAPIKey(ctx context.Context, client client.Client, instance *app users := strings.Split(string(data), "\n") for _, user := range users { index := strings.Index(user, ":") - if index > 0 && user[:index] == appsv2alpha2.DefaultBootstrapAPIKey { + if index > 0 && user[:index] == appsv2beta1.DefaultBootstrapAPIKey { username = user[:index] password = user[index+1:] return diff --git a/controllers/apps/v2alpha2/rebalance_controller.go b/controllers/apps/v2beta1/rebalance_controller.go similarity index 83% rename from controllers/apps/v2alpha2/rebalance_controller.go rename to controllers/apps/v2beta1/rebalance_controller.go index cdb9c9d69..8e10255ca 100644 --- a/controllers/apps/v2alpha2/rebalance_controller.go +++ b/controllers/apps/v2beta1/rebalance_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "context" @@ -36,10 +36,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" appsv1beta4 "github.com/emqx/emqx-operator/apis/apps/v1beta4" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" controllerv1beta4 "github.com/emqx/emqx-operator/controllers/apps/v1beta4" - // controllerv2alpha2 "github.com/emqx/emqx-operator/controllers/apps/v2alpha2" + // controllerv2beta1 "github.com/emqx/emqx-operator/controllers/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" "github.com/tidwall/gjson" ) @@ -89,7 +89,7 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( logger := log.FromContext(ctx) logger.V(1).Info("Reconcile rebalance") - rebalance := &appsv2alpha2.Rebalance{} + rebalance := &appsv2beta1.Rebalance{} if err := r.Client.Get(ctx, req.NamespacedName, rebalance); err != nil { if k8sErrors.IsNotFound(err) { return ctrl.Result{}, nil @@ -97,7 +97,7 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return ctrl.Result{}, err } - // check instanceKind is v1beta4 or v2alpha2 + // check instanceKind is v1beta4 or v2beta1 if rebalance.Spec.InstanceKind == "EmqxEnterprise" { emqx := &appsv1beta4.EmqxEnterprise{} if err := r.Client.Get(ctx, client.ObjectKey{ @@ -111,8 +111,8 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( controllerutil.RemoveFinalizer(rebalance, finalizer) return ctrl.Result{}, r.Client.Update(ctx, rebalance) } - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("EMQX Enterprise %s is not found", rebalance.Spec.InstanceName), }) @@ -120,8 +120,8 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } if !emqx.Status.IsConditionTrue(appsv1beta4.ConditionRunning) { - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("EMQX Enterprise %s is not ready", rebalance.Spec.InstanceName), }) @@ -134,7 +134,7 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } targetEMQX = emqx } else { - emqx := &appsv2alpha2.EMQX{} + emqx := &appsv2beta1.EMQX{} if err := r.Client.Get(ctx, client.ObjectKey{ Name: rebalance.Spec.InstanceName, Namespace: rebalance.Namespace, @@ -146,8 +146,8 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( controllerutil.RemoveFinalizer(rebalance, finalizer) return ctrl.Result{}, r.Client.Update(ctx, rebalance) } - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("EMQX %s is not found", rebalance.Spec.InstanceName), }) @@ -155,10 +155,10 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } // check if emqx is ready - if !emqx.Status.IsConditionTrue(appsv2alpha2.Ready) { + if !emqx.Status.IsConditionTrue(appsv2beta1.Ready) { // return ctrl.Result{}, emperror.New("EMQX is not ready") - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("EMQX %s is not ready", rebalance.Spec.InstanceName), }) @@ -178,7 +178,7 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } if !rebalance.DeletionTimestamp.IsZero() { - if rebalance.Status.Phase == appsv2alpha2.RebalancePhaseProcessing { + if rebalance.Status.Phase == appsv2beta1.RebalancePhaseProcessing { _ = stopRebalance(targetEMQX, requester, rebalance) } controllerutil.RemoveFinalizer(rebalance, finalizer) @@ -215,63 +215,63 @@ func (r *RebalanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // SetupWithManager sets up the controller with the Manager. func (r *RebalanceReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&appsv2alpha2.Rebalance{}). + For(&appsv2beta1.Rebalance{}). Complete(r) } // Rebalance Handler -type GetRebalanceStatusFunc func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2alpha2.RebalanceState, error) -type StartRebalanceFunc func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error -type StopRebalanceFunc func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error +type GetRebalanceStatusFunc func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2beta1.RebalanceState, error) +type StartRebalanceFunc func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error +type StopRebalanceFunc func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error -func rebalanceStatusHandler(emqx client.Object, rebalance *appsv2alpha2.Rebalance, requester innerReq.RequesterInterface, +func rebalanceStatusHandler(emqx client.Object, rebalance *appsv2beta1.Rebalance, requester innerReq.RequesterInterface, startFun StartRebalanceFunc, getRebalanceStatusFun GetRebalanceStatusFunc, ) { switch rebalance.Status.Phase { case "": if err := startFun(emqx, requester, rebalance); err != nil { - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("Failed to start rebalance: %v", err.Error()), }) rebalance.Status.RebalanceStates = nil } - _ = rebalance.Status.SetProcessing(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionProcessing, + _ = rebalance.Status.SetProcessing(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionProcessing, Status: corev1.ConditionTrue, }) - case appsv2alpha2.RebalancePhaseProcessing: + case appsv2beta1.RebalancePhaseProcessing: rebalanceStates, err := getRebalanceStatusFun(emqx, requester) if err != nil { - _ = rebalance.Status.SetFailed(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionFailed, + _ = rebalance.Status.SetFailed(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionFailed, Status: corev1.ConditionTrue, Message: fmt.Sprintf("Failed to get rebalance status: %s", err.Error()), }) } if len(rebalanceStates) == 0 { - _ = rebalance.Status.SetCompleted(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionCompleted, + _ = rebalance.Status.SetCompleted(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionCompleted, Status: corev1.ConditionTrue, }) rebalance.Status.RebalanceStates = nil } - _ = rebalance.Status.SetProcessing(appsv2alpha2.RebalanceCondition{ - Type: appsv2alpha2.RebalanceConditionProcessing, + _ = rebalance.Status.SetProcessing(appsv2beta1.RebalanceCondition{ + Type: appsv2beta1.RebalanceConditionProcessing, Status: corev1.ConditionTrue, }) rebalance.Status.RebalanceStates = rebalanceStates - case appsv2alpha2.RebalancePhaseFailed, appsv2alpha2.RebalancePhaseCompleted: + case appsv2beta1.RebalancePhaseFailed, appsv2beta1.RebalancePhaseCompleted: rebalance.Status.RebalanceStates = nil default: panic("unknown rebalance phase") } } -func startRebalance(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error { +func startRebalance(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error { nodes, err := getEmqxNodes(emqx) if err != nil { return err @@ -300,7 +300,7 @@ func startRebalance(emqx client.Object, requester innerReq.RequesterInterface, r return nil } -func getRebalanceStatus(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2alpha2.RebalanceState, error) { +func getRebalanceStatus(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2beta1.RebalanceState, error) { path, err := rebalanceStatusUrl(emqx) if err != nil { return nil, err @@ -313,7 +313,7 @@ func getRebalanceStatus(emqx client.Object, requester innerReq.RequesterInterfac if resp.StatusCode != 200 { return nil, emperror.Errorf("request api failed: %s", resp.Status) } - rebalanceStates := []appsv2alpha2.RebalanceState{} + rebalanceStates := []appsv2beta1.RebalanceState{} data := gjson.GetBytes(body, "rebalances") if err := json.Unmarshal([]byte(data.Raw), &rebalanceStates); err != nil { return nil, emperror.Wrap(err, "failed to unmarshal rebalances") @@ -321,7 +321,7 @@ func getRebalanceStatus(emqx client.Object, requester innerReq.RequesterInterfac return rebalanceStates, nil } -func stopRebalance(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error { +func stopRebalance(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error { // stop rebalance should use coordinatorNode as path parameter path, err := rebalanceStopUrl(emqx, rebalance.Status.RebalanceStates[0].CoordinatorNode) if err != nil { @@ -343,7 +343,7 @@ func stopRebalance(emqx client.Object, requester innerReq.RequesterInterface, re return nil } -func getRequestBytes(rebalance *appsv2alpha2.Rebalance, nodes []string) []byte { +func getRequestBytes(rebalance *appsv2beta1.Rebalance, nodes []string) []byte { body := map[string]interface{}{ "conn_evict_rate": rebalance.Spec.RebalanceStrategy.ConnEvictRate, "sess_evict_rate": rebalance.Spec.RebalanceStrategy.SessEvictRate, @@ -375,7 +375,7 @@ func getEmqxNodes(emqx client.Object) ([]string, error) { for _, node := range e.Status.EmqxNodes { nodes = append(nodes, node.Node) } - } else if e, ok := emqx.(*appsv2alpha2.EMQX); ok { + } else if e, ok := emqx.(*appsv2beta1.EMQX); ok { if len(e.Status.ReplicantNodes) == 0 { for _, node := range e.Status.CoreNodes { nodes = append(nodes, node.Node) @@ -394,7 +394,7 @@ func getEmqxNodes(emqx client.Object) ([]string, error) { func rebalanceStartUrl(emqx client.Object, node string) (string, error) { if _, ok := emqx.(*appsv1beta4.EmqxEnterprise); ok { return fmt.Sprintf("%s/%s/start", ApiRebalanceV4, node), nil - } else if _, ok := emqx.(*appsv2alpha2.EMQX); ok { + } else if _, ok := emqx.(*appsv2beta1.EMQX); ok { return fmt.Sprintf("%s/%s/start", ApiRebalanceV5, node), nil } else { return "", emperror.New("emqx type error") @@ -404,7 +404,7 @@ func rebalanceStartUrl(emqx client.Object, node string) (string, error) { func rebalanceStopUrl(emqx client.Object, node string) (string, error) { if _, ok := emqx.(*appsv1beta4.EmqxEnterprise); ok { return fmt.Sprintf("%s/%s/stop", ApiRebalanceV4, node), nil - } else if _, ok := emqx.(*appsv2alpha2.EMQX); ok { + } else if _, ok := emqx.(*appsv2beta1.EMQX); ok { return fmt.Sprintf("%s/%s/stop", ApiRebalanceV5, node), nil } else { return "", emperror.New("emqx type error") @@ -414,7 +414,7 @@ func rebalanceStopUrl(emqx client.Object, node string) (string, error) { func rebalanceStatusUrl(emqx client.Object) (string, error) { if _, ok := emqx.(*appsv1beta4.EmqxEnterprise); ok { return fmt.Sprintf("%s/global_status", ApiRebalanceV4), nil - } else if _, ok := emqx.(*appsv2alpha2.EMQX); ok { + } else if _, ok := emqx.(*appsv2beta1.EMQX); ok { return fmt.Sprintf("%s/global_status", ApiRebalanceV5), nil } else { return "", emperror.New("emqx type error") diff --git a/controllers/apps/v2alpha2/rebalance_controller_test.go b/controllers/apps/v2beta1/rebalance_controller_test.go similarity index 87% rename from controllers/apps/v2alpha2/rebalance_controller_test.go rename to controllers/apps/v2beta1/rebalance_controller_test.go index ef59fc454..553e1aa81 100644 --- a/controllers/apps/v2alpha2/rebalance_controller_test.go +++ b/controllers/apps/v2beta1/rebalance_controller_test.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( // "fmt" @@ -10,7 +10,7 @@ import ( "testing" appsv1beta4 "github.com/emqx/emqx-operator/apis/apps/v1beta4" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -45,9 +45,9 @@ var emqxV1 = &appsv1beta4.EmqxEnterprise{ }, } -var emqxV2 = &appsv2alpha2.EMQX{ - Status: appsv2alpha2.EMQXStatus{ - CoreNodes: []appsv2alpha2.EMQXNode{ +var emqxV2 = &appsv2beta1.EMQX{ + Status: appsv2beta1.EMQXStatus{ + CoreNodes: []appsv2beta1.EMQXNode{ { Node: emqxNodeName, }, @@ -58,7 +58,7 @@ var emqxV2 = &appsv2alpha2.EMQX{ func TestGetRebalanceStatus(t *testing.T) { emqxVers := []EmqxVer{ {"v1beta4", emqxV1}, - {"v2alpha2", emqxV2}, + {"v2beta1", emqxV2}, } for _, tc := range emqxVers { @@ -113,9 +113,9 @@ func TestGetRebalanceStatus(t *testing.T) { func TestStartRebalanceV1(t *testing.T) { f := &innerReq.FakeRequester{} - rebalance := &appsv2alpha2.Rebalance{ - Spec: appsv2alpha2.RebalanceSpec{ - RebalanceStrategy: appsv2alpha2.RebalanceStrategy{ + rebalance := &appsv2beta1.Rebalance{ + Spec: appsv2beta1.RebalanceSpec{ + RebalanceStrategy: appsv2beta1.RebalanceStrategy{ ConnEvictRate: 5, SessEvictRate: 5, WaitHealthCheck: 10, @@ -130,7 +130,7 @@ func TestStartRebalanceV1(t *testing.T) { emqxVers := []EmqxVer{ {"v1beta4", emqxV1}, - {"v2alpha2", emqxV2}, + {"v2beta1", emqxV2}, } for _, tc := range emqxVers { @@ -188,10 +188,10 @@ func TestStartRebalanceV1(t *testing.T) { func TestStopRebalance(t *testing.T) { f := &innerReq.FakeRequester{} - rebalance := &appsv2alpha2.Rebalance{ - Status: appsv2alpha2.RebalanceStatus{ + rebalance := &appsv2beta1.Rebalance{ + Status: appsv2beta1.RebalanceStatus{ Phase: "Processing", - RebalanceStates: []appsv2alpha2.RebalanceState{ + RebalanceStates: []appsv2beta1.RebalanceState{ { CoordinatorNode: emqxNodeName, }, @@ -201,7 +201,7 @@ func TestStopRebalance(t *testing.T) { emqxVers := []EmqxVer{ {"v1beta4", emqxV1}, - {"v2alpha2", emqxV2}, + {"v2beta1", emqxV2}, } for _, tc := range emqxVers { @@ -257,9 +257,9 @@ func TestStopRebalance(t *testing.T) { } func TestGetRequestBytes(t *testing.T) { - rebalance := &appsv2alpha2.Rebalance{ - Spec: appsv2alpha2.RebalanceSpec{ - RebalanceStrategy: appsv2alpha2.RebalanceStrategy{ + rebalance := &appsv2beta1.Rebalance{ + Spec: appsv2beta1.RebalanceSpec{ + RebalanceStrategy: appsv2beta1.RebalanceStrategy{ ConnEvictRate: 5, SessEvictRate: 5, WaitHealthCheck: 10, @@ -274,7 +274,7 @@ func TestGetRequestBytes(t *testing.T) { emqxVers := []EmqxVer{ {"v1beta4", &appsv1beta4.EmqxEnterprise{}}, - {"v2alpha2", &appsv2alpha2.EMQX{}}, + {"v2beta1", &appsv2beta1.EMQX{}}, } for _, tc := range emqxVers { @@ -359,7 +359,7 @@ func TestGetRequestBytes(t *testing.T) { func TestRebalanceStatusHandler(t *testing.T) { finalizer := "apps.emqx.io/finalizer" - rebalance := &appsv2alpha2.Rebalance{ + rebalance := &appsv2beta1.Rebalance{ ObjectMeta: metav1.ObjectMeta{ Finalizers: []string{finalizer}, }, @@ -369,59 +369,59 @@ func TestRebalanceStatusHandler(t *testing.T) { emqxVers := []EmqxVer{ {"v1beta4", &appsv1beta4.EmqxEnterprise{}}, - {"v2alpha2", &appsv2alpha2.EMQX{}}, + {"v2beta1", &appsv2beta1.EMQX{}}, } for _, tc := range emqxVers { tc := tc // Create a new variable to avoid variable capture in closures t.Run(tc.name, func(t *testing.T) { - defStartFun := func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error { + defStartFun := func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error { return nil } - defGetFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2alpha2.RebalanceState, error) { - return []appsv2alpha2.RebalanceState{}, nil + defGetFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2beta1.RebalanceState, error) { + return []appsv2beta1.RebalanceState{}, nil } t.Run("check start rebalance failed", func(t *testing.T) { r := rebalance.DeepCopy() - startFun := func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2alpha2.Rebalance) error { + startFun := func(emqx client.Object, requester innerReq.RequesterInterface, rebalance *appsv2beta1.Rebalance) error { return errors.New("fake error") } rebalanceStatusHandler(tc.emqx, r, f, startFun, defGetFun) - assert.Equal(t, appsv2alpha2.RebalancePhaseFailed, r.Status.Phase) + assert.Equal(t, appsv2beta1.RebalancePhaseFailed, r.Status.Phase) }) t.Run("check start rebalance success", func(t *testing.T) { r := rebalance.DeepCopy() rebalanceStatusHandler(tc.emqx, r, f, defStartFun, defGetFun) - assert.Equal(t, appsv2alpha2.RebalancePhaseProcessing, r.Status.Phase) + assert.Equal(t, appsv2beta1.RebalancePhaseProcessing, r.Status.Phase) }) t.Run("check get rebalance status failed", func(t *testing.T) { r := rebalance.DeepCopy() - r.Status.Phase = appsv2alpha2.RebalancePhaseProcessing + r.Status.Phase = appsv2beta1.RebalancePhaseProcessing - getFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2alpha2.RebalanceState, error) { + getFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2beta1.RebalanceState, error) { return nil, errors.New("fake error") } rebalanceStatusHandler(tc.emqx, r, f, defStartFun, getFun) - assert.Equal(t, appsv2alpha2.RebalancePhaseFailed, r.Status.Phase) + assert.Equal(t, appsv2beta1.RebalancePhaseFailed, r.Status.Phase) }) t.Run("check get rebalance status return empty list", func(t *testing.T) { r := rebalance.DeepCopy() - r.Status.Phase = appsv2alpha2.RebalancePhaseProcessing + r.Status.Phase = appsv2beta1.RebalancePhaseProcessing rebalanceStatusHandler(tc.emqx, r, f, defStartFun, defGetFun) - assert.Equal(t, appsv2alpha2.RebalancePhaseCompleted, r.Status.Phase) + assert.Equal(t, appsv2beta1.RebalancePhaseCompleted, r.Status.Phase) }) t.Run("check get rebalance status success", func(t *testing.T) { r := rebalance.DeepCopy() - r.Status.Phase = appsv2alpha2.RebalancePhaseProcessing + r.Status.Phase = appsv2beta1.RebalancePhaseProcessing - getFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2alpha2.RebalanceState, error) { - return []appsv2alpha2.RebalanceState{ + getFun := func(emqx client.Object, requester innerReq.RequesterInterface) ([]appsv2beta1.RebalanceState, error) { + return []appsv2beta1.RebalanceState{ { State: "processing", }, @@ -429,14 +429,14 @@ func TestRebalanceStatusHandler(t *testing.T) { } rebalanceStatusHandler(tc.emqx, r, f, defStartFun, getFun) - assert.Equal(t, appsv2alpha2.RebalancePhaseProcessing, r.Status.Phase) + assert.Equal(t, appsv2beta1.RebalancePhaseProcessing, r.Status.Phase) assert.Equal(t, "processing", r.Status.RebalanceStates[0].State) }) t.Run("check failed handler", func(t *testing.T) { r := rebalance.DeepCopy() - r.Status.Phase = appsv2alpha2.RebalancePhaseFailed - r.Status.RebalanceStates = []appsv2alpha2.RebalanceState{ + r.Status.Phase = appsv2beta1.RebalancePhaseFailed + r.Status.RebalanceStates = []appsv2beta1.RebalanceState{ {State: "fake"}, } rebalanceStatusHandler(tc.emqx, r, f, defStartFun, defGetFun) @@ -445,8 +445,8 @@ func TestRebalanceStatusHandler(t *testing.T) { t.Run("check completed handler", func(t *testing.T) { r := rebalance.DeepCopy() - r.Status.Phase = appsv2alpha2.RebalancePhaseCompleted - r.Status.RebalanceStates = []appsv2alpha2.RebalanceState{ + r.Status.Phase = appsv2beta1.RebalancePhaseCompleted + r.Status.RebalanceStates = []appsv2beta1.RebalanceState{ {State: "fake"}, } rebalanceStatusHandler(tc.emqx, r, f, defStartFun, defGetFun) diff --git a/controllers/apps/v2alpha2/status_machine.go b/controllers/apps/v2beta1/status_machine.go similarity index 77% rename from controllers/apps/v2alpha2/status_machine.go rename to controllers/apps/v2beta1/status_machine.go index cdee8d6b6..ca6a14dff 100644 --- a/controllers/apps/v2alpha2/status_machine.go +++ b/controllers/apps/v2beta1/status_machine.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,7 +26,7 @@ type status interface { } type emqxStatusMachine struct { - emqx *appsv2alpha2.EMQX + emqx *appsv2beta1.EMQX // EMQX cluster status initialized status @@ -40,7 +40,7 @@ type emqxStatusMachine struct { currentStatus status } -func newEMQXStatusMachine(emqx *appsv2alpha2.EMQX) *emqxStatusMachine { +func newEMQXStatusMachine(emqx *appsv2beta1.EMQX) *emqxStatusMachine { emqxStatusMachine := &emqxStatusMachine{ emqx: emqx, } @@ -65,11 +65,11 @@ func newEMQXStatusMachine(emqx *appsv2alpha2.EMQX) *emqxStatusMachine { return emqxStatusMachine } -func (s *emqxStatusMachine) setCurrentStatus(emqx *appsv2alpha2.EMQX) { +func (s *emqxStatusMachine) setCurrentStatus(emqx *appsv2beta1.EMQX) { condition := emqx.Status.GetLastTrueCondition() if condition == nil { condition = &metav1.Condition{ - Type: appsv2alpha2.Initialized, + Type: appsv2beta1.Initialized, Status: metav1.ConditionTrue, Reason: "Initialized", Message: "initialized EMQX cluster", @@ -78,17 +78,17 @@ func (s *emqxStatusMachine) setCurrentStatus(emqx *appsv2alpha2.EMQX) { } switch condition.Type { - case appsv2alpha2.CoreNodesProgressing: + case appsv2beta1.CoreNodesProgressing: s.currentStatus = s.coreNodesProgressing - case appsv2alpha2.CoreNodesReady: + case appsv2beta1.CoreNodesReady: s.currentStatus = s.coreNodesReady - case appsv2alpha2.ReplicantNodesProgressing: + case appsv2beta1.ReplicantNodesProgressing: s.currentStatus = s.replicantNodesProgressing - case appsv2alpha2.ReplicantNodesReady: + case appsv2beta1.ReplicantNodesReady: s.currentStatus = s.replicantNodesReady - case appsv2alpha2.Available: + case appsv2beta1.Available: s.currentStatus = s.available - case appsv2alpha2.Ready: + case appsv2beta1.Ready: s.currentStatus = s.ready default: s.currentStatus = s.initialized @@ -99,7 +99,7 @@ func (s *emqxStatusMachine) NextStatus() { s.currentStatus.nextStatus() } -func (s *emqxStatusMachine) GetEMQX() *appsv2alpha2.EMQX { +func (s *emqxStatusMachine) GetEMQX() *appsv2beta1.EMQX { return s.emqx } @@ -108,17 +108,17 @@ type initializedStatus struct { } func (s *initializedStatus) nextStatus() { - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.ReplicantNodesProgressing) - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.ReplicantNodesReady) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.ReplicantNodesProgressing) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.ReplicantNodesReady) - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.CoreNodesProgressing) - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.CoreNodesReady) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.CoreNodesProgressing) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.CoreNodesReady) - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.Available) - s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2alpha2.Ready) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.Available) + s.emqxStatusMachine.emqx.Status.RemoveCondition(appsv2beta1.Ready) s.emqxStatusMachine.emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.CoreNodesProgressing, + Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue, Reason: "CoreNodesProgressing", Message: "Core nodes progressing", @@ -135,7 +135,7 @@ func (s *coreNodesProgressingStatus) nextStatus() { if emqx.Status.CoreNodesStatus.UpdateReplicas == emqx.Status.CoreNodesStatus.Replicas { emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.CoreNodesReady, + Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue, Reason: "CoreNodesReady", Message: "Core nodes is ready", @@ -152,11 +152,11 @@ type codeNodesReadyStatus struct { func (s *codeNodesReadyStatus) nextStatus() { emqx := s.emqxStatusMachine.GetEMQX() - if appsv2alpha2.IsExistReplicant(emqx) { + if appsv2beta1.IsExistReplicant(emqx) { emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, - Reason: appsv2alpha2.ReplicantNodesProgressing, + Reason: appsv2beta1.ReplicantNodesProgressing, Message: "Replicant nodes progressing", }) s.emqxStatusMachine.setCurrentStatus(emqx) @@ -164,9 +164,9 @@ func (s *codeNodesReadyStatus) nextStatus() { } emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, - Reason: appsv2alpha2.Available, + Reason: appsv2beta1.Available, Message: "Cluster is available", }) s.emqxStatusMachine.setCurrentStatus(emqx) @@ -179,16 +179,16 @@ type replicantNodesProgressingStatus struct { func (s *replicantNodesProgressingStatus) nextStatus() { emqx := s.emqxStatusMachine.GetEMQX() - if !appsv2alpha2.IsExistReplicant(emqx) { + if !appsv2beta1.IsExistReplicant(emqx) { s.emqxStatusMachine.initialized.nextStatus() return } if emqx.Status.ReplicantNodesStatus.UpdateReplicas == emqx.Status.ReplicantNodesStatus.Replicas { emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.ReplicantNodesReady, + Type: appsv2beta1.ReplicantNodesReady, Status: metav1.ConditionTrue, - Reason: appsv2alpha2.ReplicantNodesReady, + Reason: appsv2beta1.ReplicantNodesReady, Message: "Replicant nodes ready", }) } @@ -201,15 +201,15 @@ type replicantNodesReadyStatus struct { } func (s *replicantNodesReadyStatus) nextStatus() { - if !appsv2alpha2.IsExistReplicant(s.emqxStatusMachine.emqx) { + if !appsv2beta1.IsExistReplicant(s.emqxStatusMachine.emqx) { s.emqxStatusMachine.initialized.nextStatus() return } s.emqxStatusMachine.emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, - Reason: appsv2alpha2.Available, + Reason: appsv2beta1.Available, Message: "Cluster is available", }) s.emqxStatusMachine.setCurrentStatus(s.emqxStatusMachine.emqx) @@ -227,7 +227,7 @@ func (s *availableStatus) nextStatus() { return } - if appsv2alpha2.IsExistReplicant(emqx) { + if appsv2beta1.IsExistReplicant(emqx) { if emqx.Status.ReplicantNodesStatus.ReadyReplicas != emqx.Status.ReplicantNodesStatus.Replicas || emqx.Status.ReplicantNodesStatus.UpdateRevision != emqx.Status.ReplicantNodesStatus.CurrentRevision { return @@ -235,9 +235,9 @@ func (s *availableStatus) nextStatus() { } emqx.Status.SetCondition(metav1.Condition{ - Type: appsv2alpha2.Ready, + Type: appsv2beta1.Ready, Status: metav1.ConditionTrue, - Reason: appsv2alpha2.Ready, + Reason: appsv2beta1.Ready, Message: "Cluster is ready", }) s.emqxStatusMachine.setCurrentStatus(emqx) diff --git a/controllers/apps/v2alpha2/status_machine_test.go b/controllers/apps/v2beta1/status_machine_test.go similarity index 71% rename from controllers/apps/v2alpha2/status_machine_test.go rename to controllers/apps/v2beta1/status_machine_test.go index 0d3f1ed13..333ece8cf 100644 --- a/controllers/apps/v2alpha2/status_machine_test.go +++ b/controllers/apps/v2beta1/status_machine_test.go @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "testing" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" ) -var instance = &appsv2alpha2.EMQX{ - Spec: appsv2alpha2.EMQXSpec{ - CoreTemplate: appsv2alpha2.EMQXCoreTemplate{ - Spec: appsv2alpha2.EMQXCoreTemplateSpec{ - EMQXReplicantTemplateSpec: appsv2alpha2.EMQXReplicantTemplateSpec{ +var instance = &appsv2beta1.EMQX{ + Spec: appsv2beta1.EMQXSpec{ + CoreTemplate: appsv2beta1.EMQXCoreTemplate{ + Spec: appsv2beta1.EMQXCoreTemplateSpec{ + EMQXReplicantTemplateSpec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32Ptr(3), }, }, }, - ReplicantTemplate: &appsv2alpha2.EMQXReplicantTemplate{ - Spec: appsv2alpha2.EMQXReplicantTemplateSpec{ + ReplicantTemplate: &appsv2beta1.EMQXReplicantTemplate{ + Spec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32Ptr(3), }, }, }, - Status: appsv2alpha2.EMQXStatus{ - CoreNodesStatus: appsv2alpha2.EMQXNodesStatus{ + Status: appsv2beta1.EMQXStatus{ + CoreNodesStatus: appsv2beta1.EMQXNodesStatus{ Replicas: 3, }, - ReplicantNodesStatus: &appsv2alpha2.EMQXNodesStatus{ + ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{ Replicas: 3, }, }, @@ -55,67 +55,67 @@ func TestNewStatusMachine(t *testing.T) { emqx := instance.DeepCopy() emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.initialized, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Initialized, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Initialized, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("coreNodesProgressing", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.CoreNodesProgressing, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.coreNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesProgressing, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesProgressing, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("coreNodesReady", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.CoreNodesReady, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.coreNodesReady, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesReady, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesReady, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("replicantNodesProgressing", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.ReplicantNodesProgressing, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.replicantNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.ReplicantNodesProgressing, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.ReplicantNodesProgressing, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("replicantNodesReady", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.ReplicantNodesReady, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.ReplicantNodesReady, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.replicantNodesReady, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.ReplicantNodesReady, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.ReplicantNodesReady, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("available", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.Available, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.Available, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.available, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Available, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Available, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) t.Run("ready", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.Ready, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.Ready, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) assert.Equal(t, emqxStatusMachine.ready, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Ready, emqxStatusMachine.emqx.Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Ready, emqxStatusMachine.emqx.Status.Conditions[0].Type) }) } @@ -123,7 +123,7 @@ func TestNextStatusForInit(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Initialized, + Type: appsv2beta1.Initialized, Status: metav1.ConditionTrue, }, } @@ -131,7 +131,7 @@ func TestNextStatusForInit(t *testing.T) { emqxStatusMachine := newEMQXStatusMachine(emqx) emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.coreNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) } func TestNextStatusForCoreNodeProgressing(t *testing.T) { @@ -139,7 +139,7 @@ func TestNextStatusForCoreNodeProgressing(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.CoreNodesProgressing, + Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue, }, } @@ -149,14 +149,14 @@ func TestNextStatusForCoreNodeProgressing(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.coreNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("next status", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.CoreNodesProgressing, + Type: appsv2beta1.CoreNodesProgressing, Status: metav1.ConditionTrue, }, } @@ -166,7 +166,7 @@ func TestNextStatusForCoreNodeProgressing(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.coreNodesReady, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesReady, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesReady, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) } @@ -175,21 +175,21 @@ func TestNextStatusForCodeNodesReady(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.CoreNodesReady, + Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue, }, } emqxStatusMachine := newEMQXStatusMachine(emqx) emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.replicantNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.ReplicantNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.ReplicantNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("next status when replicant template is nil", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.CoreNodesReady, + Type: appsv2beta1.CoreNodesReady, Status: metav1.ConditionTrue, }, } @@ -198,7 +198,7 @@ func TestNextStatusForCodeNodesReady(t *testing.T) { emqx.Spec.ReplicantTemplate = nil emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.available, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) } @@ -208,7 +208,7 @@ func TestNextStatusForReplicantNodeProgressing(t *testing.T) { emqx.Spec.ReplicantTemplate = nil emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, }, } @@ -216,14 +216,14 @@ func TestNextStatusForReplicantNodeProgressing(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.coreNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("still status when replicant nodes not ready", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, }, } @@ -232,14 +232,14 @@ func TestNextStatusForReplicantNodeProgressing(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.replicantNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.ReplicantNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.ReplicantNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("next status", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.ReplicantNodesProgressing, + Type: appsv2beta1.ReplicantNodesProgressing, Status: metav1.ConditionTrue, }, } @@ -248,7 +248,7 @@ func TestNextStatusForReplicantNodeProgressing(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.replicantNodesReady, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.ReplicantNodesReady, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.ReplicantNodesReady, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) } @@ -257,20 +257,20 @@ func TestNextStatusForReplicantNodesReady(t *testing.T) { emqx := instance.DeepCopy() emqx.Spec.ReplicantTemplate = nil emqx.Status.Conditions = []metav1.Condition{ - {Type: appsv2alpha2.ReplicantNodesReady, Status: metav1.ConditionTrue}, + {Type: appsv2beta1.ReplicantNodesReady, Status: metav1.ConditionTrue}, } emqxStatusMachine := newEMQXStatusMachine(emqx) emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.coreNodesProgressing, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.CoreNodesProgressing, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("next status", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.ReplicantNodesReady, + Type: appsv2beta1.ReplicantNodesReady, Status: metav1.ConditionTrue, }, } @@ -279,7 +279,7 @@ func TestNextStatusForReplicantNodesReady(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.available, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) } @@ -288,7 +288,7 @@ func TestNextStatusForAvailable(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, }, } @@ -297,14 +297,14 @@ func TestNextStatusForAvailable(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.available, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("still status when replicant nodes ready replicas not equal replicas", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, }, } @@ -313,14 +313,14 @@ func TestNextStatusForAvailable(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.available, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Available, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) t.Run("next status", func(t *testing.T) { emqx := instance.DeepCopy() emqx.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, }, } @@ -330,6 +330,6 @@ func TestNextStatusForAvailable(t *testing.T) { emqxStatusMachine.NextStatus() assert.Equal(t, emqxStatusMachine.ready, emqxStatusMachine.currentStatus) - assert.Equal(t, appsv2alpha2.Ready, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) + assert.Equal(t, appsv2beta1.Ready, emqxStatusMachine.GetEMQX().Status.Conditions[0].Type) }) } diff --git a/controllers/apps/v2alpha2/suite_test.go b/controllers/apps/v2beta1/suite_test.go similarity index 91% rename from controllers/apps/v2alpha2/suite_test.go rename to controllers/apps/v2beta1/suite_test.go index 0cbd779a1..af2d3cb6a 100644 --- a/controllers/apps/v2alpha2/suite_test.go +++ b/controllers/apps/v2beta1/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "os" @@ -34,7 +34,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" //+kubebuilder:scaffold:imports ) @@ -49,16 +49,16 @@ var k8sClient client.Client var ctx context.Context var emqxReconciler *EMQXReconciler -var emqx *appsv2alpha2.EMQX = &appsv2alpha2.EMQX{ +var emqx *appsv2beta1.EMQX = &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ UID: "fake-1234567890", Name: "emqx", Labels: map[string]string{ - appsv2alpha2.ManagerByLabelKey: "emqx-operator", - appsv2alpha2.InstanceNameLabelKey: instance.Name, + appsv2beta1.ManagerByLabelKey: "emqx-operator", + appsv2beta1.InstanceNameLabelKey: instance.Name, }, }, - Spec: appsv2alpha2.EMQXSpec{ + Spec: appsv2beta1.EMQXSpec{ Image: "emqx", }, } @@ -102,7 +102,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = appsv2alpha2.AddToScheme(scheme.Scheme) + err = appsv2beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme diff --git a/controllers/apps/v2alpha2/sync_emqx_config.go b/controllers/apps/v2beta1/sync_emqx_config.go similarity index 88% rename from controllers/apps/v2alpha2/sync_emqx_config.go rename to controllers/apps/v2beta1/sync_emqx_config.go index 267e90869..c19d2c795 100644 --- a/controllers/apps/v2alpha2/sync_emqx_config.go +++ b/controllers/apps/v2beta1/sync_emqx_config.go @@ -1,11 +1,11 @@ -package v2alpha2 +package v2beta1 import ( "context" "net/http" emperror "emperror.dev/errors" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" "github.com/rory-z/go-hocon" corev1 "k8s.io/api/core/v1" @@ -17,7 +17,7 @@ type syncConfig struct { *EMQXReconciler } -func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) subResult { +func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { // If core nodes is nil, the EMQX is in the process of being created if len(instance.Status.CoreNodes) == 0 { configMap := generateConfigMap(instance, instance.Spec.Config.Data) @@ -27,7 +27,7 @@ func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, return subResult{} } - lastConfig, ok := instance.Annotations[appsv2alpha2.LastEMQXConfigAnnotationKey] + lastConfig, ok := instance.Annotations[appsv2beta1.LastEMQXConfigAnnotationKey] if ok && instance.Spec.Config.Data != lastConfig { // Delete readonly configs config, _ := hocon.ParseString(instance.Spec.Config.Data) @@ -40,7 +40,7 @@ func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, return subResult{err: emperror.Wrap(err, "failed to put emqx config")} } - instance.Annotations[appsv2alpha2.LastEMQXConfigAnnotationKey] = instance.Spec.Config.Data + instance.Annotations[appsv2beta1.LastEMQXConfigAnnotationKey] = instance.Spec.Config.Data if err := s.Client.Update(ctx, instance); err != nil { return subResult{err: emperror.Wrap(err, "failed to update emqx instance")} } @@ -63,7 +63,7 @@ func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, if instance.Annotations == nil { instance.Annotations = map[string]string{} } - instance.Annotations[appsv2alpha2.LastEMQXConfigAnnotationKey] = instance.Spec.Config.Data + instance.Annotations[appsv2beta1.LastEMQXConfigAnnotationKey] = instance.Spec.Config.Data if err := s.Client.Update(ctx, instance); err != nil { return subResult{err: emperror.Wrap(err, "failed to update emqx instance")} } @@ -82,7 +82,7 @@ func (s *syncConfig) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, return subResult{} } -func generateConfigMap(instance *appsv2alpha2.EMQX, data string) *corev1.ConfigMap { +func generateConfigMap(instance *appsv2beta1.EMQX, data string) *corev1.ConfigMap { return &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", diff --git a/controllers/apps/v2alpha2/sync_pods.go b/controllers/apps/v2beta1/sync_pods.go similarity index 94% rename from controllers/apps/v2alpha2/sync_pods.go rename to controllers/apps/v2beta1/sync_pods.go index 760faccf3..ed7e4dee2 100644 --- a/controllers/apps/v2alpha2/sync_pods.go +++ b/controllers/apps/v2beta1/sync_pods.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -8,7 +8,7 @@ import ( "strings" emperror "emperror.dev/errors" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -20,7 +20,7 @@ type syncPods struct { *EMQXReconciler } -func (s *syncPods) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) subResult { +func (s *syncPods) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { if r == nil { return subResult{} } @@ -29,7 +29,7 @@ func (s *syncPods) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r updateRs, currentRs, _ := getReplicaSetList(ctx, s.Client, instance) targetedEMQXNodesName := []string{} - if appsv2alpha2.IsExistReplicant(instance) { + if appsv2beta1.IsExistReplicant(instance) { if currentRs != nil { for _, node := range instance.Status.ReplicantNodes { if node.ControllerUID == currentRs.UID { @@ -89,7 +89,7 @@ func (s *syncPods) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r func (s *syncPods) canBeScaleDownRs( ctx context.Context, - instance *appsv2alpha2.EMQX, + instance *appsv2beta1.EMQX, r innerReq.RequesterInterface, oldRs *appsv1.ReplicaSet, targetedEMQXNodesName []string, @@ -133,12 +133,12 @@ func (s *syncPods) canBeScaleDownRs( func (s *syncPods) canBeScaleDownSts( ctx context.Context, - instance *appsv2alpha2.EMQX, + instance *appsv2beta1.EMQX, r innerReq.RequesterInterface, oldSts *appsv1.StatefulSet, targetedEMQXNodesName []string, ) (bool, error) { - if appsv2alpha2.IsExistReplicant(instance) { + if appsv2beta1.IsExistReplicant(instance) { if instance.Status.ReplicantNodesStatus.CurrentRevision != instance.Status.ReplicantNodesStatus.UpdateRevision { return false, nil } @@ -179,7 +179,7 @@ func (s *syncPods) canBeScaleDownSts( return true, nil } -func getEMQXNodeInfoByAPI(r innerReq.RequesterInterface, nodeName string) (*appsv2alpha2.EMQXNode, error) { +func getEMQXNodeInfoByAPI(r innerReq.RequesterInterface, nodeName string) (*appsv2beta1.EMQXNode, error) { url := r.GetURL(fmt.Sprintf("api/v5/nodes/%s", nodeName)) resp, body, err := r.Request("GET", url, nil, nil) @@ -187,7 +187,7 @@ func getEMQXNodeInfoByAPI(r innerReq.RequesterInterface, nodeName string) (*apps return nil, emperror.Wrap(err, "failed to get API api/v5/nodes") } if resp.StatusCode == 404 { - return &appsv2alpha2.EMQXNode{ + return &appsv2beta1.EMQXNode{ Node: nodeName, NodeStatus: "stopped", }, nil @@ -196,14 +196,14 @@ func getEMQXNodeInfoByAPI(r innerReq.RequesterInterface, nodeName string) (*apps return nil, emperror.Errorf("failed to get API %s, status : %s, body: %s", url.String(), resp.Status, body) } - nodeInfo := &appsv2alpha2.EMQXNode{} + nodeInfo := &appsv2beta1.EMQXNode{} if err := json.Unmarshal(body, &nodeInfo); err != nil { return nil, emperror.Wrap(err, "failed to unmarshal node statuses") } return nodeInfo, nil } -func startEvacuationByAPI(r innerReq.RequesterInterface, instance *appsv2alpha2.EMQX, migrateTo []string, nodeName string) error { +func startEvacuationByAPI(r innerReq.RequesterInterface, instance *appsv2beta1.EMQX, migrateTo []string, nodeName string) error { body := map[string]interface{}{ "conn_evict_rate": instance.Spec.UpdateStrategy.EvacuationStrategy.ConnEvictRate, "sess_evict_rate": instance.Spec.UpdateStrategy.EvacuationStrategy.SessEvictRate, diff --git a/controllers/apps/v2alpha2/sync_pods_suite_test.go b/controllers/apps/v2beta1/sync_pods_suite_test.go similarity index 85% rename from controllers/apps/v2alpha2/sync_pods_suite_test.go rename to controllers/apps/v2beta1/sync_pods_suite_test.go index 0d481ec2e..28b68cbb8 100644 --- a/controllers/apps/v2alpha2/sync_pods_suite_test.go +++ b/controllers/apps/v2beta1/sync_pods_suite_test.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -7,7 +7,7 @@ import ( "net/url" "time" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -23,7 +23,7 @@ import ( var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { var s *syncPods var fakeR *innerReq.FakeRequester = &innerReq.FakeRequester{} - var instance *appsv2alpha2.EMQX = new(appsv2alpha2.EMQX) + var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX) var ns *corev1.Namespace = &corev1.Namespace{} var updateSts, currentSts *appsv1.StatefulSet @@ -35,7 +35,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { resp = &http.Response{ StatusCode: 200, } - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Opensource", }) return resp, respBody, nil @@ -44,7 +44,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { s = &syncPods{emqxReconciler} ns = &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ - Name: "controller-v2alpha2-update-emqx-nodes-test-" + rand.String(5), + Name: "controller-v2beta1-update-emqx-nodes-test-" + rand.String(5), Labels: map[string]string{ "test": "e2e", }, @@ -53,23 +53,23 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { instance = emqx.DeepCopy() instance.Namespace = ns.Name instance.Spec.CoreTemplate.Labels = instance.Labels - instance.Spec.ReplicantTemplate = &appsv2alpha2.EMQXReplicantTemplate{ + instance.Spec.ReplicantTemplate = &appsv2beta1.EMQXReplicantTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: instance.Labels, }, - Spec: appsv2alpha2.EMQXReplicantTemplateSpec{ + Spec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32Ptr(1), }, } - instance.Status = appsv2alpha2.EMQXStatus{ + instance.Status = appsv2beta1.EMQXStatus{ Conditions: []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, }, - CoreNodesStatus: appsv2alpha2.EMQXNodesStatus{ + CoreNodesStatus: appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", UpdateReplicas: 1, CurrentRevision: "current", @@ -77,7 +77,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { ReadyReplicas: 2, Replicas: 1, }, - ReplicantNodesStatus: &appsv2alpha2.EMQXNodesStatus{ + ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", UpdateReplicas: 1, CurrentRevision: "current", @@ -93,26 +93,26 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { ObjectMeta: metav1.ObjectMeta{ GenerateName: instance.Name + "-", Namespace: instance.Namespace, - Labels: appsv2alpha2.CloneAndAddLabel( + Labels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, Spec: appsv1.StatefulSetSpec{ Replicas: pointer.Int32Ptr(1), Selector: &metav1.LabelSelector{ - MatchLabels: appsv2alpha2.CloneAndAddLabel( + MatchLabels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: appsv2alpha2.CloneAndAddLabel( + Labels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, @@ -126,9 +126,9 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { } currentSts = updateSts.DeepCopy() - currentSts.Labels[appsv2alpha2.PodTemplateHashLabelKey] = "current" - currentSts.Spec.Selector.MatchLabels[appsv2alpha2.PodTemplateHashLabelKey] = "current" - currentSts.Spec.Template.Labels[appsv2alpha2.PodTemplateHashLabelKey] = "current" + currentSts.Labels[appsv2beta1.PodTemplateHashLabelKey] = "current" + currentSts.Spec.Selector.MatchLabels[appsv2beta1.PodTemplateHashLabelKey] = "current" + currentSts.Spec.Template.Labels[appsv2beta1.PodTemplateHashLabelKey] = "current" Expect(k8sClient.Create(context.Background(), updateSts)).Should(Succeed()) updateSts.Status.Replicas = 1 @@ -144,26 +144,26 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { ObjectMeta: metav1.ObjectMeta{ GenerateName: instance.Name + "-", Namespace: instance.Namespace, - Labels: appsv2alpha2.CloneAndAddLabel( + Labels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, Spec: appsv1.ReplicaSetSpec{ Replicas: pointer.Int32Ptr(1), Selector: &metav1.LabelSelector{ - MatchLabels: appsv2alpha2.CloneAndAddLabel( + MatchLabels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: appsv2alpha2.CloneAndAddLabel( + Labels: appsv2beta1.CloneAndAddLabel( instance.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, "update", ), }, @@ -177,9 +177,9 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { } currentRs = updateRs.DeepCopy() - currentRs.Labels[appsv2alpha2.PodTemplateHashLabelKey] = "current" - currentRs.Spec.Selector.MatchLabels[appsv2alpha2.PodTemplateHashLabelKey] = "current" - currentRs.Spec.Template.Labels[appsv2alpha2.PodTemplateHashLabelKey] = "current" + currentRs.Labels[appsv2beta1.PodTemplateHashLabelKey] = "current" + currentRs.Spec.Selector.MatchLabels[appsv2beta1.PodTemplateHashLabelKey] = "current" + currentRs.Spec.Template.Labels[appsv2beta1.PodTemplateHashLabelKey] = "current" Expect(k8sClient.Create(context.Background(), updateRs)).Should(Succeed()) updateRs.Status.Replicas = 1 @@ -214,7 +214,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { AfterEach(func() { Expect(k8sClient.DeleteAllOf(context.Background(), &appsv1.ReplicaSet{}, client.InNamespace(instance.Namespace))).Should(Succeed()) Expect(k8sClient.DeleteAllOf(context.Background(), &appsv1.StatefulSet{}, client.InNamespace(instance.Namespace))).Should(Succeed()) - Expect(k8sClient.DeleteAllOf(context.Background(), &appsv2alpha2.EMQX{}, client.InNamespace(instance.Namespace))).Should(Succeed()) + Expect(k8sClient.DeleteAllOf(context.Background(), &appsv2beta1.EMQX{}, client.InNamespace(instance.Namespace))).Should(Succeed()) Expect(k8sClient.Delete(context.Background(), ns)).Should(Succeed()) }) @@ -253,14 +253,14 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { var _ = Describe("check can be scale down", func() { var s *syncPods var fakeR *innerReq.FakeRequester = &innerReq.FakeRequester{} - var instance *appsv2alpha2.EMQX = new(appsv2alpha2.EMQX) + var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX) var ns *corev1.Namespace = &corev1.Namespace{} BeforeEach(func() { s = &syncPods{emqxReconciler} ns = &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ - Name: "controller-v2alpha2-update-emqx-nodes-test-" + rand.String(5), + Name: "controller-v2beta1-update-emqx-nodes-test-" + rand.String(5), Labels: map[string]string{ "test": "e2e", }, @@ -270,7 +270,7 @@ var _ = Describe("check can be scale down", func() { instance.Namespace = ns.Name instance.Status.Conditions = []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, @@ -284,7 +284,7 @@ var _ = Describe("check can be scale down", func() { Expect(k8sClient.DeleteAllOf(context.Background(), &corev1.Pod{}, client.InNamespace(instance.Namespace))).Should(Succeed()) Expect(k8sClient.DeleteAllOf(context.Background(), &appsv1.ReplicaSet{}, client.InNamespace(instance.Namespace))).Should(Succeed()) Expect(k8sClient.DeleteAllOf(context.Background(), &appsv1.StatefulSet{}, client.InNamespace(instance.Namespace))).Should(Succeed()) - Expect(k8sClient.DeleteAllOf(context.Background(), &appsv2alpha2.EMQX{}, client.InNamespace(instance.Namespace))).Should(Succeed()) + Expect(k8sClient.DeleteAllOf(context.Background(), &appsv2beta1.EMQX{}, client.InNamespace(instance.Namespace))).Should(Succeed()) Expect(k8sClient.Delete(context.Background(), ns)).Should(Succeed()) }) @@ -318,12 +318,12 @@ var _ = Describe("check can be scale down", func() { }) It("the replicaSet didn't ready", func() { - instance.Spec.ReplicantTemplate = &appsv2alpha2.EMQXReplicantTemplate{ - Spec: appsv2alpha2.EMQXReplicantTemplateSpec{ + instance.Spec.ReplicantTemplate = &appsv2beta1.EMQXReplicantTemplate{ + Spec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32Ptr(3), }, } - instance.Status.ReplicantNodesStatus = &appsv2alpha2.EMQXNodesStatus{ + instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", CurrentRevision: "current", } @@ -341,7 +341,7 @@ var _ = Describe("check can be scale down", func() { } if method == "GET" { - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Enterprise", Session: 99999, }) @@ -360,7 +360,7 @@ var _ = Describe("check can be scale down", func() { resp = &http.Response{ StatusCode: 200, } - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Enterprise", Session: 0, }) @@ -377,7 +377,7 @@ var _ = Describe("check can be scale down", func() { resp = &http.Response{ StatusCode: 200, } - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Opensource", }) return resp, respBody, nil @@ -462,7 +462,7 @@ var _ = Describe("check can be scale down", func() { } if method == "GET" { - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Enterprise", Session: 99999, }) @@ -481,7 +481,7 @@ var _ = Describe("check can be scale down", func() { resp = &http.Response{ StatusCode: 200, } - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Enterprise", Session: 0, }) @@ -498,7 +498,7 @@ var _ = Describe("check can be scale down", func() { resp = &http.Response{ StatusCode: 200, } - respBody, _ = json.Marshal(&appsv2alpha2.EMQXNode{ + respBody, _ = json.Marshal(&appsv2beta1.EMQXNode{ Edition: "Opensource", }) return resp, respBody, nil diff --git a/controllers/apps/v2alpha2/update_emqx_status.go b/controllers/apps/v2beta1/update_emqx_status.go similarity index 90% rename from controllers/apps/v2alpha2/update_emqx_status.go rename to controllers/apps/v2beta1/update_emqx_status.go index c5d497c64..48bc7da86 100644 --- a/controllers/apps/v2alpha2/update_emqx_status.go +++ b/controllers/apps/v2beta1/update_emqx_status.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -7,7 +7,7 @@ import ( "strings" emperror "emperror.dev/errors" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" "github.com/tidwall/gjson" corev1 "k8s.io/api/core/v1" @@ -19,9 +19,9 @@ type updateStatus struct { *EMQXReconciler } -func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) subResult { +func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { if instance.Spec.ReplicantTemplate != nil && instance.Status.ReplicantNodesStatus == nil { - instance.Status.ReplicantNodesStatus = &appsv2alpha2.EMQXNodesStatus{ + instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{ Replicas: *instance.Spec.ReplicantTemplate.Spec.Replicas, } } @@ -33,7 +33,7 @@ func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ } else { currentRs = updateRs } - instance.Status.ReplicantNodesStatus.CurrentRevision = currentRs.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.ReplicantNodesStatus.CurrentRevision = currentRs.Labels[appsv2beta1.PodTemplateHashLabelKey] if err := u.Client.Status().Update(ctx, instance); err != nil { return subResult{err: emperror.Wrap(err, "failed to update status")} } @@ -47,7 +47,7 @@ func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ } else { currentSts = updateSts } - instance.Status.CoreNodesStatus.CurrentRevision = currentSts.Labels[appsv2alpha2.PodTemplateHashLabelKey] + instance.Status.CoreNodesStatus.CurrentRevision = currentSts.Labels[appsv2beta1.PodTemplateHashLabelKey] if err := u.Client.Status().Update(ctx, instance); err != nil { return subResult{err: emperror.Wrap(err, "failed to update status")} @@ -125,7 +125,7 @@ func (u *updateStatus) reconcile(ctx context.Context, instance *appsv2alpha2.EMQ return subResult{} } -func (u *updateStatus) getEMQXNodes(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) (coreNodes, replicantNodes []appsv2alpha2.EMQXNode, err error) { +func (u *updateStatus) getEMQXNodes(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) (coreNodes, replicantNodes []appsv2beta1.EMQXNode, err error) { emqxNodes, err := getEMQXNodesByAPI(r) if err != nil { return nil, nil, emperror.Wrap(err, "failed to get node statues by API") @@ -171,7 +171,7 @@ func (u *updateStatus) getEMQXNodes(ctx context.Context, instance *appsv2alpha2. return } -func getEMQXNodesByAPI(r innerReq.RequesterInterface) ([]appsv2alpha2.EMQXNode, error) { +func getEMQXNodesByAPI(r innerReq.RequesterInterface) ([]appsv2beta1.EMQXNode, error) { url := r.GetURL("api/v5/nodes") resp, body, err := r.Request("GET", url, nil, nil) @@ -182,14 +182,14 @@ func getEMQXNodesByAPI(r innerReq.RequesterInterface) ([]appsv2alpha2.EMQXNode, return nil, emperror.Errorf("failed to get API %s, status : %s, body: %s", url.String(), resp.Status, body) } - nodeStatuses := []appsv2alpha2.EMQXNode{} + nodeStatuses := []appsv2beta1.EMQXNode{} if err := json.Unmarshal(body, &nodeStatuses); err != nil { return nil, emperror.Wrap(err, "failed to unmarshal node statuses") } return nodeStatuses, nil } -func getNodeEvacuationStatusByAPI(r innerReq.RequesterInterface) ([]appsv2alpha2.NodeEvacuationStatus, error) { +func getNodeEvacuationStatusByAPI(r innerReq.RequesterInterface) ([]appsv2beta1.NodeEvacuationStatus, error) { url := r.GetURL("api/v5/load_rebalance/global_status") resp, body, err := r.Request("GET", url, nil, nil) if err != nil { @@ -199,7 +199,7 @@ func getNodeEvacuationStatusByAPI(r innerReq.RequesterInterface) ([]appsv2alpha2 return nil, emperror.Errorf("failed to get API %s, status : %s, body: %s", url.String(), resp.Status, body) } - nodeEvacuationStatuses := []appsv2alpha2.NodeEvacuationStatus{} + nodeEvacuationStatuses := []appsv2beta1.NodeEvacuationStatus{} data := gjson.GetBytes(body, "evacuations") if err := json.Unmarshal([]byte(data.Raw), &nodeEvacuationStatuses); err != nil { return nil, emperror.Wrap(err, "failed to unmarshal node statuses") diff --git a/controllers/apps/v2alpha2/update_pod_conditions.go b/controllers/apps/v2beta1/update_pod_conditions.go similarity index 82% rename from controllers/apps/v2alpha2/update_pod_conditions.go rename to controllers/apps/v2beta1/update_pod_conditions.go index a297a7cf5..c26f3bcc0 100644 --- a/controllers/apps/v2alpha2/update_pod_conditions.go +++ b/controllers/apps/v2beta1/update_pod_conditions.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -6,7 +6,7 @@ import ( "fmt" semver "github.com/Masterminds/semver/v3" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" innerReq "github.com/emqx/emqx-operator/internal/requester" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -18,7 +18,7 @@ type updatePodConditions struct { *EMQXReconciler } -func (u *updatePodConditions) reconcile(ctx context.Context, instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface) subResult { +func (u *updatePodConditions) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { updateRs, _, _ := getReplicaSetList(ctx, u.Client, instance) updateSts, _, _ := getStateFulSetList(ctx, u.Client, instance) @@ -36,7 +36,7 @@ func (u *updatePodConditions) reconcile(ctx context.Context, instance *appsv2alp } onServingCondition := corev1.PodCondition{ - Type: appsv2alpha2.PodOnServing, + Type: appsv2beta1.PodOnServing, Status: corev1.ConditionFalse, LastProbeTime: metav1.Now(), LastTransitionTime: metav1.Now(), @@ -62,9 +62,9 @@ func (u *updatePodConditions) reconcile(ctx context.Context, instance *appsv2alp return subResult{} } -func (u *updatePodConditions) checkInCluster(instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface, pod *corev1.Pod) corev1.ConditionStatus { +func (u *updatePodConditions) checkInCluster(instance *appsv2beta1.EMQX, r innerReq.RequesterInterface, pod *corev1.Pod) corev1.ConditionStatus { nodes := instance.Status.CoreNodes - if appsv2alpha2.IsExistReplicant(instance) { + if appsv2beta1.IsExistReplicant(instance) { nodes = append(nodes, instance.Status.ReplicantNodes...) } for _, node := range nodes { @@ -81,12 +81,12 @@ func (u *updatePodConditions) checkInCluster(instance *appsv2alpha2.EMQX, r inne return corev1.ConditionFalse } -func (u *updatePodConditions) checkRebalanceStatus(instance *appsv2alpha2.EMQX, r innerReq.RequesterInterface, pod *corev1.Pod) corev1.ConditionStatus { +func (u *updatePodConditions) checkRebalanceStatus(instance *appsv2beta1.EMQX, r innerReq.RequesterInterface, pod *corev1.Pod) corev1.ConditionStatus { if r == nil { return corev1.ConditionFalse } var port string - dashboardPort, err := appsv2alpha2.GetDashboardServicePort(instance.Spec.Config.Data) + dashboardPort, err := appsv2beta1.GetDashboardServicePort(instance.Spec.Config.Data) if err != nil || dashboardPort == nil { port = "18083" } diff --git a/controllers/apps/v2alpha2/util.go b/controllers/apps/v2beta1/util.go similarity index 90% rename from controllers/apps/v2alpha2/util.go rename to controllers/apps/v2beta1/util.go index bee22f4a7..187908987 100644 --- a/controllers/apps/v2alpha2/util.go +++ b/controllers/apps/v2beta1/util.go @@ -1,4 +1,4 @@ -package v2alpha2 +package v2beta1 import ( "context" @@ -13,7 +13,7 @@ import ( emperror "emperror.dev/errors" "github.com/cisco-open/k8s-objectmatcher/patch" "github.com/davecgh/go-spew/spew" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/tidwall/gjson" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func getRsPodMap(ctx context.Context, k8sClient client.Client, instance *appsv2alpha2.EMQX) map[types.UID][]*corev1.Pod { +func getRsPodMap(ctx context.Context, k8sClient client.Client, instance *appsv2beta1.EMQX) map[types.UID][]*corev1.Pod { podList := &corev1.PodList{} _ = k8sClient.List(ctx, podList, client.InNamespace(instance.Namespace), @@ -59,14 +59,14 @@ func getRsPodMap(ctx context.Context, k8sClient client.Client, instance *appsv2a return rsMap } -func getStateFulSetList(ctx context.Context, k8sClient client.Client, instance *appsv2alpha2.EMQX) (updateSts, currentSts *appsv1.StatefulSet, oldStsList []*appsv1.StatefulSet) { +func getStateFulSetList(ctx context.Context, k8sClient client.Client, instance *appsv2beta1.EMQX) (updateSts, currentSts *appsv1.StatefulSet, oldStsList []*appsv1.StatefulSet) { list := &appsv1.StatefulSetList{} _ = k8sClient.List(ctx, list, client.InNamespace(instance.Namespace), client.MatchingLabels(instance.Spec.CoreTemplate.Labels), ) for _, sts := range list.Items { - if hash, ok := sts.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { + if hash, ok := sts.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { if hash == instance.Status.CoreNodesStatus.UpdateRevision { updateSts = sts.DeepCopy() } @@ -86,7 +86,7 @@ func getStateFulSetList(ctx context.Context, k8sClient client.Client, instance * return } -func getReplicaSetList(ctx context.Context, k8sClient client.Client, instance *appsv2alpha2.EMQX) (updateRs, currentRs *appsv1.ReplicaSet, oldRsList []*appsv1.ReplicaSet) { +func getReplicaSetList(ctx context.Context, k8sClient client.Client, instance *appsv2beta1.EMQX) (updateRs, currentRs *appsv1.ReplicaSet, oldRsList []*appsv1.ReplicaSet) { if instance.Spec.ReplicantTemplate == nil { list := &appsv1.ReplicaSetList{} _ = k8sClient.List(ctx, list, @@ -106,7 +106,7 @@ func getReplicaSetList(ctx context.Context, k8sClient client.Client, instance *a client.MatchingLabels(instance.Spec.ReplicantTemplate.Labels), ) for _, rs := range list.Items { - if hash, ok := rs.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { + if hash, ok := rs.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { if hash == instance.Status.ReplicantNodesStatus.UpdateRevision { updateRs = rs.DeepCopy() } @@ -144,16 +144,16 @@ func handlerEventList(list *corev1.EventList) []*corev1.Event { return eList } -func checkInitialDelaySecondsReady(instance *appsv2alpha2.EMQX) bool { - _, condition := instance.Status.GetCondition(appsv2alpha2.Available) - if condition == nil || condition.Type != appsv2alpha2.Available { +func checkInitialDelaySecondsReady(instance *appsv2beta1.EMQX) bool { + _, condition := instance.Status.GetCondition(appsv2beta1.Available) + if condition == nil || condition.Type != appsv2beta1.Available { return false } delay := time.Since(condition.LastTransitionTime.Time).Seconds() return int32(delay) > instance.Spec.UpdateStrategy.InitialDelaySeconds } -func checkWaitTakeoverReady(instance *appsv2alpha2.EMQX, eList []*corev1.Event) bool { +func checkWaitTakeoverReady(instance *appsv2beta1.EMQX, eList []*corev1.Event) bool { if len(eList) == 0 { return true } @@ -171,8 +171,8 @@ func justCheckPodTemplate() patch.CalculateOption { _ = json.Unmarshal([]byte(podTemplateSpecJson.String()), podTemplateSpec) // Remove the podTemplateHashLabelKey from the podTemplateSpec - if _, ok := podTemplateSpec.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { - podTemplateSpec.Labels = appsv2alpha2.CloneAndRemoveLabel(podTemplateSpec.Labels, appsv2alpha2.PodTemplateHashLabelKey) + if _, ok := podTemplateSpec.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { + podTemplateSpec.Labels = appsv2beta1.CloneAndRemoveLabel(podTemplateSpec.Labels, appsv2beta1.PodTemplateHashLabelKey) } emptyRs := &appsv1.ReplicaSet{} diff --git a/controllers/apps/v2alpha2/util_test.go b/controllers/apps/v2beta1/util_test.go similarity index 69% rename from controllers/apps/v2alpha2/util_test.go rename to controllers/apps/v2beta1/util_test.go index 3132de833..50cd92614 100644 --- a/controllers/apps/v2alpha2/util_test.go +++ b/controllers/apps/v2beta1/util_test.go @@ -1,28 +1,28 @@ -package v2alpha2 +package v2beta1 import ( "testing" "time" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestCheckInitialDelaySecondsReady(t *testing.T) { - assert.False(t, checkInitialDelaySecondsReady(&appsv2alpha2.EMQX{})) + assert.False(t, checkInitialDelaySecondsReady(&appsv2beta1.EMQX{})) - assert.False(t, checkInitialDelaySecondsReady(&appsv2alpha2.EMQX{ - Spec: appsv2alpha2.EMQXSpec{ - UpdateStrategy: appsv2alpha2.UpdateStrategy{ + assert.False(t, checkInitialDelaySecondsReady(&appsv2beta1.EMQX{ + Spec: appsv2beta1.EMQXSpec{ + UpdateStrategy: appsv2beta1.UpdateStrategy{ InitialDelaySeconds: 999999999, }, }, - Status: appsv2alpha2.EMQXStatus{ + Status: appsv2beta1.EMQXStatus{ Conditions: []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now()}, }, @@ -30,16 +30,16 @@ func TestCheckInitialDelaySecondsReady(t *testing.T) { }, })) - assert.True(t, checkInitialDelaySecondsReady(&appsv2alpha2.EMQX{ - Spec: appsv2alpha2.EMQXSpec{ - UpdateStrategy: appsv2alpha2.UpdateStrategy{ + assert.True(t, checkInitialDelaySecondsReady(&appsv2beta1.EMQX{ + Spec: appsv2beta1.EMQXSpec{ + UpdateStrategy: appsv2beta1.UpdateStrategy{ InitialDelaySeconds: 0, }, }, - Status: appsv2alpha2.EMQXStatus{ + Status: appsv2beta1.EMQXStatus{ Conditions: []metav1.Condition{ { - Type: appsv2alpha2.Available, + Type: appsv2beta1.Available, Status: metav1.ConditionTrue, LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, @@ -50,15 +50,15 @@ func TestCheckInitialDelaySecondsReady(t *testing.T) { func TestCheckWaitTakeoverReady(t *testing.T) { t.Run("event list is empty", func(t *testing.T) { - assert.True(t, checkWaitTakeoverReady(&appsv2alpha2.EMQX{}, []*corev1.Event{})) + assert.True(t, checkWaitTakeoverReady(&appsv2beta1.EMQX{}, []*corev1.Event{})) }) t.Run("event list is not empty, waitTakeover not ready", func(t *testing.T) { - emqx := &appsv2alpha2.EMQX{ - Spec: appsv2alpha2.EMQXSpec{ - UpdateStrategy: appsv2alpha2.UpdateStrategy{ + emqx := &appsv2beta1.EMQX{ + Spec: appsv2beta1.EMQXSpec{ + UpdateStrategy: appsv2beta1.UpdateStrategy{ InitialDelaySeconds: 0, - EvacuationStrategy: appsv2alpha2.EvacuationStrategy{ + EvacuationStrategy: appsv2beta1.EvacuationStrategy{ WaitTakeover: 999999999, }, }, @@ -75,11 +75,11 @@ func TestCheckWaitTakeoverReady(t *testing.T) { }) t.Run("event list is not empty, waitTakeover is ready", func(t *testing.T) { - emqx := &appsv2alpha2.EMQX{ - Spec: appsv2alpha2.EMQXSpec{ - UpdateStrategy: appsv2alpha2.UpdateStrategy{ + emqx := &appsv2beta1.EMQX{ + Spec: appsv2beta1.EMQXSpec{ + UpdateStrategy: appsv2beta1.UpdateStrategy{ InitialDelaySeconds: 0, - EvacuationStrategy: appsv2alpha2.EvacuationStrategy{ + EvacuationStrategy: appsv2beta1.EvacuationStrategy{ WaitTakeover: 0, }, }, diff --git a/deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml b/deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml index b6170b552..f8a5f07d9 100644 --- a/deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml +++ b/deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml @@ -6482,7 +6482,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v2alpha2 + name: v2beta1 schema: openAPIV3Schema: properties: diff --git a/deploy/charts/emqx-operator/templates/crd.rebalances.apps.emqx.io.yaml b/deploy/charts/emqx-operator/templates/crd.rebalances.apps.emqx.io.yaml index cc97d60a4..e2aae02ba 100644 --- a/deploy/charts/emqx-operator/templates/crd.rebalances.apps.emqx.io.yaml +++ b/deploy/charts/emqx-operator/templates/crd.rebalances.apps.emqx.io.yaml @@ -158,7 +158,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - name: v2alpha2 + name: v2beta1 schema: openAPIV3Schema: properties: diff --git a/deploy/charts/emqx-operator/templates/webhook-mutating-configuration.yaml b/deploy/charts/emqx-operator/templates/webhook-mutating-configuration.yaml index aff869511..e4257a0f3 100644 --- a/deploy/charts/emqx-operator/templates/webhook-mutating-configuration.yaml +++ b/deploy/charts/emqx-operator/templates/webhook-mutating-configuration.yaml @@ -76,14 +76,14 @@ webhooks: service: name: {{ include "emqx-operator.fullname" . }}-webhook-service namespace: {{ .Release.Namespace }} - path: /mutate-apps-emqx-io-v2alpha2-emqx + path: /mutate-apps-emqx-io-v2beta1-emqx failurePolicy: Fail name: mutating.apps.emqx.io rules: - apiGroups: - apps.emqx.io apiVersions: - - v2alpha2 + - v2beta1 operations: - CREATE - UPDATE diff --git a/deploy/charts/emqx-operator/templates/webhook-validating-configuration.yaml b/deploy/charts/emqx-operator/templates/webhook-validating-configuration.yaml index e37587c9f..de944e08a 100644 --- a/deploy/charts/emqx-operator/templates/webhook-validating-configuration.yaml +++ b/deploy/charts/emqx-operator/templates/webhook-validating-configuration.yaml @@ -76,14 +76,14 @@ webhooks: service: name: {{ include "emqx-operator.fullname" . }}-webhook-service namespace: {{ .Release.Namespace }} - path: /validate-apps-emqx-io-v2alpha2-emqx + path: /validate-apps-emqx-io-v2beta1-emqx failurePolicy: Fail name: validator.apps.emqx.io rules: - apiGroups: - apps.emqx.io apiVersions: - - v2alpha2 + - v2beta1 operations: - CREATE - UPDATE diff --git a/docs/directory.json b/docs/directory.json index 5df9e350f..043d9a213 100644 --- a/docs/directory.json +++ b/docs/directory.json @@ -97,8 +97,8 @@ "path": "reference/v2alpha1-reference" }, { - "title": "v2alpha2 Reference", - "path": "reference/v2alpha2-reference" + "title": "v2beta1 Reference", + "path": "reference/v2beta1-reference" } ] } @@ -213,8 +213,8 @@ "path": "reference/v2alpha1-reference" }, { - "title": "v2alpha2 参考", - "path": "reference/v2alpha2-reference" + "title": "v2beta1 参考", + "path": "reference/v2beta1-reference" } ] } diff --git a/docs/en_US/deployment/on-aws-eks.md b/docs/en_US/deployment/on-aws-eks.md index 3bef4680f..be663cc20 100644 --- a/docs/en_US/deployment/on-aws-eks.md +++ b/docs/en_US/deployment/on-aws-eks.md @@ -19,12 +19,12 @@ Before you begin, you must have the following: The following is the relevant configuration of EMQX custom resources. You can select the corresponding APIVersion according to the EMQX version you want to deploy. For the specific compatibility relationship, please refer to [Compatibility list between EMQX and EMQX Operator](../index.md) :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + Save the following content as a YAML file and deploy it via the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -171,7 +171,7 @@ The following is the relevant configuration of EMQX custom resources. You can se + Obtain External IP of EMQX cluster :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/deployment/on-azure-aks.md b/docs/en_US/deployment/on-azure-aks.md index 2e19197cf..8d6d14e46 100644 --- a/docs/en_US/deployment/on-azure-aks.md +++ b/docs/en_US/deployment/on-azure-aks.md @@ -20,10 +20,10 @@ Before you begin, you must have the following: Here are the relevant configurations for EMQX Custom Resource. You can choose the corresponding APIVersion based on the version of EMQX you wish to deploy. For specific compatibility relationships, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -133,7 +133,7 @@ Access the EMQX console by opening a web browser and visiting http://20.245.123. - Retrieve External IP of the EMQX cluster :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 ```shell external_ip=$(kubectl get svc emqx-ee -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/deployment/on-gcp-gke.md b/docs/en_US/deployment/on-gcp-gke.md index b76545b12..debc77b41 100644 --- a/docs/en_US/deployment/on-gcp-gke.md +++ b/docs/en_US/deployment/on-gcp-gke.md @@ -34,13 +34,13 @@ Before you begin, you must have the following: Here are the relevant configurations for EMQX Custom Resource. You can choose the corresponding APIVersion based on the version of EMQX you wish to deploy. For specific compatibility relationships, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 Save the following content as a YAML file and deploy it using the `kubectl apply` command. ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -157,7 +157,7 @@ external_ip=$(kubectl get svc emqx-ee -o json | jq '.status.loadBalancer.ingress ``` ::: -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 ```shell external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/getting-started/getting-started.md b/docs/en_US/getting-started/getting-started.md index 4c6cf0eb3..fde99248f 100644 --- a/docs/en_US/getting-started/getting-started.md +++ b/docs/en_US/getting-started/getting-started.md @@ -64,7 +64,7 @@ Alternatively, if you are interested in learning how to upgrade or uninstall EMQ 1. Save the following content as a YAML file and deploy it with the `kubectl apply`. ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx-ee @@ -72,7 +72,7 @@ Alternatively, if you are interested in learning how to upgrade or uninstall EMQ image: emqx/emqx-enterprise:5.1.0 ``` - For more details about the EMQX CRD, please check the [reference document](../reference/v2alpha2-reference.md). + For more details about the EMQX CRD, please check the [reference document](../reference/v2beta1-reference.md). 2. Wait the EMQX cluster is running. @@ -91,7 +91,7 @@ Alternatively, if you are interested in learning how to upgrade or uninstall EMQ 1. Save the following content as a YAML file and deploy it with the `kubectl apply`. ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -99,7 +99,7 @@ Alternatively, if you are interested in learning how to upgrade or uninstall EMQ image: emqx:5.1 ``` - For more details about the EMQX CRD, please check the [reference document](../reference/v2alpha2-reference.md). + For more details about the EMQX CRD, please check the [reference document](../reference/v2beta1-reference.md). 2. Wait the EMQX cluster is running. diff --git a/docs/en_US/index.md b/docs/en_US/index.md index e458efb63..cc31c6271 100644 --- a/docs/en_US/index.md +++ b/docs/en_US/index.md @@ -21,7 +21,7 @@ The EMQX Operator includes, but is not limited to, the following features: | 4.4.8 (included) ~ 4.4.14 | 1.2.6, 1.2.7, 1.2.8, 2.0.0, 2.0.1, 2.0.2, 2.0.3 | [apps.emqx.io/v1beta3](./reference/v1beta3-reference.md) | EmqxEnterprise | | 4.4.14 or higher 4.4.x | 2.1.0, 2.1.1 | [apps.emqx.io/v1beta4](./reference/v1beta4-reference.md) | EmqxEnterprise | | 5.0.0 (included) ~ 5.0.23 | 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2alpha2](./reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2beta1](./reference/v2beta1-reference.md) | EMQX | ### EMQX Open Source @@ -35,7 +35,7 @@ The EMQX Operator includes, but is not limited to, the following features: | 5.0.6 (included) ~ 5.0.8 | 2.0.0, 2.0.1, 2.0.3 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | | 5.0.8 (included) ~ 5.0.14 | 2.0.2 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | | 5.0.14 (included) ~ 5.0.23 | 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2alpha2](./reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 or higher | 2.2.0 | [apps.emqx.io/v2beta1](./reference/v2beta1-reference.md) | EMQX | ## How to selector Kubernetes version diff --git a/docs/en_US/reference/overview.md b/docs/en_US/reference/overview.md index 9a1393690..bb1507839 100644 --- a/docs/en_US/reference/overview.md +++ b/docs/en_US/reference/overview.md @@ -5,4 +5,4 @@ This section of the Kubernetes documentation contains references. + [apps.emqx.io/v1beta3](./v1beta3-reference.md) + [apps.emqx.io/v1beta4](./v1beta4-reference.md) + [apps.emqx.io/v2alpha1](./v2alpha1-reference.md) -+ [apps.emqx.io/v2alpha2](./v2alpha2-reference.md) ++ [apps.emqx.io/v2beta1](./v2beta1-reference.md) diff --git a/docs/en_US/reference/v2alpha2-reference.md b/docs/en_US/reference/v2beta1-reference.md similarity index 98% rename from docs/en_US/reference/v2alpha2-reference.md rename to docs/en_US/reference/v2beta1-reference.md index 4005c087e..294f22bad 100644 --- a/docs/en_US/reference/v2alpha2-reference.md +++ b/docs/en_US/reference/v2beta1-reference.md @@ -1,12 +1,12 @@ # API Reference ## Packages -- [apps.emqx.io/v2alpha2](#appsemqxiov2alpha2) +- [apps.emqx.io/v2beta1](#appsemqxiov2beta1) -## apps.emqx.io/v2alpha2 +## apps.emqx.io/v2beta1 -Package v2alpha2 contains API Schema definitions for the apps v2alpha2 API group +Package v2beta1 contains API Schema definitions for the apps v2beta1 API group ### Resource Types - [EMQX](#emqx) @@ -57,7 +57,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `EMQX` | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `spec` _[EMQXSpec](#emqxspec)_ | Spec defines the desired identities of EMQX nodes in this set. | @@ -124,7 +124,7 @@ EMQXList contains a list of EMQX | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `EMQXList` | `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `items` _[EMQX](#emqx) array_ | | @@ -333,7 +333,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `Rebalance` | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `spec` _[RebalanceSpec](#rebalancespec)_ | | @@ -380,7 +380,7 @@ RebalanceList contains a list of Rebalance | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `RebalanceList` | `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `items` _[Rebalance](#rebalance) array_ | | @@ -408,7 +408,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `instanceKind` _string_ | InstanceKind is used to distinguish between EMQX and EMQXEnterprise. When it is set to "EMQX", it means that the EMQX CR is v2alpha2, and when it is set to "EmqxEnterprise", it means that the EmqxEnterprise CR is v1beta4. | +| `instanceKind` _string_ | InstanceKind is used to distinguish between EMQX and EMQXEnterprise. When it is set to "EMQX", it means that the EMQX CR is v2beta1, and when it is set to "EmqxEnterprise", it means that the EmqxEnterprise CR is v1beta4. | | `instanceName` _string_ | InstanceName represents the name of EMQX CR, just work for EMQX Enterprise | | `rebalanceStrategy` _[RebalanceStrategy](#rebalancestrategy)_ | RebalanceStrategy represents the strategy of EMQX rebalancing More info: https://docs.emqx.com/en/enterprise/v4.4/advanced/rebalancing.html#rebalancing | diff --git a/docs/en_US/tasks/configure-emqx-blueGreenUpdate.md b/docs/en_US/tasks/configure-emqx-blueGreenUpdate.md index b730dc9e0..a35cc29fc 100644 --- a/docs/en_US/tasks/configure-emqx-blueGreenUpdate.md +++ b/docs/en_US/tasks/configure-emqx-blueGreenUpdate.md @@ -6,7 +6,7 @@ How to gracefully upgrade the EMQX cluster through blue-green deployment :::tip -This feature only supports `apps.emqx.io/v1beta4 EmqxEnterprise` and `apps.emqx.io/v2alpha2 EMQX`. +This feature only supports `apps.emqx.io/v1beta4 EmqxEnterprise` and `apps.emqx.io/v2beta1 EMQX`. ::: @@ -103,12 +103,12 @@ timeline ### Configuration update strategy :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -Create `apps.emqx.io/v2alpha2` EMQX and configure update strategy. +Create `apps.emqx.io/v2beta1` EMQX and configure update strategy. ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/en_US/tasks/configure-emqx-config.md b/docs/en_US/tasks/configure-emqx-config.md index 35f6bc366..bdd90a7df 100644 --- a/docs/en_US/tasks/configure-emqx-config.md +++ b/docs/en_US/tasks/configure-emqx-config.md @@ -8,12 +8,12 @@ Change EMQX configuration by `config.data` in EMQX Custom Resource. The main configuration file of EMQX is `/etc/emqx.conf`. Starting from version 5.0, EMQX adopts [HOCON](https://www.emqx.io/docs/en/v5.1/configuration/configuration.html#hocon-configuration-format) as the configuration file format. -`apps.emqx.io/v2alpha2 EMQX` supports configuring EMQX cluster through `.spec.config.data` field. For config.data configuration, please refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). +`apps.emqx.io/v2beta1 EMQX` supports configuring EMQX cluster through `.spec.config.data` field. For config.data configuration, please refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). + Save the following content as a YAML file and deploy it with the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/en_US/tasks/configure-emqx-core-replicant.md b/docs/en_US/tasks/configure-emqx-core-replicant.md index 32b4aff20..c0c453def 100644 --- a/docs/en_US/tasks/configure-emqx-core-replicant.md +++ b/docs/en_US/tasks/configure-emqx-core-replicant.md @@ -19,12 +19,12 @@ There must be at least one Core node in the EMQX cluster. For the purpose of hig ## Configure EMQX Cluster -`apps.emqx.io/v2alpha2 EMQX` supports configuring the Core node of the EMQX cluster through the `.spec.coreTemplate` field, and configuring the Replicant node of the EMQX cluster using the `.spec.replicantTemplate` field. For more information, please refer to: [API Reference](../reference/v2alpha2-reference.md#emqxspec). +`apps.emqx.io/v2beta1 EMQX` supports configuring the Core node of the EMQX cluster through the `.spec.coreTemplate` field, and configuring the Replicant node of the EMQX cluster using the `.spec.replicantTemplate` field. For more information, please refer to: [API Reference](../reference/v2beta1-reference.md#emqxspec). + Save the following content as a YAML file and deploy it with the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/en_US/tasks/configure-emqx-license.md b/docs/en_US/tasks/configure-emqx-license.md index cc376548f..e4d67c4c6 100644 --- a/docs/en_US/tasks/configure-emqx-license.md +++ b/docs/en_US/tasks/configure-emqx-license.md @@ -14,16 +14,16 @@ The following is the relevant configuration of EMQX Custom Resource. You can cho ## Configure EMQX Cluster :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 - `apps.emqx.io/v2alpha2 EMQX` supports configuring EMQX cluster license through `.spec.config.data`. For config.data configuration, please refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). This field is only allowed to be configured when creating an EMQX cluster, and does not support updating. + `apps.emqx.io/v2beta1 EMQX` supports configuring EMQX cluster license through `.spec.config.data`. For config.data configuration, please refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). This field is only allowed to be configured when creating an EMQX cluster, and does not support updating. > After the EMQX cluster is created, if the license needs to be updated, please update it through the EMQX Dashboard. + Save the following content as a YAML file and deploy it via the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx-ee @@ -124,7 +124,7 @@ The following is the relevant configuration of EMQX Custom Resource. You can cho ## Update License :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + View License information ```bash diff --git a/docs/en_US/tasks/configure-emqx-log-level.md b/docs/en_US/tasks/configure-emqx-log-level.md index c5d14eafa..4002d5ba5 100644 --- a/docs/en_US/tasks/configure-emqx-log-level.md +++ b/docs/en_US/tasks/configure-emqx-log-level.md @@ -9,16 +9,16 @@ Modify the log level of EMQX cluster. The following is the relevant configuration of EMQX Custom Resource. You can choose the corresponding APIVersion according to the version of EMQX you want to deploy. For the specific compatibility relationship, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` supports configuration of EMQX cluster log level through `.spec.config.data`. The configuration of config.data can refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). +`apps.emqx.io/v2beta1 EMQX` supports configuration of EMQX cluster log level through `.spec.config.data`. The configuration of config.data can refer to the document: [Configuration Manual](https://www.emqx.io/docs/en/v5.1/configuration/configuration-manual.html#configuration-manual). > This field is only allowed to be configured when creating an EMQX cluster, and does not support updating. If you need to modify the cluster log level after creating EMQX, please modify it through EMQX Dashboard. + Save the following content as a YAML file and deploy it with the kubectl apply command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -110,7 +110,7 @@ The following is the relevant configuration of EMQX Custom Resource. You can cho + Obtain the External IP of EMQX cluster :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/tasks/configure-emqx-persistence.md b/docs/en_US/tasks/configure-emqx-persistence.md index 7143195b3..0f6078f66 100644 --- a/docs/en_US/tasks/configure-emqx-persistence.md +++ b/docs/en_US/tasks/configure-emqx-persistence.md @@ -10,16 +10,16 @@ The following is the relevant configuration of EMQX Custom Resource. You can choose the corresponding APIVersion according to the version of EMQX you want to deploy. For the specific compatibility relationship, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` supports configuration of EMQX cluster Core node persistence through `.spec.coreTemplate.spec.volumeClaimTemplates` field. The semantics and configuration of `.spec.coreTemplate.spec.volumeClaimTemplates` field are consistent with `PersistentVolumeClaimSpec` of Kubernetes, and its configuration can refer to the document: [PersistentVolumeClaimSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#persistentvolumeclaimspec-v1-core). +`apps.emqx.io/v2beta1 EMQX` supports configuration of EMQX cluster Core node persistence through `.spec.coreTemplate.spec.volumeClaimTemplates` field. The semantics and configuration of `.spec.coreTemplate.spec.volumeClaimTemplates` field are consistent with `PersistentVolumeClaimSpec` of Kubernetes, and its configuration can refer to the document: [PersistentVolumeClaimSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#persistentvolumeclaimspec-v1-core). When the user configures the `.spec.coreTemplate.spec.volumeClaimTemplates` field, EMQX Operator will mount the `/opt/emqx/data` directory in the EMQX container to [StorageClass](https://kubernetes.io/docs/concepts/storage/storage-classes/) in the PV and PVC created, when the EMQX Pod is deleted, the PV and PVC will not be deleted, so as to achieve the purpose of saving EMQX runtime data. For more information about PV and PVC, refer to the document [Persistent Volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/). + Save the following content as a YAML file and deploy it via the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -134,7 +134,7 @@ Verification scheme: 1) Passed in the old EMQX Dashboard creates a test rule; 2) + Access EMQX Dashboard through browser to create test rules :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/tasks/configure-emqx-prometheus.md b/docs/en_US/tasks/configure-emqx-prometheus.md index 67652e4a5..125c2b9ee 100644 --- a/docs/en_US/tasks/configure-emqx-prometheus.md +++ b/docs/en_US/tasks/configure-emqx-prometheus.md @@ -13,12 +13,12 @@ Grafana' deployment documentation can refer to [Grafana](https://grafana.com/doc Here are the relevant configurations for EMQX Custom Resource. You can choose the corresponding APIVersion based on the version of EMQX you wish to deploy. For specific compatibility relationships, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab v2alpha2 +::: tab v2beta1 EMQX supports exposing indicators through the http interface. For all statistical indicators under the cluster, please refer to the document: [Integrate with Prometheus](https://www.emqx.io/docs/en/v5.1/observability/prometheus.html) ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -190,7 +190,7 @@ emqx-exporter-856564c95-j4q5v Running 8m33s Prometheus-operator uses [PodMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#podmonitor) and [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#servicemonitor) CRD to define how to monitor a set of pods or services dynamically. :::: tabs type:card -::: tab v2alpha2 +::: tab v2beta1 ```yaml apiVersion: monitoring.coreos.com/v1 diff --git a/docs/en_US/tasks/configure-emqx-rebalance.md b/docs/en_US/tasks/configure-emqx-rebalance.md index e1f8a4897..38f85b07a 100644 --- a/docs/en_US/tasks/configure-emqx-rebalance.md +++ b/docs/en_US/tasks/configure-emqx-rebalance.md @@ -30,7 +30,7 @@ The corresponding CRD of the cluster rebalancing in EMQX Operator is `Rebalance` ::: tab EMQX Enterprise 5.x ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: Rebalance metadata: name: rebalance-sample @@ -47,14 +47,14 @@ spec: relSessThreshold: "1.1" ``` -> For Rebalance configuration, please refer to the document: [Rebalance reference](../reference/v2alpha2-reference.md#rebalancestrategy). +> For Rebalance configuration, please refer to the document: [Rebalance reference](../reference/v2beta1-reference.md#rebalancestrategy). ::: ::: tab EMQX Enterprise 4.x ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: Rebalance metadata: name: rebalance-sample diff --git a/docs/en_US/tasks/configure-emqx-service.md b/docs/en_US/tasks/configure-emqx-service.md index 6f190006c..f44ef3589 100644 --- a/docs/en_US/tasks/configure-emqx-service.md +++ b/docs/en_US/tasks/configure-emqx-service.md @@ -9,14 +9,14 @@ Access the EMQX cluster through the Service of LoadBalancer type. The following is the relevant configuration of EMQX Custom Resource. You can choose the corresponding APIVersion according to the version of EMQX you want to deploy. For the specific compatibility relationship, please refer to [EMQX Operator Compatibility](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` supports configuring EMQX cluster Dashboard Service through `.spec.dashboardServiceTemplate`, and configuring EMQX cluster listener Service through `.spec.listenersServiceTemplate`, its documentation can refer to [Service](../reference/v2alpha2-reference.md#emqxspec). +`apps.emqx.io/v2beta1 EMQX` supports configuring EMQX cluster Dashboard Service through `.spec.dashboardServiceTemplate`, and configuring EMQX cluster listener Service through `.spec.listenersServiceTemplate`, its documentation can refer to [Service](../reference/v2beta1-reference.md#emqxspec). + Save the following content as a YAML file and deploy it via the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -104,7 +104,7 @@ The following is the relevant configuration of EMQX Custom Resource. You can cho + Obtain the External IP of the EMQX cluster :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/en_US/tasks/configure-emqx-tls.md b/docs/en_US/tasks/configure-emqx-tls.md index 95f4687c5..2bd1b1ba9 100644 --- a/docs/en_US/tasks/configure-emqx-tls.md +++ b/docs/en_US/tasks/configure-emqx-tls.md @@ -100,16 +100,16 @@ There are many types of Volumes. For the description of Volumes, please refer to Access `http://192.168.1.200:18083` through a browser, and use the default username and password `admin/public` to login EMQX console. ::: -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` supports `.spec.coreTemplate.extraVolumes` and `.spec.coreTemplate.extraVolumeMounts` and `.spec.replicantTemplate.extraVolumes` and `.spec.replicantTemplate.extraVolumeMounts` fields to EMQX The cluster configures additional volumes and mount points. In this article, we can use these two fields to configure TLS certificates for the EMQX cluster. +`apps.emqx.io/v2beta1 EMQX` supports `.spec.coreTemplate.extraVolumes` and `.spec.coreTemplate.extraVolumeMounts` and `.spec.replicantTemplate.extraVolumes` and `.spec.replicantTemplate.extraVolumeMounts` fields to EMQX The cluster configures additional volumes and mount points. In this article, we can use these two fields to configure TLS certificates for the EMQX cluster. There are many types of Volumes. For the description of Volumes, please refer to the document: [Volumes](https://kubernetes.io/docs/concepts/storage/volumes/#secret). In this article we are using the `secret` type. + Save the following as a YAML file and deploy it with the `kubectl apply` command ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -188,7 +188,7 @@ There are many types of Volumes. For the description of Volumes, please refer to + Obtain the External IP of EMQX cluster :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/deployment/on-alibaba-cloud.md b/docs/zh_CN/deployment/on-alibaba-cloud.md index c689f5d67..f67bcfe09 100644 --- a/docs/zh_CN/deployment/on-alibaba-cloud.md +++ b/docs/zh_CN/deployment/on-alibaba-cloud.md @@ -20,12 +20,12 @@ EMQX Operator 支持在阿里云容器服务 Kubernetes 版部署 EMQX。阿里 下面是 EMQX 自定义资源的相关配置。你可以根据你想部署的 EMQX 版本选择相应的 APIVersion。关于具体的兼容性关系,请参考[EMQX 与 EMQX Operator 的兼容性列表](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它。 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -158,7 +158,7 @@ EMQX Operator 支持在阿里云容器服务 Kubernetes 版部署 EMQX。阿里 ``` ::: - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') ``` @@ -204,10 +204,10 @@ EMQX Operator 支持在阿里云容器服务 Kubernetes 版部署 EMQX。阿里 :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/zh_CN/deployment/on-aws-eks.md b/docs/zh_CN/deployment/on-aws-eks.md index a9f300184..6b27c5cc3 100644 --- a/docs/zh_CN/deployment/on-aws-eks.md +++ b/docs/zh_CN/deployment/on-aws-eks.md @@ -19,12 +19,12 @@ EMQX Operator 支持在 Amazon 容器服务 EKS(Elastic Kubernetes Service) 下面是 EMQX 自定义资源的相关配置。你可以根据你想部署的 EMQX 版本选择相应的 APIVersion。关于具体的兼容性关系,请参考 [EMQX 与 EMQX Operator 的兼容性列表](../index.md) :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -179,7 +179,7 @@ EMQX Operator 支持在 Amazon 容器服务 EKS(Elastic Kubernetes Service) + 获取 EMQX 集群的 External IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/deployment/on-azure-aks.md b/docs/zh_CN/deployment/on-azure-aks.md index ed5e7f77a..d3fc2bb84 100644 --- a/docs/zh_CN/deployment/on-azure-aks.md +++ b/docs/zh_CN/deployment/on-azure-aks.md @@ -20,10 +20,10 @@ EMQX 是一款高性能的开源分布式物联网 MQTT 消息服务器,它提 以下是 EMQX Custom Resource 的相关配置。您可以根据您想要部署的 EMQX 版本选择相应的 APIVersion。具体的兼容关系,请参考 [EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -132,7 +132,7 @@ MQTT X CLI 是一个开源的 MQTT 5.0 命令行客户端工具,旨在帮助 - 获取 EMQX 集群的外部 IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```shell external_ip=$(kubectl get svc emqx-ee -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/deployment/on-gcp-gke.md b/docs/zh_CN/deployment/on-gcp-gke.md index 7aa8e45ed..b62c23b9f 100644 --- a/docs/zh_CN/deployment/on-gcp-gke.md +++ b/docs/zh_CN/deployment/on-gcp-gke.md @@ -32,12 +32,12 @@ EMQX 是一款高性能的开源分布式物联网 MQTT 消息服务器,它提 以下是 EMQX 自定义资源的相关配置。您可以根据您希望部署的 EMQX 版本选择相应的 APIVersion。有关具体的兼容关系,请参阅 [EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 将以下内容保存为 YAML 文件,并使用 kubectl apply 命令进行部署。 ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -145,7 +145,7 @@ MQTT X CLI 是一个开源的 MQTT 5.0 命令行客户端工具,旨在帮助 - 获取 EMQX 集群的外部 IP 地址 :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```shell external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/deployment/on-huawei-cloud.md b/docs/zh_CN/deployment/on-huawei-cloud.md index 40e819de0..add16ab7f 100644 --- a/docs/zh_CN/deployment/on-huawei-cloud.md +++ b/docs/zh_CN/deployment/on-huawei-cloud.md @@ -30,12 +30,12 @@ EMQX Operator 支持在华为云容器引擎(Cloud Container Engine,简称 C 下面是 EMQX 自定义资源的相关配置。你可以根据你想部署的 EMQX 版本选择相应的 APIVersion。关于具体的兼容性关系,请参考[ EMQX 与 EMQX Operator 的兼容性列表](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -175,7 +175,7 @@ EMQX Operator 支持在华为云容器引擎(Cloud Container Engine,简称 C + 获取 EMQX 集群的 External IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/deployment/on-tencent-cloud.md b/docs/zh_CN/deployment/on-tencent-cloud.md index 34553a7df..a2a2b0f6e 100644 --- a/docs/zh_CN/deployment/on-tencent-cloud.md +++ b/docs/zh_CN/deployment/on-tencent-cloud.md @@ -20,12 +20,12 @@ EMQX Operator 支持在腾讯云容器服务(Tencent Kubernetes Engine,TKE 下面是 EMQX 自定义资源的相关配置。你可以根据你想部署的 EMQX 版本选择相应的 APIVersion。关于具体的兼容性关系,请参考[ EMQX 与 EMQX Operator 的兼容性列表](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -152,7 +152,7 @@ EMQX Operator 支持在腾讯云容器服务(Tencent Kubernetes Engine,TKE external_ip=$(kubectl get svc emqx-ee -o json | jq '.status.loadBalancer.ingress[0].ip') ``` ::: - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/getting-started/getting-started.md b/docs/zh_CN/getting-started/getting-started.md index ddc565bbd..7c8b3809f 100644 --- a/docs/zh_CN/getting-started/getting-started.md +++ b/docs/zh_CN/getting-started/getting-started.md @@ -62,7 +62,7 @@ 1. 将下面的 YAML 配置文件保存为 `emqx.yaml`。 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx-ee @@ -76,7 +76,7 @@ $ kubectl apply -f emqx.yaml ``` - 关于 EMQX 自定义资源的更多信息,请查看 [API 参考](../reference/v2alpha2-reference.md) + 关于 EMQX 自定义资源的更多信息,请查看 [API 参考](../reference/v2beta1-reference.md) 2. 检查 EMQX 集群状态,请确保 STATUS 为 Running,这可能需要一些时间等待 EMQX 集群准备就绪。 @@ -93,7 +93,7 @@ 1. 将下面的 YAML 配置文件保存为 `emqx.yaml`。 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -107,7 +107,7 @@ $ kubectl apply -f emqx.yaml ``` - 关于 EMQX 自定义资源的更多信息,请查看 [API 参考](../reference/v2alpha2-reference.md) + 关于 EMQX 自定义资源的更多信息,请查看 [API 参考](../reference/v2beta1-reference.md) 2. 检查 EMQX 集群状态,请确保 STATUS 为 Running,这可能需要一些时间等待 EMQX 集群准备就绪。 diff --git a/docs/zh_CN/index.md b/docs/zh_CN/index.md index cacb880b5..6e6bec62c 100644 --- a/docs/zh_CN/index.md +++ b/docs/zh_CN/index.md @@ -21,7 +21,7 @@ EMQX Operator 包括但不限于以下功能: | 4.4.8 (包含) ~ 4.4.14 | 1.2.6, 1.2.7, 1.2.8, 2.0.0, 2.0.1, 2.0.2, 2.0.3 | [apps.emqx.io/v1beta3](./reference/v1beta3-reference.md) | EmqxEnterprise | | 4.4.14 (包含) 或更高 4.4.x | 2.1.0, 2.1.1 | [apps.emqx.io/v1beta4](./reference/v1beta4-reference.md) | EmqxEnterprise | | 5.0.0 (包含) ~ 5.0.23 | 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 或更高 | 2.2.0 | [apps.emqx.io/v2alpha2](./reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 或更高 | 2.2.0 | [apps.emqx.io/v2beta1](./reference/v2beta1-reference.md) | EMQX | ### EMQX 开源版 @@ -34,7 +34,7 @@ EMQX Operator 包括但不限于以下功能: | 5.0.6 (包含) ~ 5.0.8 | 2.0.0, 2.0.1, 2.0.3 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | | 5.0.8 (包含) ~ 5.0.14 | 2.0.2 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | | 5.0.14 (包含) ~ 5.0.23 | 2.1.0, 2.1.1 | [apps.emqx.io/v2alpha1](./reference/v2alpha1-reference.md) | EMQX | -| 5.1.1 或更高 | 2.2.0 | [apps.emqx.io/v2alpha2](./reference/v2alpha2-reference.md) | EMQX | +| 5.1.1 或更高 | 2.2.0 | [apps.emqx.io/v2beta1](./reference/v2beta1-reference.md) | EMQX | ## 如何选择 Kubernetes 版本 diff --git a/docs/zh_CN/reference/overview.md b/docs/zh_CN/reference/overview.md index 9a1393690..bb1507839 100644 --- a/docs/zh_CN/reference/overview.md +++ b/docs/zh_CN/reference/overview.md @@ -5,4 +5,4 @@ This section of the Kubernetes documentation contains references. + [apps.emqx.io/v1beta3](./v1beta3-reference.md) + [apps.emqx.io/v1beta4](./v1beta4-reference.md) + [apps.emqx.io/v2alpha1](./v2alpha1-reference.md) -+ [apps.emqx.io/v2alpha2](./v2alpha2-reference.md) ++ [apps.emqx.io/v2beta1](./v2beta1-reference.md) diff --git a/docs/zh_CN/reference/v2alpha2-reference.md b/docs/zh_CN/reference/v2beta1-reference.md similarity index 98% rename from docs/zh_CN/reference/v2alpha2-reference.md rename to docs/zh_CN/reference/v2beta1-reference.md index 4005c087e..294f22bad 100644 --- a/docs/zh_CN/reference/v2alpha2-reference.md +++ b/docs/zh_CN/reference/v2beta1-reference.md @@ -1,12 +1,12 @@ # API Reference ## Packages -- [apps.emqx.io/v2alpha2](#appsemqxiov2alpha2) +- [apps.emqx.io/v2beta1](#appsemqxiov2beta1) -## apps.emqx.io/v2alpha2 +## apps.emqx.io/v2beta1 -Package v2alpha2 contains API Schema definitions for the apps v2alpha2 API group +Package v2beta1 contains API Schema definitions for the apps v2beta1 API group ### Resource Types - [EMQX](#emqx) @@ -57,7 +57,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `EMQX` | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `spec` _[EMQXSpec](#emqxspec)_ | Spec defines the desired identities of EMQX nodes in this set. | @@ -124,7 +124,7 @@ EMQXList contains a list of EMQX | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `EMQXList` | `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `items` _[EMQX](#emqx) array_ | | @@ -333,7 +333,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `Rebalance` | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `spec` _[RebalanceSpec](#rebalancespec)_ | | @@ -380,7 +380,7 @@ RebalanceList contains a list of Rebalance | Field | Description | | --- | --- | -| `apiVersion` _string_ | `apps.emqx.io/v2alpha2` +| `apiVersion` _string_ | `apps.emqx.io/v2beta1` | `kind` _string_ | `RebalanceList` | `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | `items` _[Rebalance](#rebalance) array_ | | @@ -408,7 +408,7 @@ _Appears in:_ | Field | Description | | --- | --- | -| `instanceKind` _string_ | InstanceKind is used to distinguish between EMQX and EMQXEnterprise. When it is set to "EMQX", it means that the EMQX CR is v2alpha2, and when it is set to "EmqxEnterprise", it means that the EmqxEnterprise CR is v1beta4. | +| `instanceKind` _string_ | InstanceKind is used to distinguish between EMQX and EMQXEnterprise. When it is set to "EMQX", it means that the EMQX CR is v2beta1, and when it is set to "EmqxEnterprise", it means that the EmqxEnterprise CR is v1beta4. | | `instanceName` _string_ | InstanceName represents the name of EMQX CR, just work for EMQX Enterprise | | `rebalanceStrategy` _[RebalanceStrategy](#rebalancestrategy)_ | RebalanceStrategy represents the strategy of EMQX rebalancing More info: https://docs.emqx.com/en/enterprise/v4.4/advanced/rebalancing.html#rebalancing | diff --git a/docs/zh_CN/tasks/configure-emqx-blueGreenUpdate.md b/docs/zh_CN/tasks/configure-emqx-blueGreenUpdate.md index 4b67409cb..c45c03ce0 100644 --- a/docs/zh_CN/tasks/configure-emqx-blueGreenUpdate.md +++ b/docs/zh_CN/tasks/configure-emqx-blueGreenUpdate.md @@ -6,7 +6,7 @@ :::tip -该功能仅支持 `apps.emqx.io/v1beta4 EmqxEnterprise` 及 `apps.emqx.io/v2alpha2 EMQX` +该功能仅支持 `apps.emqx.io/v1beta4 EmqxEnterprise` 及 `apps.emqx.io/v2beta1 EMQX` ::: @@ -98,12 +98,12 @@ timeline ### 配置更新策略 :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -创建 `apps.emqx.io/v2alpha2 EMQX`,并配置更新策略 +创建 `apps.emqx.io/v2beta1 EMQX`,并配置更新策略 ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/zh_CN/tasks/configure-emqx-config.md b/docs/zh_CN/tasks/configure-emqx-config.md index 9282cb188..d36243743 100644 --- a/docs/zh_CN/tasks/configure-emqx-config.md +++ b/docs/zh_CN/tasks/configure-emqx-config.md @@ -8,7 +8,7 @@ EMQX 主配置文件为 `etc/emqx.conf`,从 5.0 版本开始,EMQX 采用 [HOCON](https://www.emqx.io/docs/zh/v5.1/configuration/configuration.html#hocon-%E9%85%8D%E7%BD%AE%E6%A0%BC%E5%BC%8F) 作为配置文件格式。 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.config.data` 字段配置 EMQX 集群。EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.config.data` 字段配置 EMQX 集群。EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 :::tip 如果在创建 EMQX 之后需要修改集群配置,请通过 EMQX Dashboard 进行修改。 @@ -17,7 +17,7 @@ EMQX 主配置文件为 `etc/emqx.conf`,从 5.0 版本开始,EMQX 采用 [HO + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/zh_CN/tasks/configure-emqx-core-replicant.md b/docs/zh_CN/tasks/configure-emqx-core-replicant.md index 444fab015..6072e5807 100644 --- a/docs/zh_CN/tasks/configure-emqx-core-replicant.md +++ b/docs/zh_CN/tasks/configure-emqx-core-replicant.md @@ -19,12 +19,12 @@ EMQX 集群中至少要有一个 Core 节点,出于高可用的目的,EMQX O ## 部署 EMQX 集群 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.coreTemplate` 字段来配置 EMQX 集群 Core 节点,使用 `.spec.replicantTemplate` 字段来配置 EMQX 集群 Replicant 节点,更多信息请查看:[API 参考](../reference/v2alpha2-reference.md#emqxspec)。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.coreTemplate` 字段来配置 EMQX 集群 Core 节点,使用 `.spec.replicantTemplate` 字段来配置 EMQX 集群 Replicant 节点,更多信息请查看:[API 参考](../reference/v2beta1-reference.md#emqxspec)。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx diff --git a/docs/zh_CN/tasks/configure-emqx-license.md b/docs/zh_CN/tasks/configure-emqx-license.md index 826251401..dac0ccc77 100644 --- a/docs/zh_CN/tasks/configure-emqx-license.md +++ b/docs/zh_CN/tasks/configure-emqx-license.md @@ -14,16 +14,16 @@ EMQX 企业版 License 可以在 EMQ 官网免费申请:[申请 EMQX 企业版 ## 配置 EMQX 集群 :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.config.data` 配置 EMQX 集群 License,EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.config.data` 配置 EMQX 集群 License,EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 > 在创建 EMQX 集群之后,如果需要更新 License,请通过 EMQX Dashboard 进行更新。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx-ee @@ -126,7 +126,7 @@ EMQX 企业版 License 可以在 EMQ 官网免费申请:[申请 EMQX 企业版 ## 更新 License :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 + 查看 License 信息 diff --git a/docs/zh_CN/tasks/configure-emqx-log-level.md b/docs/zh_CN/tasks/configure-emqx-log-level.md index 511506d34..fe4415a09 100644 --- a/docs/zh_CN/tasks/configure-emqx-log-level.md +++ b/docs/zh_CN/tasks/configure-emqx-log-level.md @@ -9,16 +9,16 @@ 下面是 EMQX Custom Resource 的相关配置,你可以根据希望部署的 EMQX 的版本来选择对应的 APIVersion,具体的兼容性关系,请参考 [EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.config.data` 来配置 EMQX 集群日志等级,EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.config.data` 来配置 EMQX 集群日志等级,EMQX 配置可以参考文档:[配置手册](https://www.emqx.io/docs/zh/v5.1/configuration/configuration-manual.html#%E8%8A%82%E7%82%B9%E8%AE%BE%E7%BD%AE)。 > 这个字段只允许在创建 EMQX 集群的时候配置,不支持更新。如果在创建 EMQX 之后需要修改集群日志等级,请通过 EMQX Dashboard 进行修改。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -111,7 +111,7 @@ + 获取 EMQX 集群的 External IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/tasks/configure-emqx-persistence.md b/docs/zh_CN/tasks/configure-emqx-persistence.md index 0856dbaf9..04b54b291 100644 --- a/docs/zh_CN/tasks/configure-emqx-persistence.md +++ b/docs/zh_CN/tasks/configure-emqx-persistence.md @@ -10,16 +10,16 @@ 下面是 EMQX Custom Resource 的相关配置,你可以根据希望部署的 EMQX 的版本来选择对应的 APIVersion,具体的兼容性关系,请参考[EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.coreTemplate.spec.volumeClaimTemplates` 字段配置 EMQX 集群 Core 节点持久化。`.spec.coreTemplate.spec.volumeClaimTemplates` 字段的语义及配置与 Kubernetes 的 `PersistentVolumeClaimSpec` 一致,其配置可以参考文档:[PersistentVolumeClaimSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#persistentvolumeclaimspec-v1-core) 。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.coreTemplate.spec.volumeClaimTemplates` 字段配置 EMQX 集群 Core 节点持久化。`.spec.coreTemplate.spec.volumeClaimTemplates` 字段的语义及配置与 Kubernetes 的 `PersistentVolumeClaimSpec` 一致,其配置可以参考文档:[PersistentVolumeClaimSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#persistentvolumeclaimspec-v1-core) 。 当用户配置了 `.spec.coreTemplate.spec.volumeClaimTemplates` 字段时,EMQX Operator 会将 PVC(PersistentVolumeClaim) 作为 Volume 挂载到 EMQX Pod 中,PVC 表示用户持久化请求,最终负责存储的是持久化卷(PersistentVolume,PV),PV 和 PVC 是一一对应的。EMQX Operator 使用 [StorageClass](https://kubernetes.io/zh-cn/docs/concepts/storage/storage-classes/) 动态创建 PV,PV 存储了 EMQX 容器中 `/opt/emqx/data` 目录下的数据,当用户不再使用 PV 资源时,可以手动删除 PVC 对象,从而允许该 PV 资源被回收再利用。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -135,7 +135,7 @@ + 通过浏览器访问 EMQX Dashboard 创建测试规则 :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/tasks/configure-emqx-prometheus.md b/docs/zh_CN/tasks/configure-emqx-prometheus.md index 35d65ef07..c292794cc 100644 --- a/docs/zh_CN/tasks/configure-emqx-prometheus.md +++ b/docs/zh_CN/tasks/configure-emqx-prometheus.md @@ -13,12 +13,12 @@ Grafana 部署文档可以参考:[Grafana](https://grafana.com/docs/grafana/la 下面是 EMQX Custom Resource 的相关配置,你可以根据希望部署的 EMQX 的版本来选择对应的 APIVersion,具体的兼容性关系,请参考[EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab v2alpha2 +::: tab v2beta1 EMQX 支持通过 http 接口对外暴露指标,集群下所有统计指标数据可以参考文档:[集成 Prometheus](https://www.emqx.io/docs/zh/v5.1/observability/prometheus.html#%E9%9B%86%E6%88%90-prometheus) ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -201,7 +201,7 @@ emqx-exporter-856564c95-j4q5v Running 8m33s Prometheus-operator 使用 [PodMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#podmonitor) 和 [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#servicemonitor) CRD 定义如何动态的监视一组 pod 或者 service。 :::: tabs type:card -::: tab v2alpha2 +::: tab v2beta1 ```yaml apiVersion: monitoring.coreos.com/v1 diff --git a/docs/zh_CN/tasks/configure-emqx-rebalance.md b/docs/zh_CN/tasks/configure-emqx-rebalance.md index f28e94c5a..2527dd285 100644 --- a/docs/zh_CN/tasks/configure-emqx-rebalance.md +++ b/docs/zh_CN/tasks/configure-emqx-rebalance.md @@ -31,7 +31,7 @@ ::: tab EMQX Enterprise 5.x ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: Rebalance metadata: name: rebalance-sample @@ -48,14 +48,14 @@ spec: relSessThreshold: "1.1" ``` -> 关于 Rebalance 配置可以参考文档:[Rebalance reference](../reference/v2alpha2-reference.md#rebalancestrategy)。 +> 关于 Rebalance 配置可以参考文档:[Rebalance reference](../reference/v2beta1-reference.md#rebalancestrategy)。 ::: ::: tab EMQX Enterprise 4.x ```yaml -apiVersion: apps.emqx.io/v2alpha2 +apiVersion: apps.emqx.io/v2beta1 kind: Rebalance metadata: name: rebalance-sample diff --git a/docs/zh_CN/tasks/configure-emqx-service.md b/docs/zh_CN/tasks/configure-emqx-service.md index e65bcd7d6..fa2154cf4 100644 --- a/docs/zh_CN/tasks/configure-emqx-service.md +++ b/docs/zh_CN/tasks/configure-emqx-service.md @@ -9,14 +9,14 @@ 下面是 EMQX Custom Resource 的相关配置,你可以根据希望部署的 EMQX 的版本来选择对应的 APIVersion,具体的兼容性关系,请参考 [EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.dashboardServiceTemplate` 配置 EMQX 集群 Dashboard Service ,通过 `.spec.listenersServiceTemplate` 配置 EMQX 集群 listener Service,其文档可以参考:[Service](../reference/v2alpha2-reference.md#emqxspec)。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.dashboardServiceTemplate` 配置 EMQX 集群 Dashboard Service ,通过 `.spec.listenersServiceTemplate` 配置 EMQX 集群 listener Service,其文档可以参考:[Service](../reference/v2beta1-reference.md#emqxspec)。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -104,7 +104,7 @@ + 获取 EMQX 集群的 External IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/docs/zh_CN/tasks/configure-emqx-tls.md b/docs/zh_CN/tasks/configure-emqx-tls.md index a108b4f8f..c0e01d34a 100644 --- a/docs/zh_CN/tasks/configure-emqx-tls.md +++ b/docs/zh_CN/tasks/configure-emqx-tls.md @@ -38,16 +38,16 @@ Secret 是一种包含少量敏感信息例如密码、令牌或密钥的对象 下面是 EMQX Custom Resource 的相关配置,你可以根据希望部署的 EMQX 的版本来选择对应的 APIVersion,具体的兼容性关系,请参考 [EMQX Operator 兼容性](../index.md): :::: tabs type:card -::: tab apps.emqx.io/v2alpha2 +::: tab apps.emqx.io/v2beta1 -`apps.emqx.io/v2alpha2 EMQX` 支持通过 `.spec.coreTemplate.extraVolumes` 和 `.spec.coreTemplate.extraVolumeMounts` 以及 `.spec.replicantTemplate.extraVolumes` 和 `.spec.replicantTemplate.extraVolumeMounts` 字段给 EMQX 集群配置额外的卷和挂载点。在本文中我们可以使用这个两个字段为 EMQX 集群配置 TLS 证书。 +`apps.emqx.io/v2beta1 EMQX` 支持通过 `.spec.coreTemplate.extraVolumes` 和 `.spec.coreTemplate.extraVolumeMounts` 以及 `.spec.replicantTemplate.extraVolumes` 和 `.spec.replicantTemplate.extraVolumeMounts` 字段给 EMQX 集群配置额外的卷和挂载点。在本文中我们可以使用这个两个字段为 EMQX 集群配置 TLS 证书。 Volumes 的类型有很多种,关于 Volumes 描述可以参考文档:[Volumes](https://kubernetes.io/zh-cn/docs/concepts/storage/volumes/#secret)。在本文中我们使用的是 `secret` 类型。 + 将下面的内容保存成 YAML 文件,并通过 `kubectl apply` 命令部署它 ```yaml - apiVersion: apps.emqx.io/v2alpha2 + apiVersion: apps.emqx.io/v2beta1 kind: EMQX metadata: name: emqx @@ -186,7 +186,7 @@ Volumes 的类型有很多种,关于 Volumes 描述可以参考文档:[Volum + 获取 EMQX 集群的 External IP :::: tabs type:card - ::: tab apps.emqx.io/v2alpha2 + ::: tab apps.emqx.io/v2beta1 ```bash external_ip=$(kubectl get svc emqx-listeners -o json | jq '.status.loadBalancer.ingress[0].ip') diff --git a/e2e/v2alpha2/e2e_rebalance_test.go b/e2e/v2beta1/e2e_rebalance_test.go similarity index 86% rename from e2e/v2alpha2/e2e_rebalance_test.go rename to e2e/v2beta1/e2e_rebalance_test.go index 10186b3b7..ba3e8eda7 100644 --- a/e2e/v2alpha2/e2e_rebalance_test.go +++ b/e2e/v2beta1/e2e_rebalance_test.go @@ -1,11 +1,11 @@ -package v2alpha2 +package v2beta1 import ( "context" "fmt" appsv1beta4 "github.com/emqx/emqx-operator/apis/apps/v1beta4" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -19,16 +19,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -var rebalance = appsv2alpha2.Rebalance{ +var rebalance = appsv2beta1.Rebalance{ TypeMeta: metav1.TypeMeta{ Kind: "Rebalance", - APIVersion: appsv2alpha2.GroupVersion.String(), + APIVersion: appsv2beta1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: "rebalance", }, - Spec: appsv2alpha2.RebalanceSpec{ - RebalanceStrategy: appsv2alpha2.RebalanceStrategy{ + Spec: appsv2beta1.RebalanceSpec{ + RebalanceStrategy: appsv2beta1.RebalanceStrategy{ WaitTakeover: 10, ConnEvictRate: 10, SessEvictRate: 10, @@ -42,8 +42,8 @@ var rebalance = appsv2alpha2.Rebalance{ } var _ = Describe("EMQX 5 Rebalance Test", func() { - var instance *appsv2alpha2.EMQX - var r *appsv2alpha2.Rebalance + var instance *appsv2beta1.EMQX + var r *appsv2beta1.Rebalance BeforeEach(func() { instance = genEMQX().DeepCopy() instance.Spec.Image = "emqx/emqx-enterprise:5.1" @@ -89,14 +89,14 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { }) It("Rebalance will failed, because the EMQX is not found", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseFailed), + HaveField("Phase", appsv2beta1.RebalancePhaseFailed), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( - HaveField("Type", appsv2alpha2.RebalanceConditionFailed), + HaveField("Type", appsv2beta1.RebalanceConditionFailed), )), HaveField("Conditions", ContainElements( HaveField("Status", corev1.ConditionTrue), @@ -136,12 +136,12 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { Expect(k8sClient.Create(context.TODO(), instance)).Should(Succeed()) // check EMQX CR if created successfully - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), ) }) @@ -186,15 +186,15 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { }) By("Rebalance will failed, because the EMQX is nothing to balance", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseFailed), + HaveField("Phase", appsv2beta1.RebalancePhaseFailed), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( And( - HaveField("Type", appsv2alpha2.RebalanceConditionFailed), + HaveField("Type", appsv2beta1.RebalanceConditionFailed), HaveField("Status", corev1.ConditionTrue), HaveField("Message", ContainSubstring("Failed to start rebalance")), ), @@ -204,8 +204,8 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { By("Mock rebalance is in progress", func() { // mock rebalance processing - r.Status.Phase = appsv2alpha2.RebalancePhaseProcessing - r.Status.Conditions = []appsv2alpha2.RebalanceCondition{} + r.Status.Phase = appsv2beta1.RebalancePhaseProcessing + r.Status.Conditions = []appsv2beta1.RebalanceCondition{} Expect(k8sClient.Status().Update(context.TODO(), r)).Should(Succeed()) // update annotations for target reconciler @@ -215,14 +215,14 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { }) By("Rebalance should completed", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseCompleted), + HaveField("Phase", appsv2beta1.RebalancePhaseCompleted), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( - HaveField("Type", appsv2alpha2.RebalanceConditionCompleted), + HaveField("Type", appsv2beta1.RebalanceConditionCompleted), )), HaveField("Conditions", ContainElements( HaveField("Status", corev1.ConditionTrue), @@ -235,7 +235,7 @@ var _ = Describe("EMQX 5 Rebalance Test", func() { var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { var instance *appsv1beta4.EmqxEnterprise - var r *appsv2alpha2.Rebalance + var r *appsv2beta1.Rebalance BeforeEach(func() { instance = &appsv1beta4.EmqxEnterprise{ TypeMeta: metav1.TypeMeta{ @@ -244,7 +244,7 @@ var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { }, ObjectMeta: metav1.ObjectMeta{ Name: "emqx-ee", - Namespace: "e2e-test-v2alpha2" + "-" + rand.String(5), + Namespace: "e2e-test-v2beta1" + "-" + rand.String(5), Labels: map[string]string{ "test": "e2e", }, @@ -306,14 +306,14 @@ var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { }) It("Rebalance will failed, because the EMQX is not found", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseFailed), + HaveField("Phase", appsv2beta1.RebalancePhaseFailed), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( - HaveField("Type", appsv2alpha2.RebalanceConditionFailed), + HaveField("Type", appsv2beta1.RebalanceConditionFailed), )), HaveField("Conditions", ContainElements( HaveField("Status", corev1.ConditionTrue), @@ -400,15 +400,15 @@ var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { }) By("Rebalance will failed, because the EMQX is nothing to balance", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseFailed), + HaveField("Phase", appsv2beta1.RebalancePhaseFailed), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( And( - HaveField("Type", appsv2alpha2.RebalanceConditionFailed), + HaveField("Type", appsv2beta1.RebalanceConditionFailed), HaveField("Status", corev1.ConditionTrue), HaveField("Message", ContainSubstring("Failed to start rebalance")), ), @@ -418,8 +418,8 @@ var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { By("Mock rebalance is in progress", func() { // mock rebalance processing - r.Status.Phase = appsv2alpha2.RebalancePhaseProcessing - r.Status.Conditions = []appsv2alpha2.RebalanceCondition{} + r.Status.Phase = appsv2beta1.RebalancePhaseProcessing + r.Status.Conditions = []appsv2beta1.RebalanceCondition{} Expect(k8sClient.Status().Update(context.TODO(), r)).Should(Succeed()) // update annotations for target reconciler @@ -429,14 +429,14 @@ var _ = Describe("EMQX 4 Rebalance Test", Label("rebalance"), func() { }) By("Rebalance should completed", func() { - Eventually(func() appsv2alpha2.RebalanceStatus { + Eventually(func() appsv2beta1.RebalanceStatus { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(r), r) return r.Status }, timeout, interval).Should(And( - HaveField("Phase", appsv2alpha2.RebalancePhaseCompleted), + HaveField("Phase", appsv2beta1.RebalancePhaseCompleted), HaveField("RebalanceStates", BeNil()), HaveField("Conditions", ContainElements( - HaveField("Type", appsv2alpha2.RebalanceConditionCompleted), + HaveField("Type", appsv2beta1.RebalanceConditionCompleted), )), HaveField("Conditions", ContainElements( HaveField("Status", corev1.ConditionTrue), diff --git a/e2e/v2alpha2/e2e_test.go b/e2e/v2beta1/e2e_test.go similarity index 82% rename from e2e/v2alpha2/e2e_test.go rename to e2e/v2beta1/e2e_test.go index 36d9d5530..2db512fe1 100644 --- a/e2e/v2alpha2/e2e_test.go +++ b/e2e/v2beta1/e2e_test.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "context" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" gomegaTypes "github.com/onsi/gomega/types" @@ -34,7 +34,7 @@ import ( ) var _ = Describe("E2E Test", Label("base"), Ordered, func() { - var instance *appsv2alpha2.EMQX = new(appsv2alpha2.EMQX) + var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX) BeforeEach(func() { instance = emqx.DeepCopy() }) @@ -60,18 +60,18 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { }) It("should create EMQX CR successfully", func() { - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -81,10 +81,10 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Not(BeEmpty())), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, BeNil()), ), @@ -92,9 +92,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.CoreTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision, )) }) @@ -105,18 +105,18 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { instance.Spec.CoreTemplate.Spec.Replicas = pointer.Int32Ptr(3) Expect(k8sClient.Update(context.TODO(), instance)).Should(Succeed()) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -126,10 +126,10 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Not(BeEmpty())), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, BeNil()), ), @@ -137,9 +137,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.CoreTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision, )) }) @@ -150,18 +150,18 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { instance.Spec.CoreTemplate.Spec.Replicas = pointer.Int32Ptr(2) Expect(k8sClient.Update(context.TODO(), instance)).Should(Succeed()) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -171,10 +171,10 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Equal(storage.Status.CoreNodesStatus.CurrentRevision)), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, BeNil()), ), @@ -182,9 +182,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.CoreTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision, )) }) @@ -195,21 +195,21 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { instance.Spec.Image = "emqx:5.1" Expect(k8sClient.Update(context.TODO(), instance)).Should(Succeed()) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("CurrentRevision", Not(Equal(storage.Status.CoreNodesStatus.CurrentRevision))), HaveField("UpdateRevision", Not(Equal(storage.Status.CoreNodesStatus.CurrentRevision))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, BeNil()), ), @@ -217,9 +217,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.CoreTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.CoreNodesStatus.CurrentRevision, )) }) @@ -233,7 +233,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { client.MatchingLabels(instance.Labels), ) for i, sts := range list.Items { - if podTemplateHash, ok := sts.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { + if podTemplateHash, ok := sts.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { if podTemplateHash == instance.Status.CoreNodesStatus.CurrentRevision { list.Items = append(list.Items[:i], list.Items[i+1:]...) } @@ -288,8 +288,8 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { JustBeforeEach(func() { Expect(k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance)).Should(Succeed()) - instance.Spec.ReplicantTemplate = &appsv2alpha2.EMQXReplicantTemplate{ - Spec: appsv2alpha2.EMQXReplicantTemplateSpec{ + instance.Spec.ReplicantTemplate = &appsv2beta1.EMQXReplicantTemplate{ + Spec: appsv2beta1.EMQXReplicantTemplateSpec{ Replicas: pointer.Int32Ptr(2), }, } @@ -298,15 +298,15 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { }) It("should update EMQX CR successfully", func() { - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -316,7 +316,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Not(BeEmpty())), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), @@ -331,9 +331,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.ReplicantTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.ReplicantNodesStatus.CurrentRevision, )) }) @@ -344,18 +344,18 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { instance.Spec.ReplicantTemplate.Spec.Replicas = pointer.Int32Ptr(3) Expect(k8sClient.Update(context.TODO(), instance)).Should(Succeed()) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -365,10 +365,10 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Equal(storage.Status.CoreNodesStatus.CurrentRevision)), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) []appsv2alpha2.EMQXNode { + WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, HaveLen(int(*instance.Spec.ReplicantTemplate.Spec.Replicas))), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), @@ -383,9 +383,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.ReplicantTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.ReplicantNodesStatus.CurrentRevision, )) }) @@ -396,21 +396,21 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { instance.Spec.Image = "emqx/emqx:5.1" Expect(k8sClient.Update(context.TODO(), instance)).Should(Succeed()) - Eventually(func() *appsv2alpha2.EMQX { + Eventually(func() *appsv2beta1.EMQX { _ = k8sClient.Get(context.TODO(), client.ObjectKeyFromObject(instance), instance) return instance }).WithTimeout(timeout).WithPolling(interval).Should( And( - WithTransform(func(instance *appsv2alpha2.EMQX) bool { - return instance.Status.IsConditionTrue(appsv2alpha2.Ready) + WithTransform(func(instance *appsv2beta1.EMQX) bool { + return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), - WithTransform(func(instance *appsv2alpha2.EMQX) appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { return instance.Status.CoreNodesStatus }, And( HaveField("CurrentRevision", Not(Equal(storage.Status.CoreNodesStatus.CurrentRevision))), HaveField("UpdateRevision", Not(Equal(storage.Status.CoreNodesStatus.CurrentRevision))), )), - WithTransform(func(instance *appsv2alpha2.EMQX) *appsv2alpha2.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus }, And( HaveField("CurrentRevision", Not(Equal(storage.Status.ReplicantNodesStatus.CurrentRevision))), @@ -421,9 +421,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { checkServices(instance) checkPods(instance) - checkEndpoints(instance, appsv2alpha2.CloneAndAddLabel( + checkEndpoints(instance, appsv2beta1.CloneAndAddLabel( instance.Spec.ReplicantTemplate.Labels, - appsv2alpha2.PodTemplateHashLabelKey, + appsv2beta1.PodTemplateHashLabelKey, instance.Status.ReplicantNodesStatus.CurrentRevision, )) }) @@ -437,7 +437,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { client.MatchingLabels(instance.Labels), ) for i, sts := range list.Items { - if podTemplateHash, ok := sts.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { + if podTemplateHash, ok := sts.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { if podTemplateHash == instance.Status.ReplicantNodesStatus.CurrentRevision { list.Items = append(list.Items[:i], list.Items[i+1:]...) } @@ -460,7 +460,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { client.MatchingLabels(instance.Labels), ) for i, sts := range list.Items { - if podTemplateHash, ok := sts.Labels[appsv2alpha2.PodTemplateHashLabelKey]; ok { + if podTemplateHash, ok := sts.Labels[appsv2beta1.PodTemplateHashLabelKey]; ok { if podTemplateHash == instance.Status.CoreNodesStatus.CurrentRevision { list.Items = append(list.Items[:i], list.Items[i+1:]...) } @@ -520,7 +520,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { }) }) -func checkServices(instance *appsv2alpha2.EMQX) { +func checkServices(instance *appsv2beta1.EMQX) { Eventually(func() []corev1.ServicePort { svc := &corev1.Service{} _ = k8sClient.Get(context.TODO(), types.NamespacedName{Name: instance.Spec.ListenersServiceTemplate.Name, Namespace: instance.Namespace}, svc) @@ -561,7 +561,7 @@ func checkServices(instance *appsv2alpha2.EMQX) { ) } -func checkPods(instance *appsv2alpha2.EMQX) { +func checkPods(instance *appsv2beta1.EMQX) { podList := &corev1.PodList{} Eventually(func() []corev1.Pod { _ = k8sClient.List(context.TODO(), podList, @@ -575,7 +575,7 @@ func checkPods(instance *appsv2alpha2.EMQX) { HaveField("Status", And( HaveField("Phase", corev1.PodRunning), HaveField("Conditions", ContainElements( - HaveField("Type", appsv2alpha2.PodOnServing), + HaveField("Type", appsv2beta1.PodOnServing), HaveField("Type", corev1.PodReady), )))), ), @@ -583,7 +583,7 @@ func checkPods(instance *appsv2alpha2.EMQX) { ) } -func checkEndpoints(instance *appsv2alpha2.EMQX, labels map[string]string) { +func checkEndpoints(instance *appsv2beta1.EMQX, labels map[string]string) { podList := &corev1.PodList{} _ = k8sClient.List(context.TODO(), podList, client.InNamespace(instance.Namespace), diff --git a/e2e/v2alpha2/suite_test.go b/e2e/v2beta1/suite_test.go similarity index 88% rename from e2e/v2alpha2/suite_test.go rename to e2e/v2beta1/suite_test.go index 3ad4786ff..01c590ed2 100644 --- a/e2e/v2alpha2/suite_test.go +++ b/e2e/v2beta1/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha2 +package v2beta1 import ( "os" @@ -37,10 +37,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" appsv1beta4 "github.com/emqx/emqx-operator/apis/apps/v1beta4" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" appscontrollersv1beta4 "github.com/emqx/emqx-operator/controllers/apps/v1beta4" - appscontrollersv2alpha2 "github.com/emqx/emqx-operator/controllers/apps/v2alpha2" + appscontrollersv2beta1 "github.com/emqx/emqx-operator/controllers/apps/v2beta1" //+kubebuilder:scaffold:imports ) @@ -51,7 +51,7 @@ import ( var timeout, interval time.Duration var k8sClient client.Client var testEnv *envtest.Environment -var emqx *appsv2alpha2.EMQX +var emqx *appsv2beta1.EMQX func TestAPIs(t *testing.T) { RegisterFailHandler(Fail) @@ -96,7 +96,7 @@ var _ = BeforeSuite(func() { err = appsv1beta4.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = appsv2alpha2.AddToScheme(scheme.Scheme) + err = appsv2beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme @@ -116,10 +116,10 @@ var _ = BeforeSuite(func() { }).SetupWithManager(k8sManager) Expect(err).ToNot(HaveOccurred()) - err = appscontrollersv2alpha2.NewEMQXReconciler(k8sManager).SetupWithManager(k8sManager) + err = appscontrollersv2beta1.NewEMQXReconciler(k8sManager).SetupWithManager(k8sManager) Expect(err).ToNot(HaveOccurred()) - err = appscontrollersv2alpha2.NewRebalanceReconciler(k8sManager).SetupWithManager(k8sManager) + err = appscontrollersv2beta1.NewRebalanceReconciler(k8sManager).SetupWithManager(k8sManager) Expect(err).ToNot(HaveOccurred()) go func() { @@ -135,17 +135,17 @@ var _ = AfterSuite(func() { Expect(err).NotTo(HaveOccurred()) }) -func genEMQX() *appsv2alpha2.EMQX { - emqx := &appsv2alpha2.EMQX{ +func genEMQX() *appsv2beta1.EMQX { + emqx := &appsv2beta1.EMQX{ ObjectMeta: metav1.ObjectMeta{ Name: "emqx", - Namespace: "e2e-test-v2alpha2" + "-" + rand.String(5), + Namespace: "e2e-test-v2beta1" + "-" + rand.String(5), }, - Spec: appsv2alpha2.EMQXSpec{ + Spec: appsv2beta1.EMQXSpec{ Image: "emqx:latest", ImagePullPolicy: corev1.PullAlways, ClusterDomain: "cluster.local", - Config: appsv2alpha2.Config{ + Config: appsv2beta1.Config{ Data: ` gateway.lwm2m { auto_observe = true diff --git a/main.go b/main.go index aac822acc..bfdce0378 100644 --- a/main.go +++ b/main.go @@ -38,9 +38,9 @@ import ( appsv1beta3 "github.com/emqx/emqx-operator/apis/apps/v1beta3" appsv1beta4 "github.com/emqx/emqx-operator/apis/apps/v1beta4" appsv2alpha1 "github.com/emqx/emqx-operator/apis/apps/v2alpha1" - appsv2alpha2 "github.com/emqx/emqx-operator/apis/apps/v2alpha2" + appsv2beta1 "github.com/emqx/emqx-operator/apis/apps/v2beta1" appscontrollersv1beta4 "github.com/emqx/emqx-operator/controllers/apps/v1beta4" - appscontrollersv2alpha2 "github.com/emqx/emqx-operator/controllers/apps/v2alpha2" + appscontrollersv2beta1 "github.com/emqx/emqx-operator/controllers/apps/v2beta1" //+kubebuilder:scaffold:imports ) @@ -55,7 +55,7 @@ func init() { utilruntime.Must(appsv1beta3.AddToScheme(scheme)) utilruntime.Must(appsv1beta4.AddToScheme(scheme)) utilruntime.Must(appsv2alpha1.AddToScheme(scheme)) - utilruntime.Must(appsv2alpha2.AddToScheme(scheme)) + utilruntime.Must(appsv2beta1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -125,12 +125,12 @@ func main() { os.Exit(1) } - if err = appscontrollersv2alpha2.NewEMQXReconciler(mgr).SetupWithManager(mgr); err != nil { + if err = appscontrollersv2beta1.NewEMQXReconciler(mgr).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "EMQX") os.Exit(1) } - if err = appscontrollersv2alpha2.NewRebalanceReconciler(mgr).SetupWithManager(mgr); err != nil { + if err = appscontrollersv2beta1.NewRebalanceReconciler(mgr).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Rebalance") } @@ -150,12 +150,12 @@ func main() { os.Exit(1) } - if err = (&appsv2alpha2.EMQX{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&appsv2beta1.EMQX{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "EMQX") os.Exit(1) } - if err = (&appsv2alpha2.Rebalance{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&appsv2beta1.Rebalance{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Rebalance") os.Exit(1) }