postgresql_controller.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright 2023.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package controller
  14. import (
  15. "context"
  16. "k8s.io/apimachinery/pkg/runtime"
  17. ctrl "sigs.k8s.io/controller-runtime"
  18. "sigs.k8s.io/controller-runtime/pkg/client"
  19. "sigs.k8s.io/controller-runtime/pkg/log"
  20. databasev1 "github.com/iwanhae/nodb/api/v1"
  21. )
  22. // PostgreSQLReconciler reconciles a PostgreSQL object
  23. type PostgreSQLReconciler struct {
  24. client.Client
  25. Scheme *runtime.Scheme
  26. }
  27. //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls,verbs=get;list;watch;create;update;patch;delete
  28. //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/status,verbs=get;update;patch
  29. //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/finalizers,verbs=update
  30. // Reconcile is part of the main kubernetes reconciliation loop which aims to
  31. // move the current state of the cluster closer to the desired state.
  32. // TODO(user): Modify the Reconcile function to compare the state specified by
  33. // the PostgreSQL object against the actual cluster state, and then
  34. // perform operations to make the cluster state reflect the state specified by
  35. // the user.
  36. //
  37. // For more details, check Reconcile and its Result here:
  38. // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.0/pkg/reconcile
  39. func (r *PostgreSQLReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
  40. _ = log.FromContext(ctx)
  41. // TODO(user): your logic here
  42. return ctrl.Result{}, nil
  43. }
  44. // SetupWithManager sets up the controller with the Manager.
  45. func (r *PostgreSQLReconciler) SetupWithManager(mgr ctrl.Manager) error {
  46. return ctrl.NewControllerManagedBy(mgr).
  47. For(&databasev1.PostgreSQL{}).
  48. Complete(r)
  49. }