Skip to content

Commit

Permalink
chore: bump to kubebuilder v3.14.0 (#37)
Browse files Browse the repository at this point in the history
* chore: update ci workflow

* chore: add handy .gitignore for updates

* doc: add guide to update kubebuilder

* doc: update kubebuilder version

* chore: bump `operator-v1` to latest kubebuilder release

* doc: update kubebuilder update guide

* chore: update `operator-v2` and `operator-v2-with-tests`

* doc: update `README`

* doc: add articles link

* ci: trigger `ci` job when pushing to PR
  • Loading branch information
leovct authored Feb 2, 2024
1 parent 47fb8ca commit cdd7842
Show file tree
Hide file tree
Showing 28 changed files with 101 additions and 31 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
name: ci

on:
pull_request:
push:
branches: [main]
pull_request:
paths-ignore:
- '.github/workflows/pull_request_template.md'
- 'doc/**'
- 'README.md'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*-old
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 🛠️ Build a Kubernetes Operator in 10 minutes

> **👋 The source code has been updated in early November 2023 to use the latest version of kubebuilder ([v3.13.0](https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v3.13.0)). Expect the code to be kept up to date with the latest kubebuilder releases!**
> **👋 The source code has been updated in early January 2024 to use the latest version of kubebuilder ([v3.14.0](https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v3.14.0)). Expect the code to be kept up to date with the latest kubebuilder releases!**
## Table of Contents

- [Introduction](#introduction)
- [Architecture Diagram](#architecture-diagram)
- [Differences between versions](#differences-between-versions)
- [Contributing](#contributing)

## Introduction

Expand Down Expand Up @@ -128,3 +129,75 @@ diff --color -r operator-v2/internal/controller/suite_test.go operator-v2-with-t
86a112
> cancel()
```

## Contributing

Contributions are welcome! Feel free to open issues or reach out if you want more details! :)

### Bump kubebuilder version

Simple steps to follow to upgrade the tutorial to the latest `kubebuilder` version.

Note: this is an example with `operator-v1`. Repeat the same steps for all the other versions of the operator...

```bash
# Scaffold the new project.
mv operator-v1 operator-v1-old
mkdir operator-v1
pushd operator-v1
kubebuilder init --domain my.domain --repo my.domain/tutorial
kubebuilder create api --group tutorial --version v1 --kind Foo
# Change the `projectName` property to `operator`.
vi PROJECT

# Implement the Foo CRD (`FooSpec` and `FooStatus`).
cat ../operator-v1-old/api/v1/foo_types.go
vi api/v1/foo_types.go

# Same thing with the controller (RBAC permissions, reconcile and setupWithManager functions).
# Note: you may need to resolve some imports such as `corev1`.
cat ../operator-v1-old/internal/controller/foo_controller.go
vi internal/controller/foo_controller.go

# Generate manifests.
make manifests
# Change all occurences of `operator-v1` to `operator`.
# But make sure to keep the `operator-v1` title in `README.md`.

# Test that the new version works.
# Note: for this step, you will need a running Kubernetes cluster.
kind create cluster
kubectl cluster-info --context kind-kind
kubectl get nodes

make install
kubectl get crds
make run

cp ../operator-v1-old/config/samples/tutorial_v1_foo.yaml config/samples
kubectl apply -k config/samples
# Check the logs of the controller, it should detect the creation events.
# Also check the status of the CRDs, they should be empty at this point.
kubectl describe foos

cp ../operator-v1-old/config/samples/pod.yaml config/samples
kubectl apply -f config/samples/pod.yaml
# Again, check the logs of the controller, it should throw some logs.
# The foo-1 CRD should now have an happy status.
kubectl describe foos

# Update the pod name from `jack` to `joe`.
vi config/samples/pod.yaml
kubectl apply -f config/samples/pod.yaml
# Both CRDs should now have an happy status.
kubectl describe foos
kubectl delete pod jack --force
# Only the foo-2 CRD should have an empty status.
kubectl describe foos

# Now compare the diffs between the new and the old projects.
# Also make sure to compare diffs between projects and keep the `README` updated!
# Update the website articles and Medium articles too!
# https://leovct.github.io/
# https://medium.com/@leovct/list/kubernetes-operators-101-dcfcc4cb52f6
```
2 changes: 1 addition & 1 deletion operator-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ More information can be found via the [Kubebuilder Documentation](https://book.k

## License

Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/api/v1/foo_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion operator-v1/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/internal/controller/foo_controller.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v1/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ More information can be found via the [Kubebuilder Documentation](https://book.k

## License

Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/api/v1/foo_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion operator-v2-with-tests/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2-with-tests/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ More information can be found via the [Kubebuilder Documentation](https://book.k

## License

Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/api/v1/foo_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion operator-v2/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/internal/controller/foo_controller.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion operator-v2/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023.
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit cdd7842

Please sign in to comment.