Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Kubernetes 1.27 #2235

Merged
merged 9 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run Elasticsearch E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run examples E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run generate E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-miscellaneous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run miscellaneous E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run sidecar E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-streaming.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run streaming E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: UI E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
kube-version:
- "1.19"
- "1.25"
- "1.27"
name: Run upgrade E2E tests
steps:
- name: "Check out code into the Go module directory"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ LD_FLAGS ?= "-X $(VERSION_PKG).version=$(VERSION) -X $(VERSION_PKG).buildDate=$(

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST ?= $(LOCALBIN)/setup-envtest
ENVTEST_K8S_VERSION = 1.26
ENVTEST_K8S_VERSION = 1.27
# Options for KIND version to use
export KUBE_VERSION ?= 1.26
export KUBE_VERSION ?= 1.27
KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml

SCORECARD_TEST_IMG ?= quay.io/operator-framework/scorecard-test:v$(OPERATOR_SDK_VERSION)
Expand Down
15 changes: 8 additions & 7 deletions apis/v1/jaeger_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

const (
Expand Down Expand Up @@ -86,13 +87,13 @@ func (j *Jaeger) Default() {
var _ webhook.Validator = &Jaeger{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (j *Jaeger) ValidateCreate() error {
func (j *Jaeger) ValidateCreate() (admission.Warnings, error) {
jaegerlog.Info("validate create", "name", j.Name)
return j.ValidateUpdate(nil)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (j *Jaeger) ValidateUpdate(_ runtime.Object) error {
func (j *Jaeger) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
jaegerlog.Info("validate update", "name", j.Name)

if ShouldInjectOpenShiftElasticsearchConfiguration(j.Spec.Storage) && j.Spec.Storage.Elasticsearch.DoNotProvision {
Expand All @@ -103,24 +104,24 @@ func (j *Jaeger) ValidateUpdate(_ runtime.Object) error {
Name: j.Spec.Storage.Elasticsearch.Name,
}, es)
if errors.IsNotFound(err) {
return fmt.Errorf("elasticsearch instance not found: %v", err)
return nil, fmt.Errorf("elasticsearch instance not found: %v", err)
}
}

for _, opt := range j.objsWithOptions() {
got := opt.DeepCopy().ToArgs()
if f := getAdditionalTLSFlags(got); f != nil {
return fmt.Errorf("tls flags incomplete, got: %v", got)
return nil, fmt.Errorf("tls flags incomplete, got: %v", got)
}
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (j *Jaeger) ValidateDelete() error {
func (j *Jaeger) ValidateDelete() (admission.Warnings, error) {
jaegerlog.Info("validate delete", "name", j.Name)
return nil
return nil, nil
}

// OpenShiftElasticsearchNodeCount returns total node count of Elasticsearch nodes.
Expand Down
7 changes: 5 additions & 2 deletions apis/v1/jaeger_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func TestDefault(t *testing.T) {
}

func TestValidateDelete(t *testing.T) {
assert.Nil(t, new(Jaeger).ValidateDelete())
warnings, err := new(Jaeger).ValidateDelete()
assert.Nil(t, warnings)
assert.Nil(t, err)
}

func TestValidate(t *testing.T) {
Expand Down Expand Up @@ -275,13 +277,14 @@ func TestValidate(t *testing.T) {
fakeCl := fake.NewClientBuilder().WithRuntimeObjects(test.objsToCreate...).Build()
cl = fakeCl

err := test.current.ValidateCreate()
warnings, err := test.current.ValidateCreate()
if test.err != "" {
assert.NotNil(t, err)
assert.Equal(t, test.err, err.Error())
} else {
assert.Nil(t, err)
}
assert.Nil(t, warnings)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ spec:
- --upstream=http://127.0.0.1:8383/
- --logtostderr=true
- --v=0
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
name: kube-rbac-proxy
ports:
- containerPort: 8443
Expand Down
2 changes: 1 addition & 1 deletion bundle/manifests/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: observability/jaeger-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.9.2
controller-gen.kubebuilder.io/version: v0.12.0
creationTimestamp: null
labels:
name: jaeger-operator
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.12.0
name: jaegers.jaegertracing.io
spec:
group: jaegertracing.io
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
spec:
containers:
- name: kube-rbac-proxy
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.0
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8383/"
Expand Down
1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
2 changes: 0 additions & 2 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down Expand Up @@ -49,7 +48,6 @@ webhooks:
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
Expand Down
10 changes: 4 additions & 6 deletions controllers/appsv1/deployment_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import (
"github.com/jaegertracing/jaeger-operator/pkg/tracing"
)

var (
_ admission.DecoderInjector = (*deploymentInterceptor)(nil)
_ webhook.AdmissionHandler = (*deploymentInterceptor)(nil)
)
var _ webhook.AdmissionHandler = (*deploymentInterceptor)(nil)

// NewDeploymentInterceptorWebhook creates a new deployment mutating webhook to be registered
func NewDeploymentInterceptorWebhook(c client.Client) webhook.AdmissionHandler {
func NewDeploymentInterceptorWebhook(c client.Client, decoder *admission.Decoder) webhook.AdmissionHandler {
return &deploymentInterceptor{
client: c,
client: c,
decoder: decoder,
}
}

Expand Down
20 changes: 8 additions & 12 deletions controllers/appsv1/deployment_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ func TestReconcilieDeployment(t *testing.T) {
AdmissionResponse: admissionv1.AdmissionResponse{
Allowed: true,
Result: &metav1.Status{
Reason: "is jaeger deployment, we do not touch it",
Code: 200,
Message: "is jaeger deployment, we do not touch it",
Code: 200,
},
},
},
Expand Down Expand Up @@ -314,8 +314,8 @@ func TestReconcilieDeployment(t *testing.T) {
AdmissionResponse: admissionv1.AdmissionResponse{
Allowed: true,
Result: &metav1.Status{
Reason: "no suitable Jaeger instances found to inject a sidecar",
Code: 200,
Message: "no suitable Jaeger instances found to inject a sidecar",
Code: 200,
},
},
},
Expand Down Expand Up @@ -369,8 +369,8 @@ func TestReconcilieDeployment(t *testing.T) {
AdmissionResponse: admissionv1.AdmissionResponse{
Allowed: true,
Result: &metav1.Status{
Reason: "not watching in namespace, we do not touch the deployment",
Code: 200,
Message: "not watching in namespace, we do not touch the deployment",
Code: 200,
},
},
},
Expand Down Expand Up @@ -398,7 +398,8 @@ func TestReconcilieDeployment(t *testing.T) {
errors: tc.errors,
}

r := NewDeploymentInterceptorWebhook(cl)
decoder := admission.NewDecoder(scheme.Scheme)
r := NewDeploymentInterceptorWebhook(cl, decoder)

req := admission.Request{}
if !tc.emptyRequest {
Expand All @@ -419,9 +420,6 @@ func TestReconcilieDeployment(t *testing.T) {
}
}

decoder, err := admission.NewDecoder(s)
require.NoError(t, err)
admission.InjectDecoderInto(decoder, r)
resp := r.Handle(context.Background(), req)

assert.Len(t, resp.Patches, len(tc.resp.Patches))
Expand All @@ -433,8 +431,6 @@ func TestReconcilieDeployment(t *testing.T) {
})

assert.Equal(t, tc.resp, resp)

require.NoError(t, err)
})
}
}
6 changes: 4 additions & 2 deletions controllers/jaegertracing/jaeger_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/operator-framework/operator-lib/handler"

Expand Down Expand Up @@ -69,7 +68,10 @@ func (r *JaegerReconciler) Reconcile(ctx context.Context, request ctrl.Request)
func (r *JaegerReconciler) SetupWithManager(mgr ctrl.Manager) error {
err := ctrl.NewControllerManagedBy(mgr).
For(&v1.Jaeger{}).
Watches(&source.Kind{Type: &v1.Jaeger{}}, &handler.InstrumentedEnqueueRequestForObject{}).
Watches(
&v1.Jaeger{},
&handler.InstrumentedEnqueueRequestForObject{},
).
Complete(r)
return err
}
Loading
Loading