This operator is implemented for managing an external etcd cluster with ArgoCD. It is written using the Operator SDK framework.
Argo watches the Git repository (specifically resources of kind EtcdConfig) and keeps the Git status synchronized with the Kubernetes cluster.
apiVersion: etcd.dilshan.com/v1
kind: EtcdConfig
A YAML file (with kind: EtcdConfig) is stored and managed in a Git repository.
ArgoCD continuously monitors the Git repository for changes to the YAML file. When a difference (diff) is detected in the YAML file compared to what is deployed in the Kubernetes cluster, ArgoCD triggers an action.
ArgoCD Applies the YAML to the Kubernetes Cluster: The updated YAML file is applied to the Kubernetes cluster.
Operator Watches applied YAML file and YAML-last-synced: The operator monitors both the newly applied YAML file and a YAML-last-synced file (which is a copy of the last applied YAML).
The operator checks for differences between the newly applied YAML and the YAML-last-synced file.
-
Update the etcd Cluster:
The operator updates the external etcd cluster based on the new configuration in the YAML file.
-
Delete YAML-last-synced:
The YAML-last-synced file is deleted as it is no longer up-to-date.
-
Copy Newly Applied YAML to YAML-last-synced:
The newly applied YAML file is copied to create a new YAML-last-synced file, representing the current state.
-
Deletes the specified key from the etcd cluster
-
Update the External etcd Cluster:
The external etcd cluster is updated directly based on the configuration that was intended to be applied by ArgoCD.
-
Copy YAML File to YAML-last-synced:
A copy of this YAML file is saved as YAML-last-synced to ensure the operator has the most recent configuration for future comparisons.
- go version v1.21.0+
- docker version 17.03+.
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
Create a secret named etcd-operator-etcd-auth-secrets for authenticating with the etcd cluster.
Update the etcd-secret.yaml file located in config/manager with the following content:
data:
etcdEndpoints: ""
etcdPassword: ""
etcdUsername: ""
Build and push your image to the location specified by IMG
:
make docker-build docker-push IMG=<some-registry>/etcd-operator:tag
or
change the Makefile
NOTE: This image ought to be published in the personal registry you specified. And it is required to have access to pull the image from the working environment. Make sure you have the proper permission to the registry if the above commands don’t work.
Install the CRDs into the cluster:
make install
Deploy the Manager to the cluster with the image specified by IMG
:
make deploy IMG=<some-registry>/etcd-operator:tag
If Changes Were Made in the Makefile
make deploy
NOTE: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin.
Create instances of your solution You can apply the samples (examples) from the config/sample:
kubectl apply -k config/samples/
NOTE: Ensure that the samples has default values to test it out.
Delete the instances (CRs) from the cluster:
kubectl delete -k config/samples/
Delete the APIs(CRDs) from the cluster:
make uninstall
UnDeploy the controller from the cluster:
make undeploy