|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 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 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1alpha1 |
| 16 | + |
| 17 | +import ( |
| 18 | + v1 "k8s.io/api/core/v1" |
| 19 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 20 | +) |
| 21 | + |
| 22 | +// OpAMPBridgeSpec defines the desired state of OpAMPBridge. |
| 23 | +type OpAMPBridgeSpec struct { |
| 24 | + // OpAMP backend Server endpoint |
| 25 | + // +required |
| 26 | + Endpoint string `json:"endpoint"` |
| 27 | + // Capabilities supported by the OpAMP Bridge |
| 28 | + // +required |
| 29 | + Capabilities map[OpAMPBridgeCapability]bool `json:"capabilities"` |
| 30 | + // ComponentsAllowed is a list of allowed OpenTelemetry components for each pipeline type (receiver, processor, etc.) |
| 31 | + // +optional |
| 32 | + ComponentsAllowed map[string][]string `json:"componentsAllowed,omitempty"` |
| 33 | + // Resources to set on the OpAMPBridge pods. |
| 34 | + // +optional |
| 35 | + Resources v1.ResourceRequirements `json:"resources,omitempty"` |
| 36 | + // NodeSelector to schedule OpAMPBridge pods. |
| 37 | + // +optional |
| 38 | + NodeSelector map[string]string `json:"nodeSelector,omitempty"` |
| 39 | + // Replicas is the number of pod instances for the OpAMPBridge. |
| 40 | + // +optional |
| 41 | + // +kubebuilder:validation:Maximum=1 |
| 42 | + Replicas *int32 `json:"replicas,omitempty"` |
| 43 | + // SecurityContext will be set as the container security context. |
| 44 | + // +optional |
| 45 | + SecurityContext *v1.SecurityContext `json:"securityContext,omitempty"` |
| 46 | + // PodSecurityContext will be set as the pod security context. |
| 47 | + // +optional |
| 48 | + PodSecurityContext *v1.PodSecurityContext `json:"podSecurityContext,omitempty"` |
| 49 | + // PodAnnotations is the set of annotations that will be attached to |
| 50 | + // OpAMPBridge pods. |
| 51 | + // +optional |
| 52 | + PodAnnotations map[string]string `json:"podAnnotations,omitempty"` |
| 53 | + // ServiceAccount indicates the name of an existing service account to use with this instance. When set, |
| 54 | + // the operator will not automatically create a ServiceAccount for the OpAMPBridge. |
| 55 | + // +optional |
| 56 | + ServiceAccount string `json:"serviceAccount,omitempty"` |
| 57 | + // Image indicates the container image to use for the OpAMPBridge. |
| 58 | + // +optional |
| 59 | + Image string `json:"image,omitempty"` |
| 60 | + // UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed |
| 61 | + // +optional |
| 62 | + UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy"` |
| 63 | + // ImagePullPolicy indicates the pull policy to be used for retrieving the container image (Always, Never, IfNotPresent) |
| 64 | + // +optional |
| 65 | + ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"` |
| 66 | + // VolumeMounts represents the mount points to use in the underlying OpAMPBridge deployment(s) |
| 67 | + // +optional |
| 68 | + // +listType=atomic |
| 69 | + VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"` |
| 70 | + // Ports allows a set of ports to be exposed by the underlying v1.Service. |
| 71 | + // +optional |
| 72 | + // +listType=atomic |
| 73 | + Ports []v1.ServicePort `json:"ports,omitempty"` |
| 74 | + // ENV vars to set on the OpAMPBridge Pods. |
| 75 | + // +optional |
| 76 | + Env []v1.EnvVar `json:"env,omitempty"` |
| 77 | + // List of sources to populate environment variables on the OpAMPBridge Pods. |
| 78 | + // +optional |
| 79 | + EnvFrom []v1.EnvFromSource `json:"envFrom,omitempty"` |
| 80 | + // Toleration to schedule OpAMPBridge pods. |
| 81 | + // +optional |
| 82 | + Tolerations []v1.Toleration `json:"tolerations,omitempty"` |
| 83 | + // Volumes represents which volumes to use in the underlying OpAMPBridge deployment(s). |
| 84 | + // +optional |
| 85 | + // +listType=atomic |
| 86 | + Volumes []v1.Volume `json:"volumes,omitempty"` |
| 87 | + // HostNetwork indicates if the pod should run in the host networking namespace. |
| 88 | + // +optional |
| 89 | + HostNetwork bool `json:"hostNetwork,omitempty"` |
| 90 | + // If specified, indicates the pod's priority. |
| 91 | + // If not specified, the pod priority will be default or zero if there is no |
| 92 | + // default. |
| 93 | + // +optional |
| 94 | + PriorityClassName string `json:"priorityClassName,omitempty"` |
| 95 | + // If specified, indicates the pod's scheduling constraints |
| 96 | + // +optional |
| 97 | + Affinity *v1.Affinity `json:"affinity,omitempty"` |
| 98 | + // TopologySpreadConstraints embedded kubernetes pod configuration option, |
| 99 | + // controls how pods are spread across your cluster among failure-domains |
| 100 | + // such as regions, zones, nodes, and other user-defined topology domains |
| 101 | + // https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ |
| 102 | + // +optional |
| 103 | + TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` |
| 104 | +} |
| 105 | + |
| 106 | +// OpAMPBridgeStatus defines the observed state of OpAMPBridge. |
| 107 | +type OpAMPBridgeStatus struct { |
| 108 | + // Version of the managed OpAMP Bridge (operand) |
| 109 | + // +optional |
| 110 | + Version string `json:"version,omitempty"` |
| 111 | +} |
| 112 | + |
| 113 | +// +kubebuilder:object:root=true |
| 114 | +// +kubebuilder:subresource:status |
| 115 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 116 | +// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="OpenTelemetry Version" |
| 117 | +// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.endpoint" |
| 118 | +// +operator-sdk:csv:customresourcedefinitions:displayName="OpAMP Bridge" |
| 119 | +// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1},{Deployment,apps/v1},{ConfigMaps,v1},{Service,v1}} |
| 120 | + |
| 121 | +// OpAMPBridge is the Schema for the opampbridges API. |
| 122 | +type OpAMPBridge struct { |
| 123 | + metav1.TypeMeta `json:",inline"` |
| 124 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 125 | + |
| 126 | + Spec OpAMPBridgeSpec `json:"spec,omitempty"` |
| 127 | + Status OpAMPBridgeStatus `json:"status,omitempty"` |
| 128 | +} |
| 129 | + |
| 130 | +//+kubebuilder:object:root=true |
| 131 | + |
| 132 | +// OpAMPBridgeList contains a list of OpAMPBridge. |
| 133 | +type OpAMPBridgeList struct { |
| 134 | + metav1.TypeMeta `json:",inline"` |
| 135 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 136 | + Items []OpAMPBridge `json:"items"` |
| 137 | +} |
| 138 | + |
| 139 | +func init() { |
| 140 | + SchemeBuilder.Register(&OpAMPBridge{}, &OpAMPBridgeList{}) |
| 141 | +} |
0 commit comments