Skip to content

Commit

Permalink
Kubernetes 1.25 compatibility & test against
Browse files Browse the repository at this point in the history
  • Loading branch information
nberlee committed Sep 15, 2022
1 parent 335ee4e commit c8d20c1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
with:
cluster-name: test-cluster-1
args: >-
--image docker.io/rancher/k3s:v1.24.1-k3s1
--image docker.io/rancher/k3s:v1.25.0-k3s1
--agents 1
--no-lb
--k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN adduser \


FROM build-base AS env-test
ARG KUBERNETES=v1.23.5
ARG KUBERNETES=v1.25.0

ADD https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES/bin/linux/amd64/kubectl /bin/
RUN chmod +x /bin/kubectl
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ See the [Resources and Labels](./doc/user/resource_labels.md) doc for an overvie

## Requirements

- Kubernetes 1.19+
- Kubernetes 1.22+
- etcd 3.2.13+

## Demo
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/k8sutil/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func WaitCRDReady(ctx context.Context, clientset apiextensionsclient.Interface,
}
case apiextensionsv1.NamesAccepted:
if cond.Status == apiextensionsv1.ConditionFalse {
return false, fmt.Errorf("Name conflict: %v", cond.Reason)
return false, fmt.Errorf("name conflict: %v", cond.Reason)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
policyv1beta1 "k8s.io/api/policy/v1beta1"
policyv1 "k8s.io/api/policy/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -262,15 +262,15 @@ func newEtcdServiceManifest(svcName, clusterName, clusterIP string, ports []v1.S
return svc
}

func newEtcdPodDisruptionBudgetManifest(pdbName, clusterName string, minAvailable *intstr.IntOrString) *policyv1beta1.PodDisruptionBudget {
func newEtcdPodDisruptionBudgetManifest(pdbName, clusterName string, minAvailable *intstr.IntOrString) *policyv1.PodDisruptionBudget {
labels := LabelsForCluster(clusterName)

pdb := &policyv1beta1.PodDisruptionBudget{
pdb := &policyv1.PodDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{
Name: pdbName,
Labels: labels,
},
Spec: policyv1beta1.PodDisruptionBudgetSpec{
Spec: policyv1.PodDisruptionBudgetSpec{
MinAvailable: minAvailable,
Selector: &metav1.LabelSelector{
MatchLabels: labels,
Expand Down Expand Up @@ -571,9 +571,9 @@ func UpdateOrCreatePodDisruptionBudget(ctx context.Context, kubecli kubernetes.I
addOwnerRefToObject(pdb.GetObjectMeta(), owner)

return retry.RetryOnConflict(retry.DefaultRetry, func() error {
od, err := kubecli.PolicyV1beta1().PodDisruptionBudgets(namespace).Get(ctx, name, metav1.GetOptions{})
od, err := kubecli.PolicyV1().PodDisruptionBudgets(namespace).Get(ctx, name, metav1.GetOptions{})
if IsKubernetesResourceNotFoundError(err) {
_, err := kubecli.PolicyV1beta1().PodDisruptionBudgets(namespace).Create(ctx, pdb, metav1.CreateOptions{})
_, err := kubecli.PolicyV1().PodDisruptionBudgets(namespace).Create(ctx, pdb, metav1.CreateOptions{})
return err
}
if err != nil {
Expand All @@ -582,7 +582,7 @@ func UpdateOrCreatePodDisruptionBudget(ctx context.Context, kubecli kubernetes.I

pdb.Status = od.Status
pdb.ObjectMeta.ResourceVersion = od.ObjectMeta.ResourceVersion // Optimistic locking
_, err = kubecli.PolicyV1beta1().PodDisruptionBudgets(namespace).Update(ctx, pdb, metav1.UpdateOptions{})
_, err = kubecli.PolicyV1().PodDisruptionBudgets(namespace).Update(ctx, pdb, metav1.UpdateOptions{})

return err
})
Expand Down

0 comments on commit c8d20c1

Please sign in to comment.