From 17247f3c54ada74f9d1f94a62b2d5f6c093ce13d Mon Sep 17 00:00:00 2001 From: Jason Witkowski Date: Fri, 10 Feb 2023 14:28:03 -0500 Subject: [PATCH] feat: Move policy/v1beta1 to policy/v1 for K8s 1.25+ compatability --- Makefile | 4 ++-- README.md | 3 ++- apis/druid/v1alpha1/druid_types.go | 4 ++-- apis/druid/v1alpha1/zz_generated.deepcopy.go | 4 ++-- controllers/druid/handler.go | 22 +++++++++---------- controllers/druid/handler_test.go | 4 ++-- .../broker-pod-disruption-budget.yaml | 2 +- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index d5411e38..42a21b17 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Image URL to use all building/pushing image targets IMG ?= "druid-operator:latest" # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.24.2 +ENVTEST_K8S_VERSION = 1.25.0 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -56,7 +56,7 @@ vet: ## Run go vet against code. .PHONY: test test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) --arch=amd64 use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out ##@ Build diff --git a/README.md b/README.md index 8bbbea52..47ca36fa 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,12 @@ - ```Druid``` CR belongs to api Group ```druid.apache.org``` and version ```v1alpha1``` ### Notifications -- Users may experience HPA issues with druid-operator with release 0.0.5, as described in the [issue]( https://github.com/druid-io/druid-operator/issues/160). +- Users may experience HPA issues with druid-operator with release 0.0.5, as described in the [issue]( https://github.com/druid-io/druid-operator/issues/160). - The latest release 0.0.6 has fixes for the above issue. - The operator has moved from HPA apiVersion autoscaling/v2beta1 to autoscaling/v2beta2 API users will need to update there HPA Specs according v2beta2 api in order to work with the latest druid-operator release. - Users may experience pvc deletion [issue](https://github.com/druid-io/druid-operator/issues/186) in release 0.0.6, this issue has been fixed in patch release 0.0.6.1. - druid-operator has moved Ingress apiVersion networking/v1beta1 to networking/v1. Users will need to update there Ingress Spec in the druid CR according networking/v1 syntax. In case users are using schema validated CRD, the CRD will also be needed to be updated. +- druid-operator has moved PodDisruptionBudget apiVersion policy/v1beta1 to policy/v1. Users will need to update there Kubernetes versions to 1.21+ to use druid-operator-0.0.10+. ### Note ApacheĀ®, [Apache Druid, DruidĀ®](https://druid.apache.org/) are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. This project, druid-operator, is not an Apache Software Foundation project. diff --git a/apis/druid/v1alpha1/druid_types.go b/apis/druid/v1alpha1/druid_types.go index 6adc5e4e..9d39315b 100644 --- a/apis/druid/v1alpha1/druid_types.go +++ b/apis/druid/v1alpha1/druid_types.go @@ -7,7 +7,7 @@ import ( autoscalev2beta2 "k8s.io/api/autoscaling/v2beta2" v1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -208,7 +208,7 @@ type DruidNodeSpec struct { PodLabels map[string]string `json:"podLabels,omitempty"` // Optional - PodDisruptionBudgetSpec *v1beta1.PodDisruptionBudgetSpec `json:"podDisruptionBudgetSpec,omitempty"` + PodDisruptionBudgetSpec *policyv1.PodDisruptionBudgetSpec `json:"podDisruptionBudgetSpec,omitempty"` // Required RuntimeProperties string `json:"runtime.properties"` diff --git a/apis/druid/v1alpha1/zz_generated.deepcopy.go b/apis/druid/v1alpha1/zz_generated.deepcopy.go index 667ad696..d628c102 100644 --- a/apis/druid/v1alpha1/zz_generated.deepcopy.go +++ b/apis/druid/v1alpha1/zz_generated.deepcopy.go @@ -15,7 +15,7 @@ import ( "k8s.io/api/autoscaling/v2beta2" "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -223,7 +223,7 @@ func (in *DruidNodeSpec) DeepCopyInto(out *DruidNodeSpec) { } if in.PodDisruptionBudgetSpec != nil { in, out := &in.PodDisruptionBudgetSpec, &out.PodDisruptionBudgetSpec - *out = new(v1beta1.PodDisruptionBudgetSpec) + *out = new(policyv1.PodDisruptionBudgetSpec) (*in).DeepCopyInto(*out) } if in.Services != nil { diff --git a/controllers/druid/handler.go b/controllers/druid/handler.go index 40d348b4..3ae3e213 100644 --- a/controllers/druid/handler.go +++ b/controllers/druid/handler.go @@ -17,7 +17,7 @@ import ( "github.com/druid-io/druid-operator/apis/druid/v1alpha1" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" - "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -346,7 +346,7 @@ func deployDruidCluster(sdk client.Client, m *v1alpha1.Druid, emitEvents EventEm updatedStatus.PodDisruptionBudgets = deleteUnusedResources(sdk, m, podDisruptionBudgetNames, ls, func() objectList { return makePodDisruptionBudgetListEmptyObj() }, func(listObj runtime.Object) []object { - items := listObj.(*v1beta1.PodDisruptionBudgetList).Items + items := listObj.(*policyv1.PodDisruptionBudgetList).Items result := make([]object, len(items)) for i := 0; i < len(items); i++ { result[i] = &items[i] @@ -1366,13 +1366,13 @@ func updateDefaultPortInProbe(probe *v1.Probe, defaultPort int32) *v1.Probe { return probe } -func makePodDisruptionBudget(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, ls map[string]string, nodeSpecUniqueStr string) (*v1beta1.PodDisruptionBudget, error) { +func makePodDisruptionBudget(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, ls map[string]string, nodeSpecUniqueStr string) (*policyv1.PodDisruptionBudget, error) { pdbSpec := *nodeSpec.PodDisruptionBudgetSpec pdbSpec.Selector = &metav1.LabelSelector{MatchLabels: ls} - pdb := &v1beta1.PodDisruptionBudget{ + pdb := &policyv1.PodDisruptionBudget{ TypeMeta: metav1.TypeMeta{ - APIVersion: "policy/v1beta1", + APIVersion: "policy/v1", Kind: "PodDisruptionBudget", }, @@ -1539,10 +1539,10 @@ func makeDeloymentListEmptyObj() *appsv1.DeploymentList { } } -func makePodDisruptionBudgetListEmptyObj() *v1beta1.PodDisruptionBudgetList { - return &v1beta1.PodDisruptionBudgetList{ +func makePodDisruptionBudgetListEmptyObj() *policyv1.PodDisruptionBudgetList { + return &policyv1.PodDisruptionBudgetList{ TypeMeta: metav1.TypeMeta{ - APIVersion: "policy/v1beta1", + APIVersion: "policy/v1", Kind: "PodDisruptionBudget", }, } @@ -1611,10 +1611,10 @@ func makeDeploymentEmptyObj() *appsv1.Deployment { } } -func makePodDisruptionBudgetEmptyObj() *v1beta1.PodDisruptionBudget { - return &v1beta1.PodDisruptionBudget{ +func makePodDisruptionBudgetEmptyObj() *policyv1.PodDisruptionBudget { + return &policyv1.PodDisruptionBudget{ TypeMeta: metav1.TypeMeta{ - APIVersion: "policy/v1beta1", + APIVersion: "policy/v1", Kind: "PodDisruptionBudget", }, } diff --git a/controllers/druid/handler_test.go b/controllers/druid/handler_test.go index 7774c8d7..ce51c75d 100644 --- a/controllers/druid/handler_test.go +++ b/controllers/druid/handler_test.go @@ -11,7 +11,7 @@ import ( "github.com/ghodss/yaml" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/api/policy/v1beta1" + policyv1 "k8s.io/api/policy/v1" ) func TestMakeStatefulSetForBroker(t *testing.T) { @@ -67,7 +67,7 @@ func TestMakePodDisruptionBudgetForBroker(t *testing.T) { actual, _ := makePodDisruptionBudget(&nodeSpec, clusterSpec, makeLabelsForNodeSpec(&nodeSpec, clusterSpec, clusterSpec.Name, nodeSpecUniqueStr), nodeSpecUniqueStr) addHashToObject(actual) - expected := new(v1beta1.PodDisruptionBudget) + expected := new(policyv1.PodDisruptionBudget) readAndUnmarshallResource("testdata/broker-pod-disruption-budget.yaml", &expected, t) assertEquals(expected, actual, t) diff --git a/controllers/druid/testdata/broker-pod-disruption-budget.yaml b/controllers/druid/testdata/broker-pod-disruption-budget.yaml index 9f2b1474..8d6ae8d6 100644 --- a/controllers/druid/testdata/broker-pod-disruption-budget.yaml +++ b/controllers/druid/testdata/broker-pod-disruption-budget.yaml @@ -1,4 +1,4 @@ -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: labels: