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

chore: update kubebuilder version to 3.12.0 #22

Merged
merged 82 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
944af31
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 25, 2023
9de4edf
[kubebuilder] Init project
nakamasato Sep 25, 2023
cd6ba6e
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 25, 2023
f58b611
[Controller] Add log in Reconcile function
nakamasato Sep 25, 2023
bd04e0d
[API] Remove Foo field from custom resource Password
nakamasato Sep 25, 2023
e448a45
[Controller] Fetch Password object
nakamasato Sep 25, 2023
5d160ed
[Controller] Create Secret object if not exists
nakamasato Sep 25, 2023
a5f0350
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 25, 2023
303bcca
[Controller] Generate random password
nakamasato Sep 25, 2023
d00438d
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 25, 2023
6b2ce9e
[API&Controller] Add Password Status
nakamasato Sep 25, 2023
4543b18
[API] Add AdditionalPrinterColumns
nakamasato Sep 25, 2023
0c5735f
[kubebuilder] Create validating admission webhook
nakamasato Sep 25, 2023
ed9b253
[API] Implement validating admission webhook
nakamasato Sep 25, 2023
d88c650
Update README
nakamasato Sep 25, 2023
fbdd3cb
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 25, 2023
37b013a
[kubebuilder] Init project
nakamasato Sep 25, 2023
cfdfa60
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 25, 2023
586b8ba
[Controller] Add log in Reconcile function
nakamasato Sep 25, 2023
d3dfe6f
[API] Remove Foo field from custom resource Password
nakamasato Sep 25, 2023
5a883b3
[Controller] Fetch Password object
nakamasato Sep 25, 2023
593cf68
[Controller] Create Secret object if not exists
nakamasato Sep 25, 2023
7967de7
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 25, 2023
2b00207
[Controller] Generate random password
nakamasato Sep 25, 2023
3f993e2
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 25, 2023
0c8b341
[API&Controller] Add Password Status
nakamasato Sep 25, 2023
ad32338
[API] Add AdditionalPrinterColumns
nakamasato Sep 25, 2023
d11ff0b
[kubebuilder] Create validating admission webhook
nakamasato Sep 25, 2023
0fcc4dc
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 25, 2023
6145045
[kubebuilder] Init project
nakamasato Sep 25, 2023
428c3cb
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 25, 2023
1132a7c
[Controller] Add log in Reconcile function
nakamasato Sep 25, 2023
b6af633
[API] Remove Foo field from custom resource Password
nakamasato Sep 25, 2023
718e63e
[Controller] Fetch Password object
nakamasato Sep 25, 2023
c42d6c2
[Controller] Create Secret object if not exists
nakamasato Sep 25, 2023
5b0440b
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 25, 2023
9c2c0d8
[Controller] Generate random password
nakamasato Sep 25, 2023
52b3477
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 25, 2023
cfa4796
[API&Controller] Add Password Status
nakamasato Sep 25, 2023
5592b29
[API] Add AdditionalPrinterColumns
nakamasato Sep 25, 2023
33545c8
[kubebuilder] Create validating admission webhook
nakamasato Sep 25, 2023
4ab5b3d
[API] Implement validating admission webhook
nakamasato Sep 25, 2023
8d0dd68
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 26, 2023
bb4ec22
[kubebuilder] Init project
nakamasato Sep 26, 2023
f0cd866
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 26, 2023
6baf536
[Controller] Add log in Reconcile function
nakamasato Sep 26, 2023
b7a8c8f
[API] Remove Foo field from custom resource Password
nakamasato Sep 26, 2023
e66fabb
[Controller] Fetch Password object
nakamasato Sep 26, 2023
3503401
[Controller] Create Secret object if not exists
nakamasato Sep 26, 2023
dafe527
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 26, 2023
923a0a0
[Controller] Generate random password
nakamasato Sep 26, 2023
6ad0c2c
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 26, 2023
d510e11
[API&Controller] Add Password Status
nakamasato Sep 26, 2023
24ff8f7
[API] Add AdditionalPrinterColumns
nakamasato Sep 26, 2023
fe41ee0
[kubebuilder] Create validating admission webhook
nakamasato Sep 26, 2023
e3dc933
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 26, 2023
97f5a2a
[kubebuilder] Init project
nakamasato Sep 26, 2023
cbd7a68
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 26, 2023
3451c90
[Controller] Add log in Reconcile function
nakamasato Sep 26, 2023
74f8c67
[API] Remove Foo field from custom resource Password
nakamasato Sep 26, 2023
5f28363
[Controller] Fetch Password object
nakamasato Sep 26, 2023
a59b6da
[Controller] Create Secret object if not exists
nakamasato Sep 26, 2023
1d64154
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 26, 2023
175bfef
[Controller] Generate random password
nakamasato Sep 26, 2023
be4da0c
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 26, 2023
0688994
[API&Controller] Add Password Status
nakamasato Sep 26, 2023
b211d0d
[API] Add AdditionalPrinterColumns
nakamasato Sep 26, 2023
dacb819
[kubebuilder] Create validating admission webhook
nakamasato Sep 26, 2023
7e7ca5c
Remove all files to upgrade versions (v3.12.0)
nakamasato Sep 26, 2023
a334a95
[kubebuilder] Init project
nakamasato Sep 26, 2023
bc53625
[kubebuilder] Create API Password (Controller & Resource)
nakamasato Sep 26, 2023
e3523b0
[Controller] Add log in Reconcile function
nakamasato Sep 26, 2023
054cedb
[API] Remove Foo field from custom resource Password
nakamasato Sep 26, 2023
a4eb933
[Controller] Fetch Password object
nakamasato Sep 26, 2023
9a40e7a
[Controller] Create Secret object if not exists
nakamasato Sep 26, 2023
a723ebe
[Controller] Clean up Secret when Password is deleted
nakamasato Sep 26, 2023
4fdf2ce
[Controller] Generate random password
nakamasato Sep 26, 2023
8fc8bee
[API&Controller] Make password configurable with CRD fields
nakamasato Sep 26, 2023
74de939
[API&Controller] Add Password Status
nakamasato Sep 26, 2023
5e5e2cc
[API] Add AdditionalPrinterColumns
nakamasato Sep 26, 2023
5d4b800
[kubebuilder] Create validating admission webhook
nakamasato Sep 26, 2023
e080906
[API] Implement validating admission webhook
nakamasato Sep 26, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Dockerfile.cross

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
80 changes: 40 additions & 40 deletions .upgrade-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PASSWORD_GO_TYPE_FILE=api/v1alpha1/password_types.go
PASSWORD_WEBHOOK_FILE=api/v1alpha1/password_webhook.go
SAMPLE_YAML_FILE=config/samples/secret_v1alpha1_password.yaml
CERT_MANAGER_VERSION=v1.8.0
SED=${SED:-sed}

pre-commit
get_latest_release() {
Expand Down Expand Up @@ -54,7 +55,6 @@ KEEP_FILES=(
renovate.json
)

sudo rm -rf bin
rm -rf api config controllers hack bin bundle cmd internal
for f in `ls` .dockerignore .gitignore; do
if [[ ! " ${KEEP_FILES[*]} " =~ " ${f} " ]] && [ -f "$f" ]; then
Expand Down Expand Up @@ -112,7 +112,7 @@ pre-commit run -a || true
git commit -am "[kubebuilder] Create API Password (Controller & Resource)"

# 3. [Controller] Add log in Reconcile function
gsed -i '/Reconcile(ctx context.Context, req ctrl.Request) /,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/Reconcile(ctx context.Context, req ctrl.Request) /,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
cat << EOF > tmpfile
func (r *PasswordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)
Expand All @@ -122,22 +122,22 @@ func (r *PasswordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, nil
}
EOF
gsed -i "/pkg\/reconcile/ r tmpfile" $PASSWORD_CONTROLLER_GO_FILE
$SED -i "/pkg\/reconcile/ r tmpfile" $PASSWORD_CONTROLLER_GO_FILE

make fmt
git add . && git commit -m "[Controller] Add log in Reconcile function"

# 4. [API] Remove Foo field from custom resource Password
## PasswordSpec
gsed -i '/type PasswordSpec struct {/,/}/d' $PASSWORD_GO_TYPE_FILE
$SED -i '/type PasswordSpec struct {/,/}/d' $PASSWORD_GO_TYPE_FILE
cat << EOF > tmpfile
type PasswordSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of Password. Edit password_types.go to remove/update
}
EOF
gsed -i "/PasswordSpec defines/ r tmpfile" $PASSWORD_GO_TYPE_FILE
$SED -i "/PasswordSpec defines/ r tmpfile" $PASSWORD_GO_TYPE_FILE
rm tmpfile

## fmt
Expand All @@ -151,7 +151,7 @@ git commit -am "[API] Remove Foo field from custom resource Password"


# 5. [Controller] Fetch Password object
gsed -i '/Reconcile(ctx context.Context, req ctrl.Request) /,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/Reconcile(ctx context.Context, req ctrl.Request) /,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
cat << EOF > tmpfile
func (r *PasswordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)
Expand All @@ -169,7 +169,7 @@ func (r *PasswordReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, nil
}
EOF
gsed -i "/pkg\/reconcile/ r tmpfile" $PASSWORD_CONTROLLER_GO_FILE
$SED -i "/pkg\/reconcile/ r tmpfile" $PASSWORD_CONTROLLER_GO_FILE
rm tmpfile
make fmt

Expand All @@ -179,9 +179,9 @@ git commit -am "[Controller] Fetch Password object"


## 6. [Controller] Create Secret object if not exists
gsed -i '/sigs.k8s.io\/controller-runtime\/pkg\/log/a \\ncorev1 "k8s.io/api/core/v1"' $PASSWORD_CONTROLLER_GO_FILE
gsed -i '/corev1 "k8s.io\/api\/core\/v1"/a "k8s.io/apimachinery/pkg/api/errors"' $PASSWORD_CONTROLLER_GO_FILE
gsed -i '/"k8s.io\/apimachinery\/pkg\/api\/errors"/a metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/sigs.k8s.io\/controller-runtime\/pkg\/log/a \\ncorev1 "k8s.io/api/core/v1"' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/corev1 "k8s.io\/api\/core\/v1"/a "k8s.io/apimachinery/pkg/api/errors"' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/"k8s.io\/apimachinery\/pkg\/api\/errors"/a metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"' $PASSWORD_CONTROLLER_GO_FILE

cat << EOF > tmpfile

Expand All @@ -207,7 +207,7 @@ cat << EOF > tmpfile
logger.Info("Create Secret object if not exists - completed")
EOF
# Add the contents before the last return in Reconcile function.
gsed -i $'/^\treturn ctrl.Result{}, nil/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE
$SED -i $'/^\treturn ctrl.Result{}, nil/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE

cat << EOF > tmpfile

Expand All @@ -228,7 +228,7 @@ cat tmpfile >> $PASSWORD_CONTROLLER_GO_FILE
rm tmpfile

# add rbac after the last rbac line
gsed -i '/kubebuilder:rbac:groups=secret.example.com,resources=passwords\/finalizers/a \/\/+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;' $PASSWORD_CONTROLLER_GO_FILE # add marker for secret
$SED -i '/kubebuilder:rbac:groups=secret.example.com,resources=passwords\/finalizers/a \/\/+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;' $PASSWORD_CONTROLLER_GO_FILE # add marker for secret
make fmt manifests

git add .
Expand All @@ -246,7 +246,7 @@ cat << EOF > tmpfile
}
EOF
# Add the contents after secret := newSecretFromPassword(&password)
gsed -i '/secret := newSecretFromPassword(&password)$/r tmpfile' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/secret := newSecretFromPassword(&password)$/r tmpfile' $PASSWORD_CONTROLLER_GO_FILE
rm tmpfile
make fmt

Expand All @@ -256,7 +256,7 @@ git commit -am "[Controller] Clean up Secret when Password is deleted"


## 8. [Controller] Generate random password
gsed -i '/secretv1alpha1 "example.com\/password-operator\/api\/v1alpha1"/a passwordGenerator "github.com/sethvargo/go-password/password"' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/secretv1alpha1 "example.com\/password-operator\/api\/v1alpha1"/a passwordGenerator "github.com/sethvargo/go-password/password"' $PASSWORD_CONTROLLER_GO_FILE

# Update the way to generate password
cat << EOF > tmpfile
Expand All @@ -267,8 +267,8 @@ cat << EOF > tmpfile
}
secret := newSecretFromPassword(&password, passwordStr)
EOF
gsed -i 's/secret := newSecretFromPassword(&password)/cat tmpfile/e' $PASSWORD_CONTROLLER_GO_FILE
gsed -i 's/err := ctrl.SetControllerReference(\&password, secret, r.Scheme)/err = ctrl.SetControllerReference(\&password, secret, r.Scheme)/g' $PASSWORD_CONTROLLER_GO_FILE
$SED -i 's/secret := newSecretFromPassword(&password)/cat tmpfile/e' $PASSWORD_CONTROLLER_GO_FILE
$SED -i 's/err := ctrl.SetControllerReference(\&password, secret, r.Scheme)/err = ctrl.SetControllerReference(\&password, secret, r.Scheme)/g' $PASSWORD_CONTROLLER_GO_FILE

cat << EOF > tmpfile
func newSecretFromPassword(password *secretv1alpha1.Password, passwordStr string) *corev1.Secret {
Expand All @@ -284,7 +284,7 @@ func newSecretFromPassword(password *secretv1alpha1.Password, passwordStr string
return secret
}
EOF
gsed -i '/func newSecretFromPassword(password \*secretv1alpha1.Password) \*corev1.Secret {/,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
$SED -i '/func newSecretFromPassword(password \*secretv1alpha1.Password) \*corev1.Secret {/,/^}/d' $PASSWORD_CONTROLLER_GO_FILE
cat tmpfile >> $PASSWORD_CONTROLLER_GO_FILE
rm tmpfile

Expand Down Expand Up @@ -324,7 +324,7 @@ type PasswordSpec struct {
}
EOF
# replace PasswordSpec with tmpfile
gsed -i "/type PasswordSpec struct {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_GO_TYPE_FILE
$SED -i "/type PasswordSpec struct {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_GO_TYPE_FILE

# check the length of the properties
make install
Expand All @@ -341,12 +341,12 @@ cat << EOF > tmpfile
)
EOF
# replace a line with tmpfile
gsed -i 's/passwordStr, err := passwordGenerator.Generate(64, 10, 10, false, false)/cat tmpfile/e' $PASSWORD_CONTROLLER_GO_FILE
$SED -i 's/passwordStr, err := passwordGenerator.Generate(64, 10, 10, false, false)/cat tmpfile/e' $PASSWORD_CONTROLLER_GO_FILE
make fmt
rm tmpfile

# Write length: 20 in spec
gsed -i '/spec/!b;n;c\ \ length: 20' $SAMPLE_YAML_FILE
$SED -i '/spec/!b;n;c\ \ length: 20' $SAMPLE_YAML_FILE


git add .
Expand All @@ -365,7 +365,7 @@ const (

EOF

gsed -i $'/EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!/{e cat tmpfile\n}' $PASSWORD_GO_TYPE_FILE
$SED -i $'/EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!/{e cat tmpfile\n}' $PASSWORD_GO_TYPE_FILE

cat << EOF > tmpfile
type PasswordStatus struct {
Expand All @@ -375,7 +375,7 @@ type PasswordStatus struct {
}
EOF
# replace PasswordStatus with tmpfile
gsed -i "/type PasswordStatus struct {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_GO_TYPE_FILE
$SED -i "/type PasswordStatus struct {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_GO_TYPE_FILE
make manifests

cat << EOF > tmpfile
Expand All @@ -386,7 +386,7 @@ if err := r.Status().Update(ctx, &password); err != nil {
}
EOF
# Add the contents before returning the error
gsed -i $'/return ctrl.Result{}, err/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE
$SED -i $'/return ctrl.Result{}, err/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE

cat << EOF > tmpfile

Expand All @@ -397,7 +397,7 @@ cat << EOF > tmpfile
}
EOF
# Add the contents before the last return in Reconcile function.
gsed -i $'/^\treturn ctrl.Result{}, nil/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE
$SED -i $'/^\treturn ctrl.Result{}, nil/{e cat tmpfile\n}' $PASSWORD_CONTROLLER_GO_FILE

rm tmpfile
make fmt install
Expand All @@ -411,8 +411,8 @@ git commit -am "[API&Controller] Add Password Status"

# //+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
# //+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
gsed -i '/\/\/+kubebuilder:subresource:status/a \/\/+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`' $PASSWORD_GO_TYPE_FILE
gsed -i '/\/\/+kubebuilder:subresource:status/a \/\/+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`' $PASSWORD_GO_TYPE_FILE
$SED -i '/\/\/+kubebuilder:subresource:status/a \/\/+kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`' $PASSWORD_GO_TYPE_FILE
$SED -i '/\/\/+kubebuilder:subresource:status/a \/\/+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`' $PASSWORD_GO_TYPE_FILE

make manifests
make install
Expand Down Expand Up @@ -440,7 +440,7 @@ func (r *Password) ValidateCreate() error {
return r.validatePassword()
}
EOF
gsed -i "/func (r \*Password) ValidateCreate() error {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_WEBHOOK_FILE
$SED -i "/func (r \*Password) ValidateCreate() error {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_WEBHOOK_FILE

# Replace ValidateUpdate
cat << EOF > tmpfile
Expand All @@ -450,7 +450,7 @@ func (r *Password) ValidateUpdate(old runtime.Object) error {
return r.validatePassword()
}
EOF
gsed -i "/func (r \*Password) ValidateUpdate(old runtime.Object) error {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_WEBHOOK_FILE
$SED -i "/func (r \*Password) ValidateUpdate(old runtime.Object) error {/,/^}/c $(sed 's/$/\\n/' tmpfile | tr -d '\n' | sed 's/.\{2\}$//')" $PASSWORD_WEBHOOK_FILE

# add validatePassword at the bottom
cat << EOF >> $PASSWORD_WEBHOOK_FILE
Expand All @@ -467,24 +467,24 @@ EOF
rm tmpfile

# add "k8s.io/apimachinery/pkg/api/errors" to import
gsed -i '/^import/a "errors"' $PASSWORD_WEBHOOK_FILE
$SED -i '/^import/a "errors"' $PASSWORD_WEBHOOK_FILE
make fmt

# comment out
gsed -i -e '/fieldSpecs/,+3 s/^\(.*\): \(.*\)/#\1: \2/' config/webhook/kustomizeconfig.yaml
gsed -i -e '/namespace:/,+4 s/^\(.*\): \(.*\)/#\1: \2/' config/webhook/kustomizeconfig.yaml
$SED -i -e '/fieldSpecs/,+3 s/^\(.*\): \(.*\)/#\1: \2/' config/webhook/kustomizeconfig.yaml
$SED -i -e '/namespace:/,+4 s/^\(.*\): \(.*\)/#\1: \2/' config/webhook/kustomizeconfig.yaml

gsed -i -e '/MutatingWebhookConfiguration/,+11 s/^/#/' config/default/webhookcainjection_patch.yaml
gsed -i '0,/apiVersion/s/apiVersion/#apiVersion/' config/default/webhookcainjection_patch.yaml
$SED -i -e '/MutatingWebhookConfiguration/,+11 s/^/#/' config/default/webhookcainjection_patch.yaml
$SED -i '0,/apiVersion/s/apiVersion/#apiVersion/' config/default/webhookcainjection_patch.yaml

# uncomment

gsed -i 's/#- ..\/webhook/- ..\/webhook/g' config/default/kustomization.yaml
gsed -i 's/#- ..\/certmanager/- ..\/certmanager/g' config/default/kustomization.yaml
gsed -i 's/#- manager_webhook_patch.yaml/- manager_webhook_patch.yaml/g' config/default/kustomization.yaml # To enable webhook, uncomment all the sections with [WEBHOOK] prefix
gsed -i 's/#- webhookcainjection_patch.yaml/- webhookcainjection_patch.yaml/g' config/default/kustomization.yaml # To enable cert-manager uncomment all sections with 'CERTMANAGER' prefix.
gsed -i -e '/#replacements:/,+96 s/#//' config/default/kustomization.yaml # To enable cert-manager uncomment all sections with 'CERTMANAGER' prefix.
gsed -i 's/#- patches/- path: patches/g' config/crd/kustomization.yaml
$SED -i 's/#- ..\/webhook/- ..\/webhook/g' config/default/kustomization.yaml
$SED -i 's/#- ..\/certmanager/- ..\/certmanager/g' config/default/kustomization.yaml
$SED -i 's/#- manager_webhook_patch.yaml/- manager_webhook_patch.yaml/g' config/default/kustomization.yaml # To enable webhook, uncomment all the sections with [WEBHOOK] prefix
$SED -i 's/#- webhookcainjection_patch.yaml/- webhookcainjection_patch.yaml/g' config/default/kustomization.yaml # To enable cert-manager uncomment all sections with 'CERTMANAGER' prefix.
$SED -i -e '/#replacements:/,+96 s/#//' config/default/kustomization.yaml # To enable cert-manager uncomment all sections with 'CERTMANAGER' prefix.
$SED -i 's/#- path: patches/- path: patches/g' config/crd/kustomization.yaml

make install
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$CERT_MANAGER_VERSION/cert-manager.yaml
Expand Down Expand Up @@ -530,7 +530,7 @@ git add . && git commit -am "[API] Implement validating admission webhook"
# Update README

# Description
gsed -i '/# password-operator/{n;s/.*/Example Kubernetes Operator project created with kubebuilder, which manages a CRD \`Password\` and generates a configurable password./}' README.md
$SED -i '/# password-operator/{n;s/.*/Example Kubernetes Operator project created with kubebuilder, which manages a CRD \`Password\` and generates a configurable password./}' README.md

# Versions
./.update-readme.sh $KUBEBUILDER_VERSION
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.27.1
ENVTEST_K8S_VERSION = 1.28.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -29,7 +29,7 @@ all: build

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
Expand Down Expand Up @@ -74,26 +74,26 @@ build: manifests generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/main.go

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
$(CONTAINER_TOOL) push ${IMG}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: test ## Build and push docker image for the manager for cross-platform support
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
Expand Down Expand Up @@ -139,8 +139,8 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.1
CONTROLLER_TOOLS_VERSION ?= v0.12.0
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Example Kubernetes Operator project created with kubebuilder, which manages a CR
## Versions
1. Docker Engine: 24.0.2
1. [go](https://github.com/golang/go): [go1.20.6](https://github.com/golang/go/releases/go1.20.6)
1. [kubebuilder](https://github.com/kubernetes-sigs/kubebuilder): [v3.11.0](https://github.com/kubernetes-sigs/kubebuilder/releases/v3.11.0)
1. [kubebuilder](https://github.com/kubernetes-sigs/kubebuilder): [v3.12.0](https://github.com/kubernetes-sigs/kubebuilder/releases/v3.12.0)
1. [Kubernetes](https://github.com/kubernetes/kubernetes): [v1.27.3](https://github.com/kubernetes/kubernetes/releases/tag/v1.27.3)
1. [kind](https://github.com/kubernetes-sigs/kind): [v0.20.0](https://github.com/kubernetes-sigs/kind/releases/tag/v0.20.0)
1. [kustomize](https://github.com/kubernetes-sigs/kustomize): [(devel)](https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2F(devel))
Expand Down Expand Up @@ -82,6 +82,14 @@ make manifests

More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)

### Recreate with new kubebuilder version

Example:

```
echo yes | SED=gsed ./.upgrade-version.sh v3.12.0
```

## License

Copyright 2022.
Expand Down
Loading
Loading