bluegreen_types.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 v1
  14. import (
  15. corev1 "k8s.io/api/core/v1"
  16. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  17. )
  18. // BlueGreenSpec defines the desired state of BlueGreen
  19. type BlueGreenSpec struct {
  20. // Set which service traffic should go
  21. RouteTo BlueOrGreen `json:"routeTo"`
  22. // Pod Spec for a Blue Service
  23. BlueSpec *corev1.PodSpec `json:"blueSpec,omitempty"`
  24. // Pod Spec for a Green Service
  25. GreenSpec *corev1.PodSpec `json:"greenSpec,omitempty"`
  26. }
  27. // +kubebuilder:validation:Enum=Blue;Green
  28. type BlueOrGreen string
  29. const (
  30. Blue BlueOrGreen = "Blue"
  31. Green BlueOrGreen = "Green"
  32. )
  33. // BlueGreenStatus defines the observed state of BlueGreen
  34. type BlueGreenStatus struct {
  35. RouteTo *BlueOrGreen `json:"routeTo,omitempty"`
  36. }
  37. //+kubebuilder:object:root=true
  38. //+kubebuilder:subresource:status
  39. //+kubebuilder:printcolumn:name="RouteTo",type=string,JSONPath=`.status.routeTo`
  40. //+kubebuilder:printcolumn:name="BlueReady",type=integer,JSONPath=`.status.blueReady`
  41. //+kubebuilder:printcolumn:name="GreenReady",type=integer,JSONPath=`.status.greenReady`
  42. // BlueGreen is the Schema for the bluegreens API
  43. type BlueGreen struct {
  44. metav1.TypeMeta `json:",inline"`
  45. metav1.ObjectMeta `json:"metadata,omitempty"`
  46. Spec BlueGreenSpec `json:"spec,omitempty"`
  47. Status BlueGreenStatus `json:"status,omitempty"`
  48. }
  49. //+kubebuilder:object:root=true
  50. // BlueGreenList contains a list of BlueGreen
  51. type BlueGreenList struct {
  52. metav1.TypeMeta `json:",inline"`
  53. metav1.ListMeta `json:"metadata,omitempty"`
  54. Items []BlueGreen `json:"items"`
  55. }
  56. func init() {
  57. SchemeBuilder.Register(&BlueGreen{}, &BlueGreenList{})
  58. }