Skip to content

Commit

Permalink
feat: Move policy/v1beta1 to policy/v1 for K8s 1.25+ compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Witkowski committed Feb 10, 2023
1 parent c322fbe commit 17247f3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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))
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions apis/druid/v1alpha1/druid_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions apis/druid/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions controllers/druid/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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",
},

Expand Down Expand Up @@ -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",
},
}
Expand Down Expand Up @@ -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",
},
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/druid/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: policy/v1beta1
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
labels:
Expand Down

0 comments on commit 17247f3

Please sign in to comment.