Skip to content

Commit

Permalink
updating dependencies to k8s 1.31 (#6878)
Browse files Browse the repository at this point in the history
* updating dependencies to k8s 1.31

Signed-off-by: Adam D. Cornett <[email protected]>

* adding k8s 1.31 change document

Signed-off-by: Adam D. Cornett <[email protected]>

* fixing go mod tidy issue

Signed-off-by: Adam D. Cornett <[email protected]>

---------

Signed-off-by: Adam D. Cornett <[email protected]>
  • Loading branch information
acornett21 authored Jan 10, 2025
1 parent 53dd00c commit 08db483
Show file tree
Hide file tree
Showing 34 changed files with 948 additions and 692 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export IMAGE_VERSION = v1.38.0
export SIMPLE_VERSION = $(shell (test "$(shell git describe --tags)" = "$(shell git describe --tags --abbrev=0)" && echo $(shell git describe --tags)) || echo $(shell git describe --tags --abbrev=0)+git)
export GIT_VERSION = $(shell git describe --dirty --tags --always)
export GIT_COMMIT = $(shell git rev-parse HEAD)
export K8S_VERSION = 1.30.0
export K8S_VERSION = 1.31.0

# Build settings
export TOOLS_DIR = tools/bin
Expand Down Expand Up @@ -176,12 +176,12 @@ cluster-create::

.PHONY: dev-install
dev-install::
$(SCRIPTS_DIR)/fetch kind 0.23.0
$(SCRIPTS_DIR)/fetch kind 0.24.0
$(SCRIPTS_DIR)/fetch kubectl $(K8S_VERSION) # Install kubectl AFTER envtest because envtest includes its own kubectl binary

.PHONY: test-e2e-teardown
test-e2e-teardown:
$(SCRIPTS_DIR)/fetch kind 0.23.0
$(SCRIPTS_DIR)/fetch kind 0.24.0
$(TOOLS_DIR)/kind delete cluster --name $(KIND_CLUSTER)
rm -f $(KUBECONFIG)

Expand Down
164 changes: 164 additions & 0 deletions changelog/fragments/01-document-k8s-1-31-changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
For Go-based, Helm-based and Ansible-based operators this release moves to Kubernetes 1.31 API's and Kubebuilder
v4 Scaffolding, specifically utilizing the v4.2.0 version. The update to Kubebuiler results in some scaffolding
changes which more information can be found below:
- Add support to protect project with [network policies](https://kubernetes.io/docs/concepts/services-networking/network-policies/) ([#3853](https://github.com/kubernetes-sigs/kubebuilder/pull/3853))
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "change"
# Is this a breaking change?
breaking: false
# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
#
# The generator auto-detects the PR number from the commit
# message in which this file was originally added.
#
# What is the pull request number (without the "#")?
# pull_request_override: 0
# Migration can be defined to automatically add a section to
# the migration guide. This is required for breaking changes.
migration:
header: Upgrade K8s versions to use 1.31 and Kubebuilder network-policy scaffolding
body: |
This release contains a decent amount of migrations, but not nearly as many as the [previous versions migrations](https://sdk.operatorframework.io/docs/upgrading-sdk-version/v1.38.0/)
so this release should be easier to follow.
1) [helm/v1, ansible/v1] Update the kustomize version in your Makefile
```diff
- curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.3.2/kustomize_v5.3.0_$(OS)_$(ARCH).tar.gz | \
+ curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.4.3/kustomize_v5.4.2_$(OS)_$(ARCH).tar.gz | \
```
2) [go/v4] Update your `go.mod` file to upgrade the dependencies and run `go mod tidy` to download them
```go
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
k8s.io/api v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
sigs.k8s.io/controller-runtime v0.18.4
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
sigs.k8s.io/controller-runtime v0.19.0
```
3) [go/v4] Update your `Makefile` with the below changes:
```diff
- ENVTEST_K8S_VERSION = 1.30.0
+ ENVTEST_K8S_VERSION = 1.31.0
```
```diff
- KUSTOMIZE_VERSION ?= v5.4.2
- CONTROLLER_TOOLS_VERSION ?= v0.15.0
- ENVTEST_VERSION ?= release-0.18
+ KUSTOMIZE_VERSION ?= v5.4.3
+ CONTROLLER_TOOLS_VERSION ?= v0.16.1
+ ENVTEST_VERSION ?= release-0.19
```
4) [go/v4] Update your `main.go` file with the below changes:
```diff
- // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
+ // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
- // https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/filters#WithAuthenticationAndAuthorization
+ // https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/filters#WithAuthenticationAndAuthorization
```
5) [go/v4, helm/v1, ansible/v1] Update your `/config/default/kustomization.yaml` file with the below changes:
```diff
+# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
+# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
+# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will
+# be able to communicate with the Webhook Server.
+#- ../network-policy
```
6) [go/v4, helm/v1, ansible/v1] Add `/config/network-policy/allow-metrics-traffic.yaml`
```diff
+ # This NetworkPolicy allows ingress traffic
+ # with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those
+ # namespaces are able to gathering data from the metrics endpoint.
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ labels:
+ app.kubernetes.io/name: memcached-operator
+ app.kubernetes.io/managed-by: kustomize
+ name: allow-metrics-traffic
+ namespace: system
+ spec:
+ podSelector:
+ matchLabels:
+ control-plane: controller-manager
+ policyTypes:
+ - Ingress
+ ingress:
+ # This allows ingress traffic from any namespace with the label metrics: enabled
+ - from:
+ - namespaceSelector:
+ matchLabels:
+ metrics: enabled # Only from namespaces with this label
+ ports:
+ - port: 8443
+ protocol: TCP
```
7) [helm/v1, ansible/v1] Add `/config/network-policy/kustomization.yaml`
```diff
+ resources:
+ - allow-metrics-traffic.yaml
8) [go/v4] Add `/config/network-policy/allow-webhook-traffic.yaml`
```diff
+ # This NetworkPolicy allows ingress traffic to your webhook server running
+ # as part of the controller-manager from specific namespaces and pods. CR(s) which uses webhooks
+ # will only work when applied in namespaces labeled with 'webhook: enabled'
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ labels:
+ app.kubernetes.io/name: memcached-operator
+ app.kubernetes.io/managed-by: kustomize
+ name: allow-webhook-traffic
+ namespace: system
+ spec:
+ podSelector:
+ matchLabels:
+ control-plane: controller-manager
+ policyTypes:
+ - Ingress
+ ingress:
+ # This allows ingress traffic from any namespace with the label webhook: enabled
+ - from:
+ - namespaceSelector:
+ matchLabels:
+ webhook: enabled # Only from namespaces with this label
+ ports:
+ - port: 443
+ protocol: TCP
```
9) [go/v4] Add `/config/network-policy/kustomization.yaml`
```diff
+ resources:
+ - allow-webhook-traffic.yaml
+ - allow-metrics-traffic.yaml
```
Loading

0 comments on commit 08db483

Please sign in to comment.