diff --git a/Documentation/rbac.md b/Documentation/rbac.md index cf94175da..f8df25e7f 100644 --- a/Documentation/rbac.md +++ b/Documentation/rbac.md @@ -135,7 +135,7 @@ In addition to the resources Prometheus itself needs to access, the Prometheus s [embedmd]:# (../example/rbac/prometheus/prometheus-cluster-role.yaml) ```yaml -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus @@ -222,7 +222,7 @@ And then because the `ClusterRole` named `prometheus`, as described above, is li [embedmd]:# (../example/rbac/prometheus/prometheus-cluster-role-binding.yaml) ```yaml -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: prometheus diff --git a/Documentation/user-guides/exposing-prometheus-and-alertmanager.md b/Documentation/user-guides/exposing-prometheus-and-alertmanager.md index 8f7bae280..38b7a2b30 100644 --- a/Documentation/user-guides/exposing-prometheus-and-alertmanager.md +++ b/Documentation/user-guides/exposing-prometheus-and-alertmanager.md @@ -208,7 +208,7 @@ spec: A corresponding Ingress object would be: ```yaml -apiVersion: extensions/v1beta1 +apiVersion: extensions/v1 kind: Ingress metadata: name: monitoring diff --git a/Documentation/user-guides/getting-started.md b/Documentation/user-guides/getting-started.md index 545b33118..f6ee6cbf4 100644 --- a/Documentation/user-guides/getting-started.md +++ b/Documentation/user-guides/getting-started.md @@ -108,7 +108,7 @@ metadata: [embedmd]:# (../../example/rbac/prometheus/prometheus-cluster-role.yaml) ```yaml -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus @@ -136,7 +136,7 @@ rules: [embedmd]:# (../../example/rbac/prometheus/prometheus-cluster-role-binding.yaml) ```yaml -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: prometheus diff --git a/example/additional-scrape-configs/prometheus-cluster-role-binding.yaml b/example/additional-scrape-configs/prometheus-cluster-role-binding.yaml index e255bcea3..fc234d98f 100644 --- a/example/additional-scrape-configs/prometheus-cluster-role-binding.yaml +++ b/example/additional-scrape-configs/prometheus-cluster-role-binding.yaml @@ -1,4 +1,4 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: prometheus diff --git a/example/additional-scrape-configs/prometheus-cluster-role.yaml b/example/additional-scrape-configs/prometheus-cluster-role.yaml index a85422ecf..67ca73c3e 100644 --- a/example/additional-scrape-configs/prometheus-cluster-role.yaml +++ b/example/additional-scrape-configs/prometheus-cluster-role.yaml @@ -1,4 +1,4 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus diff --git a/example/rbac/prometheus/prometheus-cluster-role-binding.yaml b/example/rbac/prometheus/prometheus-cluster-role-binding.yaml index e255bcea3..fc234d98f 100644 --- a/example/rbac/prometheus/prometheus-cluster-role-binding.yaml +++ b/example/rbac/prometheus/prometheus-cluster-role-binding.yaml @@ -1,4 +1,4 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: prometheus diff --git a/example/rbac/prometheus/prometheus-cluster-role.yaml b/example/rbac/prometheus/prometheus-cluster-role.yaml index 330c0218f..8d3019595 100644 --- a/example/rbac/prometheus/prometheus-cluster-role.yaml +++ b/example/rbac/prometheus/prometheus-cluster-role.yaml @@ -1,4 +1,4 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus diff --git a/example/storage/storageclass.yaml b/example/storage/storageclass.yaml index 8635e62cc..a7bb4c978 100644 --- a/example/storage/storageclass.yaml +++ b/example/storage/storageclass.yaml @@ -1,4 +1,4 @@ -apiVersion: storage.k8s.io/v1beta1 +apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: ssd diff --git a/pkg/admission/admission_test.go b/pkg/admission/admission_test.go index e1416e978..4dcf2278e 100644 --- a/pkg/admission/admission_test.go +++ b/pkg/admission/admission_test.go @@ -18,19 +18,18 @@ import ( "bytes" "encoding/json" "fmt" - jsonpatch "github.com/evanphx/json-patch/v5" "io/ioutil" - v1 "k8s.io/api/admission/v1" "net/http" "net/http/httptest" "os" "strings" "testing" + jsonpatch "github.com/evanphx/json-patch/v5" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/prometheus/client_golang/prometheus" - "k8s.io/api/admission/v1beta1" + "k8s.io/api/admission/v1" ) func TestMutateRule(t *testing.T) { @@ -182,7 +181,7 @@ func server(s serveFunc) *httptest.Server { return httptest.NewServer(http.HandlerFunc(s)) } -func send(t *testing.T, ts *httptest.Server, rules []byte) *v1beta1.AdmissionReview { +func send(t *testing.T, ts *httptest.Server, rules []byte) *v1.AdmissionReview { resp, err := http.Post(ts.URL, "application/json", bytes.NewReader(rules)) if err != nil { t.Errorf("Publish() returned an error: %s", err) @@ -193,7 +192,7 @@ func send(t *testing.T, ts *httptest.Server, rules []byte) *v1beta1.AdmissionRev t.Errorf("ioutil.ReadAll(resp.Body) returned an error: %s", err) } - rev := &v1beta1.AdmissionReview{} + rev := &v1.AdmissionReview{} if err := json.Unmarshal(body, rev); err != nil { t.Errorf("unable to parse webhook response: %s", err) } @@ -204,7 +203,7 @@ func send(t *testing.T, ts *httptest.Server, rules []byte) *v1beta1.AdmissionRev var goodRulesWithAnnotations = []byte(` { "kind": "AdmissionReview", - "apiVersion": "admission.k8s.io/v1beta1", + "apiVersion": "admission.k8s.io/v1", "request": { "uid": "87c5df7f-5090-11e9-b9b4-02425473f309", "kind": { @@ -270,7 +269,7 @@ var goodRulesWithAnnotations = []byte(` var goodRulesWithExternalLabelsInAnnotations = []byte(` { "kind": "AdmissionReview", - "apiVersion": "admission.k8s.io/v1beta1", + "apiVersion": "admission.k8s.io/v1", "request": { "uid": "87c5df7f-5090-11e9-b9b4-02425473f309", "kind": { @@ -335,7 +334,7 @@ var goodRulesWithExternalLabelsInAnnotations = []byte(` var badRulesNoAnnotations = []byte(` { "kind": "AdmissionReview", - "apiVersion": "admission.k8s.io/v1beta1", + "apiVersion": "admission.k8s.io/v1", "request": { "uid": "87c5df7f-5090-11e9-b9b4-02425473f309", "kind": { @@ -398,7 +397,7 @@ var badRulesNoAnnotations = []byte(` var badRulesWithBooleanInAnnotations = []byte(` { "kind": "AdmissionReview", - "apiVersion": "admission.k8s.io/v1beta1", + "apiVersion": "admission.k8s.io/v1", "request": { "uid": "87c5df7f-5090-11e9-b9b4-02425473f309", "kind": { @@ -465,7 +464,7 @@ var badRulesWithBooleanInAnnotations = []byte(` var nonStringsInLabelsAnnotations = []byte(` { "kind": "AdmissionReview", - "apiVersion": "admission.k8s.io/v1beta1", + "apiVersion": "admission.k8s.io/v1", "request": { "uid": "87c5df7f-5090-11e9-b9b4-02425473f309", "kind": { diff --git a/scripts/kind-rbac.yaml b/scripts/kind-rbac.yaml index 81cf20e66..93d9d0bb5 100644 --- a/scripts/kind-rbac.yaml +++ b/scripts/kind-rbac.yaml @@ -1,6 +1,6 @@ # Wide open access to the cluster (mostly for kubelet) kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: cluster-writer rules: @@ -14,7 +14,7 @@ rules: # Full read access to the api and resources kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: cluster-reader rules: @@ -26,7 +26,7 @@ rules: --- # Give admin, kubelet, kube-system, kube-proxy god access kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: cluster-write subjects: @@ -49,7 +49,7 @@ roleRef: # Setup sd-build as a reader. This has to be a # ClusterRoleBinding to get access to non-resource URLs kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: cluster-read subjects: @@ -65,7 +65,7 @@ roleRef: # Setup sd-build as a writer in its namespace kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: sd-build-write subjects: diff --git a/test/framework/admission-webhooks.go b/test/framework/admission-webhooks.go index 418b77ad4..11c61b866 100644 --- a/test/framework/admission-webhooks.go +++ b/test/framework/admission-webhooks.go @@ -16,7 +16,7 @@ package framework import ( "github.com/pkg/errors" - "k8s.io/api/admissionregistration/v1beta1" + "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/yaml" ) @@ -30,7 +30,7 @@ func (f *Framework) createMutatingHook(certBytes []byte, namespace, yamlPath str h.Webhooks[0].ClientConfig.Service.Namespace = namespace h.Webhooks[0].ClientConfig.CABundle = certBytes - _, err = f.KubeClient.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Create(f.Ctx, h, metav1.CreateOptions{}) + _, err = f.KubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Create(f.Ctx, h, metav1.CreateOptions{}) if err != nil { return nil, errors.Wrapf(err, "failed to create mutating webhook %s", h.Name) } @@ -49,7 +49,7 @@ func (f *Framework) createValidatingHook(certBytes []byte, namespace, yamlPath s h.Webhooks[0].ClientConfig.Service.Namespace = namespace h.Webhooks[0].ClientConfig.CABundle = certBytes - _, err = f.KubeClient.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Create(f.Ctx, h, metav1.CreateOptions{}) + _, err = f.KubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().Create(f.Ctx, h, metav1.CreateOptions{}) if err != nil { return nil, errors.Wrapf(err, "failed to create validating webhook %s", h.Name) } @@ -60,20 +60,20 @@ func (f *Framework) createValidatingHook(certBytes []byte, namespace, yamlPath s } func (f *Framework) deleteMutatingWebhook(name string) error { - return f.KubeClient.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Delete(f.Ctx, name, metav1.DeleteOptions{}) + return f.KubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Delete(f.Ctx, name, metav1.DeleteOptions{}) } func (f *Framework) deleteValidatingWebhook(name string) error { - return f.KubeClient.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Delete(f.Ctx, name, metav1.DeleteOptions{}) + return f.KubeClient.AdmissionregistrationV1().ValidatingWebhookConfigurations().Delete(f.Ctx, name, metav1.DeleteOptions{}) } -func parseValidatingHookYaml(pathToYaml string) (*v1beta1.ValidatingWebhookConfiguration, error) { +func parseValidatingHookYaml(pathToYaml string) (*v1.ValidatingWebhookConfiguration, error) { manifest, err := PathToOSFile(pathToYaml) if err != nil { return nil, err } - resource := v1beta1.ValidatingWebhookConfiguration{} + resource := v1.ValidatingWebhookConfiguration{} if err := yaml.NewYAMLOrJSONDecoder(manifest, 100).Decode(&resource); err != nil { return nil, errors.Wrapf(err, "failed to decode file %s", pathToYaml) } @@ -81,13 +81,13 @@ func parseValidatingHookYaml(pathToYaml string) (*v1beta1.ValidatingWebhookConfi return &resource, nil } -func parseMutatingHookYaml(pathToYaml string) (*v1beta1.MutatingWebhookConfiguration, error) { +func parseMutatingHookYaml(pathToYaml string) (*v1.MutatingWebhookConfiguration, error) { manifest, err := PathToOSFile(pathToYaml) if err != nil { return nil, err } - resource := v1beta1.MutatingWebhookConfiguration{} + resource := v1.MutatingWebhookConfiguration{} if err := yaml.NewYAMLOrJSONDecoder(manifest, 100).Decode(&resource); err != nil { return nil, errors.Wrapf(err, "failed to decode file %s", pathToYaml) } diff --git a/test/framework/ingress.go b/test/framework/ingress.go index 786689888..86c234476 100644 --- a/test/framework/ingress.go +++ b/test/framework/ingress.go @@ -21,28 +21,31 @@ import ( "github.com/pkg/errors" "k8s.io/api/core/v1" - "k8s.io/api/extensions/v1beta1" + networkv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/yaml" ) -func MakeBasicIngress(serviceName string, servicePort int) *v1beta1.Ingress { - return &v1beta1.Ingress{ +func MakeBasicIngress(serviceName string, servicePort int) *networkv1.Ingress { + return &networkv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: "monitoring", }, - Spec: v1beta1.IngressSpec{ - Rules: []v1beta1.IngressRule{ + Spec: networkv1.IngressSpec{ + Rules: []networkv1.IngressRule{ { - IngressRuleValue: v1beta1.IngressRuleValue{ - HTTP: &v1beta1.HTTPIngressRuleValue{ - Paths: []v1beta1.HTTPIngressPath{ + IngressRuleValue: networkv1.IngressRuleValue{ + HTTP: &networkv1.HTTPIngressRuleValue{ + Paths: []networkv1.HTTPIngressPath{ { - Backend: v1beta1.IngressBackend{ - ServiceName: serviceName, - ServicePort: intstr.FromInt(servicePort), + Backend: networkv1.IngressBackend{ + Service: &networkv1.IngressServiceBackend{ + Name: serviceName, + Port: networkv1.ServiceBackendPort{ + Number: int32(servicePort), + }, + }, }, Path: "/metrics", }, @@ -55,8 +58,8 @@ func MakeBasicIngress(serviceName string, servicePort int) *v1beta1.Ingress { } } -func (f *Framework) CreateIngress(namespace string, i *v1beta1.Ingress) error { - _, err := f.KubeClient.ExtensionsV1beta1().Ingresses(namespace).Create(f.Ctx, i, metav1.CreateOptions{}) +func (f *Framework) CreateIngress(namespace string, i *networkv1.Ingress) error { + _, err := f.KubeClient.NetworkingV1().Ingresses(namespace).Create(f.Ctx, i, metav1.CreateOptions{}) return errors.Wrap(err, fmt.Sprintf("creating ingress %v failed", i.Name)) } @@ -125,10 +128,10 @@ func (f *Framework) DeleteNginxIngressControllerIncDefaultBackend(namespace stri } func (f *Framework) GetIngressIP(namespace string, ingressName string) (*string, error) { - var ingress *v1beta1.Ingress + var ingress *networkv1.Ingress err := wait.Poll(time.Millisecond*500, time.Minute*5, func() (bool, error) { var err error - ingress, err = f.KubeClient.ExtensionsV1beta1().Ingresses(namespace).Get(f.Ctx, ingressName, metav1.GetOptions{}) + ingress, err = f.KubeClient.NetworkingV1().Ingresses(namespace).Get(f.Ctx, ingressName, metav1.GetOptions{}) if err != nil { return false, errors.Wrap(err, fmt.Sprintf("requesting the ingress %v failed", ingressName)) } diff --git a/test/framework/resources/prometheus-operator-mutatingwebhook.yaml b/test/framework/resources/prometheus-operator-mutatingwebhook.yaml index 25a00b5d4..8d302544b 100644 --- a/test/framework/resources/prometheus-operator-mutatingwebhook.yaml +++ b/test/framework/resources/prometheus-operator-mutatingwebhook.yaml @@ -1,24 +1,27 @@ -apiVersion: admissionregistration.k8s.io/v1 -kind: MutatingWebhookConfiguration -metadata: - name: prometheus-operator-rulesvalidation -webhooks: - - clientConfig: - service: - name: prometheus-operator - namespace: default - path: /admission-prometheusrules/mutate - - failurePolicy: Fail - name: prometheusrulemutate.monitoring.coreos.com - namespaceSelector: {} - rules: - - apiGroups: - - monitoring.coreos.com - apiVersions: - - '*' - operations: - - CREATE - - UPDATE - resources: - - prometheusrules \ No newline at end of file +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: prometheus-operator-rulesvalidation +webhooks: + - clientConfig: + service: + name: prometheus-operator + namespace: default + path: /admission-prometheusrules/mutate + + failurePolicy: Fail + name: prometheusrulemutate.monitoring.coreos.com + namespaceSelector: {} + rules: + - apiGroups: + - monitoring.coreos.com + apiVersions: + - '*' + operations: + - CREATE + - UPDATE + resources: + - prometheusrules + sideEffects: None + admissionReviewVersions: + - v1 diff --git a/test/framework/resources/prometheus-operator-validatingwebhook.yaml b/test/framework/resources/prometheus-operator-validatingwebhook.yaml index fafbceda9..6fb8faf5d 100644 --- a/test/framework/resources/prometheus-operator-validatingwebhook.yaml +++ b/test/framework/resources/prometheus-operator-validatingwebhook.yaml @@ -1,23 +1,26 @@ -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - name: prometheus-operator-rulesvalidation -webhooks: - - clientConfig: - service: - name: prometheus-operator - namespace: default - path: /admission-prometheusrules/validate - failurePolicy: Fail - name: prometheusrulemutate.monitoring.coreos.com - namespaceSelector: {} - rules: - - apiGroups: - - monitoring.coreos.com - apiVersions: - - '*' - operations: - - CREATE - - UPDATE - resources: - - prometheusrules \ No newline at end of file +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: prometheus-operator-rulesvalidation +webhooks: + - clientConfig: + service: + name: prometheus-operator + namespace: default + path: /admission-prometheusrules/validate + failurePolicy: Fail + name: prometheusrulemutate.monitoring.coreos.com + namespaceSelector: {} + rules: + - apiGroups: + - monitoring.coreos.com + apiVersions: + - '*' + operations: + - CREATE + - UPDATE + resources: + - prometheusrules + sideEffects: None + admissionReviewVersions: + - v1 diff --git a/test/framework/resources/prometheus-role-binding.yml b/test/framework/resources/prometheus-role-binding.yml index a0c725e18..9eb2784c3 100644 --- a/test/framework/resources/prometheus-role-binding.yml +++ b/test/framework/resources/prometheus-role-binding.yml @@ -1,4 +1,4 @@ -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: prometheus