-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
The k8s implementation of CronJob (e.g., GetCronJobE function) relies on the deprecated v1beta1 API. This API has been deprecated in v1.25 (see https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-25). As a result, terratest's CronJob functions cannot be used with newer Kubernetes clusters.
Is there a reason why you rely on this deprecated API? Do you want me to create a PR to switch to batch/v1?
It seems like "only" because of failing tests it got switched from v1 to v1beta1 in this MR: #1650
To Reproduce
Use a cluster with Kubernetes v1.25 (e.g., minikube), apply a simple CronJob, e.g.,
---
apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: test-cronjob
namespace: test
spec:
schedule: "* 1 * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
backoffLimit: 4
template:
spec:
containers:
- name: pi
image: "perl:5.34.1"
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: NeverRun terratest function.
options := NewKubectlOptions("", "", "test")
cj, err := GetCronJobE(t, options, "test-cronjob")Will result in
the server could not find the requested resource
as GetCronJobE and other functions rely on batch/v1beta1.
Expected behavior
GetCronJobE works with non-deprecated batch API such as batch/v1.
Versions
- Terratest version: main branch
- Environment details (Ubuntu 24.04):