Druid Operator project has started the move from operator SDK to Kubebuilder v2 framework.
In order to finish the project migration and to avoid the upgrade of Kubebuilder v3 in different time,
the project combines both in the following version.
There are now more components that are being deployed:
- permissions for controller leader election
- metrics
- proxy sidecar to the controller
These components are part of the standard Kubebuilder deployment and are being added in order to stand with the best practices of Kubernetes and Kubebuilder.
This guide will help you go through the migration to Kubebuilder V3.
Note: These guides assumes that the current operator is running in the druid-operator
namespace.
Current Helm deployment is missing a labelSelector
+ podSpec label
value: control-plane: controller-manager
.
These fields cannot be updated in place on existing Deployment
.
This section helps you to first add these fields to the Deployment
and then will guide you
through the upgrade stage.
- Get Druid Operator's deployment object
kubectl get deployments.apps -n druid-operator druid-operator -o yaml > druid-deployment-temp.yaml
- Make the following changes:
- Add new label to
labelSelector
and tolabels
- Change the deployment name to
druid-operator-temp
- Remove the
kubectl.kubernetes.io/last-applied-configuration
annotation
apiVersion: apps/v1
kind: Deployment
metadata:
...
name: druid-operator-temp # Name change
spec:
...
selector:
matchLabels:
app.kubernetes.io/instance: druid-operator
app.kubernetes.io/name: druid-operator
control-plane: controller-manager # New label
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/instance: druid-operator
app.kubernetes.io/name: druid-operator
control-plane: controller-manager # New label
...
- Apply a second deployment
kubectl apply -f druid-deployment-temp
- Delete original deployment
kubectl delete deployment -n druid-operator druid-operator
- Edit
druid-deployment-temp.yaml
deployment's name back to original name:
apiVersion: apps/v1
kind: Deployment
metadata:
...
name: druid-operator # Back to original name
spec:
...
selector:
matchLabels:
app.kubernetes.io/instance: druid-operator
app.kubernetes.io/name: druid-operator
control-plane: controller-manager # New label
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/instance: druid-operator
app.kubernetes.io/name: druid-operator
control-plane: controller-manager # New label
...
- Apply the updated original deployment
kubectl apply -f druid-deployment-temp
- Delete temp deployment
kubectl delete deployment -n druid-operator druid-operator-temp
NOTE: You should now have the original deployment with the new labelSelector
and you are ready for moving into new deployment
8. Apply the new helm chart with the same name and same namespace.
Kubebuilder is responsible for generating the deployment YAMLs. By default, the generated namespace is
druid-operator-system
. The new deployment name of the operator is also changed to:
druid-operator-controller-manager
.
Either way, you should look at the deployment YAMLs before you are deploying them.
Service account, role and role binding that will replace the current ones - all should be in the same name.
There are two ways you can choose to deploy the new YAMLs:
- Apply the new controller in the
druid-operator-system
namespace.
NOTE: Make sure this is a different namespace that the existing operator
# Set the tag you want for the controller
cd config/manager
kustomize edit set image controller=datainfrahq/druid-operator:${IMG_TAG}
# Back to root and apply
cd ../../
kustomize build config/default | kubectl apply -f -
- Remove the old namespace.
kubectl delete ns druid-operator
- Edit Kustomize YAMLs
# Set the namespace you want for the controller
cd config/default
kustomize edit set namespace druid-operator
cd ../../
# Set the tag you want for the controller
cd config/manager
kustomize edit set image controller=datainfrahq/druid-operator:${IMG_TAG}
cd ../../
- Apply the YAMLs
kustomize build config/default | kubectl apply -f -
- Delete the old deployment
kubectl delete deployment -n druid-operator druid-operator