github.com/argoproj/argo-events@v1.9.1/pkg/apis/eventbus/v1alpha1/nats_eventbus.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	"github.com/argoproj/argo-events/pkg/apis/common"
     5  	corev1 "k8s.io/api/core/v1"
     6  )
     7  
     8  // NATSBus holds the NATS eventbus information
     9  type NATSBus struct {
    10  	// Native means to bring up a native NATS service
    11  	Native *NativeStrategy `json:"native,omitempty" protobuf:"bytes,1,opt,name=native"`
    12  	// Exotic holds an exotic NATS config
    13  	Exotic *NATSConfig `json:"exotic,omitempty" protobuf:"bytes,2,opt,name=exotic"`
    14  }
    15  
    16  // AuthStrategy is the auth strategy of native nats installaion
    17  type AuthStrategy string
    18  
    19  // possible auth strategies
    20  var (
    21  	AuthStrategyNone  AuthStrategy = "none"
    22  	AuthStrategyToken AuthStrategy = "token"
    23  	AuthStrategyBasic AuthStrategy = "basic"
    24  )
    25  
    26  // NativeStrategy indicates to install a native NATS service
    27  type NativeStrategy struct {
    28  	// Size is the NATS StatefulSet size
    29  	Replicas int32         `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
    30  	Auth     *AuthStrategy `json:"auth,omitempty" protobuf:"bytes,2,opt,name=auth,casttype=AuthStrategy"`
    31  	// +optional
    32  	Persistence *PersistenceStrategy `json:"persistence,omitempty" protobuf:"bytes,3,opt,name=persistence"`
    33  	// ContainerTemplate contains customized spec for NATS container
    34  	// +optional
    35  	ContainerTemplate *ContainerTemplate `json:"containerTemplate,omitempty" protobuf:"bytes,4,opt,name=containerTemplate"`
    36  	// MetricsContainerTemplate contains customized spec for metrics container
    37  	// +optional
    38  	MetricsContainerTemplate *ContainerTemplate `json:"metricsContainerTemplate,omitempty" protobuf:"bytes,5,opt,name=metricsContainerTemplate"`
    39  	// NodeSelector is a selector which must be true for the pod to fit on a node.
    40  	// Selector which must match a node's labels for the pod to be scheduled on that node.
    41  	// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
    42  	// +optional
    43  	NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,6,rep,name=nodeSelector"`
    44  	// If specified, the pod's tolerations.
    45  	// +optional
    46  	Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,7,rep,name=tolerations"`
    47  	// Metadata sets the pods's metadata, i.e. annotations and labels
    48  	Metadata *common.Metadata `json:"metadata,omitempty" protobuf:"bytes,8,opt,name=metadata"`
    49  	// SecurityContext holds pod-level security attributes and common container settings.
    50  	// Optional: Defaults to empty.  See type description for default values of each field.
    51  	// +optional
    52  	SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty" protobuf:"bytes,9,opt,name=securityContext"`
    53  	// Max Age of existing messages, i.e. "72h", “4h35m”
    54  	// +optional
    55  	MaxAge *string `json:"maxAge,omitempty" protobuf:"bytes,10,opt,name=maxAge"`
    56  	// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec.
    57  	// If specified, these secrets will be passed to individual puller implementations for them to use. For example,
    58  	// in the case of docker, only DockerConfig type secrets are honored.
    59  	// More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
    60  	// +optional
    61  	// +patchMergeKey=name
    62  	// +patchStrategy=merge
    63  	ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,11,rep,name=imagePullSecrets"`
    64  	// ServiceAccountName to apply to NATS StatefulSet
    65  	// +optional
    66  	ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,12,opt,name=serviceAccountName"`
    67  	// If specified, indicates the EventSource pod's priority. "system-node-critical"
    68  	// and "system-cluster-critical" are two special keywords which indicate the
    69  	// highest priorities with the former being the highest priority. Any other
    70  	// name must be defined by creating a PriorityClass object with that name.
    71  	// If not specified, the pod priority will be default or zero if there is no
    72  	// default.
    73  	// More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
    74  	// +optional
    75  	PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,13,opt,name=priorityClassName"`
    76  	// The priority value. Various system components use this field to find the
    77  	// priority of the EventSource pod. When Priority Admission Controller is enabled,
    78  	// it prevents users from setting this field. The admission controller populates
    79  	// this field from PriorityClassName.
    80  	// The higher the value, the higher the priority.
    81  	// More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
    82  	// +optional
    83  	Priority *int32 `json:"priority,omitempty" protobuf:"bytes,14,opt,name=priority"`
    84  	// The pod's scheduling constraints
    85  	// More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
    86  	// +optional
    87  	Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,15,opt,name=affinity"`
    88  	// Maximum number of messages per channel, 0 means unlimited. Defaults to 1000000
    89  	MaxMsgs *uint64 `json:"maxMsgs,omitempty" protobuf:"bytes,16,opt,name=maxMsgs"`
    90  	// Total size of messages per channel, 0 means unlimited. Defaults to 1GB
    91  	MaxBytes *string `json:"maxBytes,omitempty" protobuf:"bytes,17,opt,name=maxBytes"`
    92  	// Maximum number of subscriptions per channel, 0 means unlimited. Defaults to 1000
    93  	MaxSubs *uint64 `json:"maxSubs,omitempty" protobuf:"bytes,18,opt,name=maxSubs"`
    94  	// Maximum number of bytes in a message payload, 0 means unlimited. Defaults to 1MB
    95  	MaxPayload *string `json:"maxPayload,omitempty" protobuf:"bytes,19,opt,name=maxPayload"`
    96  	// Specifies the time in follower state without a leader before attempting an election, i.e. "72h", “4h35m”. Defaults to 2s
    97  	RaftHeartbeatTimeout *string `json:"raftHeartbeatTimeout,omitempty" protobuf:"bytes,20,opt,name=raftHeartbeatTimeout"`
    98  	// Specifies the time in candidate state without a leader before attempting an election, i.e. "72h", “4h35m”. Defaults to 2s
    99  	RaftElectionTimeout *string `json:"raftElectionTimeout,omitempty" protobuf:"bytes,21,opt,name=raftElectionTimeout"`
   100  	// Specifies how long a leader waits without being able to contact a quorum of nodes before stepping down as leader, i.e. "72h", “4h35m”. Defaults to 1s
   101  	RaftLeaseTimeout *string `json:"raftLeaseTimeout,omitempty" protobuf:"bytes,22,opt,name=raftLeaseTimeout"`
   102  	// Specifies the time without an Apply() operation before sending an heartbeat to ensure timely commit, i.e. "72h", “4h35m”. Defaults to 100ms
   103  	RaftCommitTimeout *string `json:"raftCommitTimeout,omitempty" protobuf:"bytes,23,opt,name=raftCommitTimeout"`
   104  }
   105  
   106  // GetReplicas return the replicas of statefulset
   107  func (in *NativeStrategy) GetReplicas() int {
   108  	return int(in.Replicas)
   109  }
   110  
   111  // NATSConfig holds the config of NATS
   112  type NATSConfig struct {
   113  	// NATS streaming url
   114  	URL string `json:"url,omitempty" protobuf:"bytes,1,opt,name=url"`
   115  	// Cluster ID for nats streaming
   116  	ClusterID *string `json:"clusterID,omitempty" protobuf:"bytes,2,opt,name=clusterID"`
   117  	// Auth strategy, default to AuthStrategyNone
   118  	// +optional
   119  	Auth *AuthStrategy `json:"auth,omitempty" protobuf:"bytes,3,opt,name=auth,casttype=AuthStrategy"`
   120  	// Secret for auth
   121  	// +optional
   122  	AccessSecret *corev1.SecretKeySelector `json:"accessSecret,omitempty" protobuf:"bytes,4,opt,name=accessSecret"`
   123  }