bluegreen_controller.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright 2022.
  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 controllers
  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. appv1 "github.com/kakao/bluegreen/api/v1"
  21. )
  22. // BlueGreenReconciler reconciles a BlueGreen object
  23. type BlueGreenReconciler struct {
  24. client.Client
  25. Scheme *runtime.Scheme
  26. }
  27. //+kubebuilder:rbac:groups=app.demo.kakao.com,resources=bluegreens,verbs=get;list;watch;create;update;patch;delete
  28. //+kubebuilder:rbac:groups=app.demo.kakao.com,resources=bluegreens/status,verbs=get;update;patch
  29. //+kubebuilder:rbac:groups=app.demo.kakao.com,resources=bluegreens/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 BlueGreen 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.12.2/pkg/reconcile
  39. func (r *BlueGreenReconciler) 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 *BlueGreenReconciler) SetupWithManager(mgr ctrl.Manager) error {
  46. return ctrl.NewControllerManagedBy(mgr).
  47. For(&appv1.BlueGreen{}).
  48. Complete(r)
  49. }