diff --git a/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml b/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml index fef3b54774..c00c382b80 100644 --- a/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml +++ b/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml @@ -4858,7 +4858,7 @@ spec: # Activator PDB. Currently we permit unavailability of 20% of tasks at the same time. # Given the subsetting and that the activators are partially stateful systems, we want # a slow rollout of the new versions and slow migration during node upgrades. -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: activator-pdb @@ -5552,7 +5552,7 @@ spec: averageUtilization: 100 --- # Webhook PDB. -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: webhook-pdb diff --git a/openshift-knative-operator/hack/003-serving-pdb.patch b/openshift-knative-operator/hack/003-serving-pdb.patch index d8872b951c..82df6e5729 100644 --- a/openshift-knative-operator/hack/003-serving-pdb.patch +++ b/openshift-knative-operator/hack/003-serving-pdb.patch @@ -1,16 +1,7 @@ diff --git a/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml b/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml -index dd7a139c..fef3b547 100644 +index dd7a139ca..c00c382b8 100644 --- a/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml +++ b/openshift-knative-operator/cmd/operator/kodata/knative-serving/1.2.0/2-serving-core.yaml -@@ -4858,7 +4858,7 @@ spec: - # Activator PDB. Currently we permit unavailability of 20% of tasks at the same time. - # Given the subsetting and that the activators are partially stateful systems, we want - # a slow rollout of the new versions and slow migration during node upgrades. --apiVersion: policy/v1 -+apiVersion: policy/v1beta1 - kind: PodDisruptionBudget - metadata: - name: activator-pdb @@ -4869,7 +4869,7 @@ metadata: app.kubernetes.io/version: "1.2.0" serving.knative.dev/release: "v1.2.0" @@ -20,15 +11,6 @@ index dd7a139c..fef3b547 100644 selector: matchLabels: app: activator -@@ -5552,7 +5552,7 @@ spec: - averageUtilization: 100 - --- - # Webhook PDB. --apiVersion: policy/v1 -+apiVersion: policy/v1beta1 - kind: PodDisruptionBudget - metadata: - name: webhook-pdb @@ -5563,7 +5563,7 @@ metadata: app.kubernetes.io/version: "1.2.0" serving.knative.dev/release: "v1.2.0" diff --git a/openshift-knative-operator/pkg/common/api.go b/openshift-knative-operator/pkg/common/api.go new file mode 100644 index 0000000000..9ea5cc23ed --- /dev/null +++ b/openshift-knative-operator/pkg/common/api.go @@ -0,0 +1,20 @@ +package common + +import ( + mf "github.com/manifestival/manifestival" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" +) + +// DowngradePodDisruptionBudget downgrade the API version to policy/v1beta1. +func DowngradePodDisruptionBudget() mf.Transformer { + return func(u *unstructured.Unstructured) error { + if u.GetKind() != "PodDisruptionBudget" { + return nil + } + if u.GetAPIVersion() != "policy/v1" { + return nil + } + u.SetAPIVersion("policy/v1beta1") + return nil + } +} diff --git a/openshift-knative-operator/pkg/serving/extension.go b/openshift-knative-operator/pkg/serving/extension.go index e61fe7e4a9..aa3fd94143 100644 --- a/openshift-knative-operator/pkg/serving/extension.go +++ b/openshift-knative-operator/pkg/serving/extension.go @@ -63,7 +63,7 @@ func (e *extension) Manifests(ks operatorv1alpha1.KComponent) ([]mf.Manifest, er } func (e *extension) Transformers(ks operatorv1alpha1.KComponent) []mf.Transformer { - return append([]mf.Transformer{ + tf := []mf.Transformer{ common.InjectCommonLabelIntoNamespace(), common.InjectEnvironmentIntoDeployment("controller", "controller", corev1.EnvVar{Name: "HTTP_PROXY", Value: os.Getenv("HTTP_PROXY")}, @@ -72,7 +72,13 @@ func (e *extension) Transformers(ks operatorv1alpha1.KComponent) []mf.Transforme ), overrideKourierNamespace(ks), addHTTPOptionDisabledEnvValue(), - }, monitoring.GetServingTransformers(ks)...) + } + + if err := checkMinimumVersion(e.kubeclient.Discovery(), "1.21.0"); err != nil { + tf = append(tf, common.DowngradePodDisruptionBudget()) + } + + return append(tf, monitoring.GetServingTransformers(ks)...) } func (e *extension) Reconcile(ctx context.Context, comp operatorv1alpha1.KComponent) error {