...

Source file src/github.com/openshift/api/operator/v1alpha1/types.go

Documentation: github.com/openshift/api/operator/v1alpha1

     1  package v1alpha1
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  
     6  	configv1 "github.com/openshift/api/config/v1"
     7  )
     8  
     9  type ManagementState string
    10  
    11  const (
    12  	// Managed means that the operator is actively managing its resources and trying to keep the component active
    13  	Managed ManagementState = "Managed"
    14  	// Unmanaged means that the operator is not taking any action related to the component
    15  	Unmanaged ManagementState = "Unmanaged"
    16  	// Removed means that the operator is actively managing its resources and trying to remove all traces of the component
    17  	Removed ManagementState = "Removed"
    18  )
    19  
    20  // OperatorSpec contains common fields for an operator to need.  It is intended to be anonymous included
    21  // inside of the Spec struct for you particular operator.
    22  type OperatorSpec struct {
    23  	// managementState indicates whether and how the operator should manage the component
    24  	ManagementState ManagementState `json:"managementState"`
    25  
    26  	// imagePullSpec is the image to use for the component.
    27  	ImagePullSpec string `json:"imagePullSpec"`
    28  
    29  	// imagePullPolicy specifies the image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified,
    30  	// or IfNotPresent otherwise.
    31  	ImagePullPolicy string `json:"imagePullPolicy"`
    32  
    33  	// version is the desired state in major.minor.micro-patch.  Usually patch is ignored.
    34  	Version string `json:"version"`
    35  
    36  	// logging contains glog parameters for the component pods.  It's always a command line arg for the moment
    37  	Logging LoggingConfig `json:"logging,omitempty"`
    38  }
    39  
    40  // LoggingConfig holds information about configuring logging
    41  type LoggingConfig struct {
    42  	// level is passed to glog.
    43  	Level int64 `json:"level"`
    44  
    45  	// vmodule is passed to glog.
    46  	Vmodule string `json:"vmodule"`
    47  }
    48  
    49  type ConditionStatus string
    50  
    51  const (
    52  	ConditionTrue    ConditionStatus = "True"
    53  	ConditionFalse   ConditionStatus = "False"
    54  	ConditionUnknown ConditionStatus = "Unknown"
    55  
    56  	// these conditions match the conditions for the ClusterOperator type.
    57  	OperatorStatusTypeAvailable   = "Available"
    58  	OperatorStatusTypeProgressing = "Progressing"
    59  	OperatorStatusTypeFailing     = "Failing"
    60  
    61  	OperatorStatusTypeMigrating = "Migrating"
    62  	// TODO this is going to be removed
    63  	OperatorStatusTypeSyncSuccessful = "SyncSuccessful"
    64  )
    65  
    66  // OperatorCondition is just the standard condition fields.
    67  type OperatorCondition struct {
    68  	Type               string          `json:"type"`
    69  	Status             ConditionStatus `json:"status"`
    70  	LastTransitionTime metav1.Time     `json:"lastTransitionTime,omitempty"`
    71  	Reason             string          `json:"reason,omitempty"`
    72  	Message            string          `json:"message,omitempty"`
    73  }
    74  
    75  // VersionAvailability gives information about the synchronization and operational status of a particular version of the component
    76  type VersionAvailability struct {
    77  	// version is the level this availability applies to
    78  	Version string `json:"version"`
    79  	// updatedReplicas indicates how many replicas are at the desired state
    80  	UpdatedReplicas int32 `json:"updatedReplicas"`
    81  	// readyReplicas indicates how many replicas are ready and at the desired state
    82  	ReadyReplicas int32 `json:"readyReplicas"`
    83  	// errors indicates what failures are associated with the operator trying to manage this version
    84  	Errors []string `json:"errors"`
    85  	// generations allows an operator to track what the generation of "important" resources was the last time we updated them
    86  	Generations []GenerationHistory `json:"generations"`
    87  }
    88  
    89  // GenerationHistory keeps track of the generation for a given resource so that decisions about forced updated can be made.
    90  type GenerationHistory struct {
    91  	// group is the group of the thing you're tracking
    92  	Group string `json:"group"`
    93  	// resource is the resource type of the thing you're tracking
    94  	Resource string `json:"resource"`
    95  	// namespace is where the thing you're tracking is
    96  	Namespace string `json:"namespace"`
    97  	// name is the name of the thing you're tracking
    98  	Name string `json:"name"`
    99  	// lastGeneration is the last generation of the workload controller involved
   100  	LastGeneration int64 `json:"lastGeneration"`
   101  }
   102  
   103  // OperatorStatus contains common fields for an operator to need.  It is intended to be anonymous included
   104  // inside of the Status struct for you particular operator.
   105  type OperatorStatus struct {
   106  	// observedGeneration is the last generation change you've dealt with
   107  	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
   108  
   109  	// conditions is a list of conditions and their status
   110  	Conditions []OperatorCondition `json:"conditions,omitempty"`
   111  
   112  	// state indicates what the operator has observed to be its current operational status.
   113  	State ManagementState `json:"state,omitempty"`
   114  	// taskSummary is a high level summary of what the controller is currently attempting to do.  It is high-level, human-readable
   115  	// and not guaranteed in any way. (I needed this for debugging and realized it made a great summary).
   116  	TaskSummary string `json:"taskSummary,omitempty"`
   117  
   118  	// currentVersionAvailability is availability information for the current version.  If it is unmanged or removed, this doesn't exist.
   119  	CurrentAvailability *VersionAvailability `json:"currentVersionAvailability,omitempty"`
   120  	// targetVersionAvailability is availability information for the target version if we are migrating
   121  	TargetAvailability *VersionAvailability `json:"targetVersionAvailability,omitempty"`
   122  }
   123  
   124  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   125  
   126  // GenericOperatorConfig provides information to configure an operator
   127  //
   128  // Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
   129  // +openshift:compatibility-gen:internal
   130  type GenericOperatorConfig struct {
   131  	metav1.TypeMeta `json:",inline"`
   132  
   133  	// ServingInfo is the HTTP serving information for the controller's endpoints
   134  	ServingInfo configv1.HTTPServingInfo `json:"servingInfo,omitempty"`
   135  
   136  	// leaderElection provides information to elect a leader. Only override this if you have a specific need
   137  	LeaderElection configv1.LeaderElection `json:"leaderElection,omitempty"`
   138  
   139  	// authentication allows configuration of authentication for the endpoints
   140  	Authentication DelegatedAuthentication `json:"authentication,omitempty"`
   141  	// authorization allows configuration of authentication for the endpoints
   142  	Authorization DelegatedAuthorization `json:"authorization,omitempty"`
   143  }
   144  
   145  // DelegatedAuthentication allows authentication to be disabled.
   146  type DelegatedAuthentication struct {
   147  	// disabled indicates that authentication should be disabled.  By default it will use delegated authentication.
   148  	Disabled bool `json:"disabled,omitempty"`
   149  }
   150  
   151  // DelegatedAuthorization allows authorization to be disabled.
   152  type DelegatedAuthorization struct {
   153  	// disabled indicates that authorization should be disabled.  By default it will use delegated authorization.
   154  	Disabled bool `json:"disabled,omitempty"`
   155  }
   156  
   157  // StaticPodOperatorStatus is status for controllers that manage static pods.  There are different needs because individual
   158  // node status must be tracked.
   159  type StaticPodOperatorStatus struct {
   160  	OperatorStatus `json:",inline"`
   161  
   162  	// latestAvailableDeploymentGeneration is the deploymentID of the most recent deployment
   163  	LatestAvailableDeploymentGeneration int32 `json:"latestAvailableDeploymentGeneration"`
   164  
   165  	// nodeStatuses track the deployment values and errors across individual nodes
   166  	NodeStatuses []NodeStatus `json:"nodeStatuses"`
   167  }
   168  
   169  // NodeStatus provides information about the current state of a particular node managed by this operator.
   170  type NodeStatus struct {
   171  	// nodeName is the name of the node
   172  	NodeName string `json:"nodeName"`
   173  
   174  	// currentDeploymentGeneration is the generation of the most recently successful deployment
   175  	CurrentDeploymentGeneration int32 `json:"currentDeploymentGeneration"`
   176  	// targetDeploymentGeneration is the generation of the deployment we're trying to apply
   177  	TargetDeploymentGeneration int32 `json:"targetDeploymentGeneration"`
   178  	// lastFailedDeploymentGeneration is the generation of the deployment we tried and failed to deploy.
   179  	LastFailedDeploymentGeneration int32 `json:"lastFailedDeploymentGeneration"`
   180  
   181  	// lastFailedDeploymentGenerationErrors is a list of the errors during the failed deployment referenced in lastFailedDeploymentGeneration
   182  	LastFailedDeploymentErrors []string `json:"lastFailedDeploymentErrors"`
   183  }
   184  

View as plain text