commons

package
v1.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: UPL-1.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Lifecycle states
	Active   = "ACTIVE"
	Failed   = "FAILED"
	Deleted  = "DELETED"
	Creating = "CREATING"
	Updating = "UPDATING"
	Deleting = "DELETING"

	Source      = "source"
	Destination = "destination"

	UnknownStatus = "unknown status"

	// Finalizers
	MeshFinalizer                     = "finalizers.servicemesh.oci.oracle.com/mesh-resources"
	VirtualServiceFinalizer           = "finalizers.servicemesh.oci.oracle.com/virtualservice-resources"
	VirtualDeploymentFinalizer        = "finalizers.servicemesh.oci.oracle.com/virtualdeployment-resources"
	VirtualServiceRouteTableFinalizer = "finalizers.servicemesh.oci.oracle.com/virtualserviceroutetable-resources"
	AccessPolicyFinalizer             = "finalizers.servicemesh.oci.oracle.com/accesspolicy-resources"
	IngressGatewayFinalizer           = "finalizers.servicemesh.oci.oracle.com/ingressgateway-resources"
	VirtualDeploymentBindingFinalizer = "finalizers.servicemesh.oci.oracle.com/virtualdeploymentbinding-resources"
	IngressGatewayRouteTableFinalizer = "finalizers.servicemesh.oci.oracle.com/ingressgatewayroutetable-resources"
	IngressGatewayDeploymentFinalizer = "finalizers.servicemesh.oci.oracle.com/ingressgatewaydeployment-resources"

	// Inject container names
	InitContainerName  = "init"
	ProxyContainerName = "oci-sm-proxy"

	// linux capabilities
	NetAdminCapability = "NET_ADMIN"

	OsokNamespace              = "oci-service-operator-system"
	ProxyLabelInMeshConfigMap  = "SIDECAR_IMAGE"
	CpEndpointInMeshConfigMap  = "CP_ENDPOINT"
	MdsEndpointInMeshConfigMap = "MDS_ENDPOINT"
	AutoUpdateProxyVersion     = "AUTO_UPDATE_PROXY_VERSION"

	ProxyInjectionLabel     = "servicemesh.oci.oracle.com/sidecar-injection"
	ProxyLogLevelAnnotation = "servicemesh.oci.oracle.com/proxy-log-level"
	DefaultProxyLogLevel    = ProxyLogLevelError
	Enabled                 = "enabled"
	Disabled                = "disabled"
	MeshConfigMapName       = "oci-service-operator-servicemesh-config"
	GlobalConfigMap         = OsokNamespace + "/" + MeshConfigMapName

	// Pod annotation keys
	OutdatedProxyAnnotation            = "servicemesh.oci.oracle.com/outdated-proxy"
	VirtualDeploymentBindingAnnotation = "servicemesh.oci.oracle.com/virtual-deployment-binding-ref"
	VirtualDeploymentAnnotation        = "servicemesh.oci.oracle.com/virtual-deployment-ocid"

	// IngressName Label
	IngressName = "servicemesh.oci.oracle.com/ingress-gateway-deployment"

	TargetCPUUtilizationPercentage = 50

	MetadataNameMaxLength = 190

	DeploymentAPIVersion = "apps/v1"

	Http = "http"
	Tcp  = "tcp"
)
View Source
const (
	DeploymentId  ProxyEnvVars = "DEPLOYMENT_ID"
	ProxyLogLevel ProxyEnvVars = "PROXY_LOG_LEVEL"
	IPAddress     ProxyEnvVars = "IP_ADDRESS" // this is deprecated in favor of POD_IP
	PodIp         ProxyEnvVars = "POD_IP"
	PodUId        ProxyEnvVars = "POD_UID"
	PodName       ProxyEnvVars = "POD_NAME"
	PodNamespace  ProxyEnvVars = "POD_NAMESPACE"
	StatsPort     int32        = 15006
)
View Source
const (
	MeshUserScheme MeshUserHeader = "Mesh-User-Scheme"
	MeshUserHost   MeshUserHeader = "Mesh-User-Host"
	MeshUserPath   MeshUserHeader = "Mesh-User-Path"
	MeshUserPort   MeshUserHeader = "Mesh-User-Port"

	HealthProxyEndpointPath string = "/healthproxy"

	LivenessProbeEndpointPath        string = "/health"
	LivenessProbeEndpointPort        int32  = 15010
	LivenessProbeInitialDelaySeconds int32  = 5
	LocalHost                               = "localhost"
)
View Source
const (
	// Delay duration parameters for rate limiter exponential back off
	MaxDelay           = 10 * time.Second
	MaxControllerDelay = 1 * time.Minute
	BaseDelay          = 500 * time.Millisecond

	PollInterval = time.Second * 5

	// Requeue request to sync resources from k8s to controlplane every 60 mins
	RequeueSyncDuration = time.Minute * 60

	PollControlPlaneEndpointInterval = time.Minute * 10

	ControlPlaneEndpointSleepInterval = time.Second * 30
)

Variables

View Source
var PkiVolume = corev1.Volume{
	Name: "pki",
	VolumeSource: corev1.VolumeSource{
		HostPath: &corev1.HostPathVolumeSource{
			Path: "/etc/pki",
		},
	},
}
View Source
var PkiVolumeMount = corev1.VolumeMount{
	Name:      "pki",
	ReadOnly:  true,
	MountPath: "/etc/pki",
}

Functions

func DefaultControllerRateLimiter

func DefaultControllerRateLimiter(maxDelay time.Duration) workqueue.RateLimiter

DefaultControllerRateLimiter is a no-arg constructor for a default rate limiter for a workqueue. It has both overall and per-item rate limiting. The overall is a token bucket and the per-item is exponential

func GetConditionStatus

func GetConditionStatus(state string) metav1.ConditionStatus

GetConditionStatus returns the state of the condition based on its lifecycle state

func GetConditionStatusFromK8sError

func GetConditionStatusFromK8sError(err error) metav1.ConditionStatus

GetConditionStatusFromK8sError returns the state of the condition based on the error returned from K8s

func GetDefaultExponentialRetryPolicy

func GetDefaultExponentialRetryPolicy() *common.RetryPolicy

func GetServiceMeshCondition

func GetServiceMeshCondition(serviceMeshStatus *servicemeshapi.ServiceMeshStatus, conditionType servicemeshapi.ServiceMeshConditionType) *servicemeshapi.ServiceMeshCondition

GetServiceMeshCondition will get pointer to service mesh's existing condition.

func GetServiceMeshRetryPolicy

func GetServiceMeshRetryPolicy(resource MeshResources) *common.RetryPolicy

func IsStringPresent

func IsStringPresent(strSlice []string, str string) bool

func UpdateServiceMeshCondition

func UpdateServiceMeshCondition(serviceMeshStatus *servicemeshapi.ServiceMeshStatus, conditionType servicemeshapi.ServiceMeshConditionType, status metav1.ConditionStatus, reason string, message string, generation int64) bool

UpdateServiceMeshCondition will update service mesh's condition and return whether it needs to be updated.

Types

type InformerCacheType

type InformerCacheType string
const (
	ConfigMapsCache InformerCacheType = "ConfigMaps"
	NamespacesCache InformerCacheType = "Namespaces"
	ServicesCache   InformerCacheType = "Services"
)

type IngressResourceRequirements

type IngressResourceRequirements string
const (
	//TODO: This is a placeholder and it should be replaced with validated cpu usage after testing.
	IngressCPURequestSize IngressResourceRequirements = "100m"
	//TODO: This is a placeholder and it should be replaced with validated memory usage after testing.
	IngressMemoryRequestSize IngressResourceRequirements = "128Mi"
	//TODO: This is a placeholder and it should be replaced with validated cpu usage after testing.
	IngressCPULimitSize IngressResourceRequirements = "2000m"
	//TODO: This is a placeholder and it should be replaced with validated memory usage after testing.
	IngressMemoryLimitSize IngressResourceRequirements = "1024Mi"
)

type InitContainerEnvVars

type InitContainerEnvVars string
const (
	ConfigureIpTablesEnvName  InitContainerEnvVars = "CONFIGURE_IP_TABLES"
	ConfigureIpTablesEnvValue InitContainerEnvVars = "true"
	EnvoyPortEnvVarName       InitContainerEnvVars = "ENVOY_PORT"
	EnvoyPortEnvVarValue      InitContainerEnvVars = "15000"
)

type MeshRef

type MeshRef struct {
	Id          api.OCID
	DisplayName servicemeshapi.Name
	Mtls        servicemeshapi.MeshMutualTransportLayerSecurity
}

type MeshResources

type MeshResources string
const (
	Mesh                     MeshResources = "Mesh"
	VirtualService           MeshResources = "VirtualService"
	VirtualDeployment        MeshResources = "VirtualDeployment"
	VirtualServiceRouteTable MeshResources = "VirtualServiceRouteTable"
	IngressGateway           MeshResources = "IngressGateway"
	IngressGatewayRouteTable MeshResources = "IngressGatewayRouteTable"
	AccessPolicy             MeshResources = "AccessPolicy"
	IngressGatewayDeployment MeshResources = "IngressGatewayDeployment"
	VirtualDeploymentBinding MeshResources = "VirtualDeploymentBinding"
)

type MeshUserHeader

type MeshUserHeader string

type PodWebhookError

type PodWebhookError string
const (
	InValidProxyLogAnnotation PodWebhookError = "Invalid proxy Log level"
	NoSidecarImageFound       PodWebhookError = "No sidecar image found in config map"
)

type ProxyEnvVars

type ProxyEnvVars string

type ProxyLogLevelType

type ProxyLogLevelType string
const (
	ProxyLogLevelDebug ProxyLogLevelType = "debug"
	ProxyLogLevelInfo  ProxyLogLevelType = "info"
	ProxyLogLevelWarn  ProxyLogLevelType = "warn"
	ProxyLogLevelError ProxyLogLevelType = "error"
	ProxyLogsOff       ProxyLogLevelType = "off"
)

type ResourceConditionMessage

type ResourceConditionMessage string
const (
	ResourceActive            ResourceConditionMessage = "Resource in the control plane is Active, successfully reconciled"
	ResourceDeleted           ResourceConditionMessage = "Resource in the control plane is Deleted"
	ResourceFailed            ResourceConditionMessage = "Resource in the control plane is Failed"
	ResourceCreating          ResourceConditionMessage = "Resource in the control plane is Creating, about to reconcile"
	ResourceUpdating          ResourceConditionMessage = "Resource in the control plane is Updating, about to reconcile"
	ResourceDeleting          ResourceConditionMessage = "Resource in the control plane is Deleting, about to reconcile"
	DependenciesResolved      ResourceConditionMessage = "Dependencies resolved successfully"
	ResourceConfigured        ResourceConditionMessage = "Resource configured successfully"
	ResourceChangeCompartment ResourceConditionMessage = "Changing Compartment of the resource and verifying updates"
)

func GetMessage

func GetMessage(state string) ResourceConditionMessage

GetMessage returns message based on the state

type ResourceConditionMessageVDB

type ResourceConditionMessageVDB string
const (
	ResourceActiveVDB   ResourceConditionMessageVDB = "The associated virtual deployment is Active, successfully reconciled"
	ResourceDeletedVDB  ResourceConditionMessageVDB = "The associated virtual deployment in the control plane is Deleted"
	ResourceFailedVDB   ResourceConditionMessageVDB = "The associated virtual deployment in the control plane is Failed"
	ResourceCreatingVDB ResourceConditionMessageVDB = "The associated virtual deployment in the control plane is Creating, about to reconcile"
	ResourceUpdatingVDB ResourceConditionMessageVDB = "The associated virtual deployment in the control plane is Updating, about to reconcile"
	ResourceDeletingVDB ResourceConditionMessageVDB = "The associated virtual deployment in the control plane is Deleting, about to reconcile"
)

func GetVirtualDeploymentBindingConditionMessage

func GetVirtualDeploymentBindingConditionMessage(state string) ResourceConditionMessageVDB

GetVirtualDeploymentBindingConditionMessage returns message for VirtualDeploymentBinding based on the state of the condition

type ResourceConditionReason

type ResourceConditionReason string
const (
	DependenciesNotResolved ResourceConditionReason = "DependenciesNotResolved"
	LifecycleStateChanged   ResourceConditionReason = "LifecycleStateChanged"
	Successful              ResourceConditionReason = "Successful"
	ConnectionError         ResourceConditionReason = "ConnectionError"
)

func GetReason

GetReason returns a reason based on the state of the condition

func GetVirtualDeploymentBindingConditionReason

func GetVirtualDeploymentBindingConditionReason(status metav1.ConditionStatus) ResourceConditionReason

GetVirtualDeploymentBindingConditionReason returns a reason for VirtualDeploymentBinding based on the state of the condition

type ResourceRef

type ResourceRef struct {
	Id     api.OCID
	Name   servicemeshapi.Name
	MeshId api.OCID
}

type SidecarResourceRequirements

type SidecarResourceRequirements string
const (
	//TODO: This is a placeholder and it should be replaced with validated cpu usage after testing.
	SidecarCPURequestSize SidecarResourceRequirements = "100m"
	//TODO: This is a placeholder and it should be replaced with validated memory usage after testing.
	SidecarMemoryRequestSize SidecarResourceRequirements = "128Mi"
	//TODO: This is a placeholder and it should be replaced with validated cpu usage after testing.
	SidecarCPULimitSize SidecarResourceRequirements = "2000m"
	//TODO: This is a placeholder and it should be replaced with validated memory usage after testing.
	SidecarMemoryLimitSize SidecarResourceRequirements = "1024Mi"
)

type Suffix

type Suffix string
const (
	NativeHorizontalPodAutoScalar Suffix = "-scalar"
	NativeDeployment              Suffix = "-deployment"
	NativeService                 Suffix = "-service"
)

type ValidationWebhookError

type ValidationWebhookError string
const (
	UnknownStatusOnDelete                              ValidationWebhookError = "delete cannot be applied as the status is unknown"
	NotActiveOnUpdate                                  ValidationWebhookError = "update cannot be applied as the state is not Active"
	DependenciesIsUnknownOnUpdate                      ValidationWebhookError = "update cannot be applied as at least one dependency status is unknown"
	UnknownStateOnUpdate                               ValidationWebhookError = "update cannot be applied as the state in the mesh Control Plane is unknown"
	CertificateAuthoritiesIsImmutable                  ValidationWebhookError = "spec.certificateAuthorities is immutable"
	NameIsImmutable                                    ValidationWebhookError = "spec.name is immutable"
	MetadataNameLengthExceeded                         ValidationWebhookError = "metadata.name length should not exceed 190 characters"
	TrafficRouteRuleIsEmpty                            ValidationWebhookError = "spec.routeRule cannot be empty, should contain one of httpRoute,tcpRoute or tlsPassthroughRoute"
	TrafficRouteRuleIsNotUnique                        ValidationWebhookError = "spec.routeRule cannot contain more than one type"
	MeshReferenceIsImmutable                           ValidationWebhookError = "spec.mesh is immutable"
	MeshReferenceIsEmpty                               ValidationWebhookError = "spec.mesh cannot be empty, should contain one of ref or id"
	MeshReferenceIsNotUnique                           ValidationWebhookError = "spec.mesh cannot contain both ref and id"
	MeshReferenceIsDeleting                            ValidationWebhookError = "spec.mesh is being deleted"
	MeshReferenceOCIDNotFound                          ValidationWebhookError = "spec.mesh.id has been deleted or does not exist"
	IngressGatewayReferenceIsImmutable                 ValidationWebhookError = "spec.ingressGateway is immutable"
	IngressGatewayReferenceIsEmpty                     ValidationWebhookError = "spec.ingressGateway cannot be empty, should contain one of ref or id"
	IngressGatewayReferenceIsNotUnique                 ValidationWebhookError = "spec.ingressGateway cannot contain both ref and id"
	IngressGatewayReferenceIsDeleting                  ValidationWebhookError = "spec.ingressGateway is being deleted"
	VirtualServiceReferenceIsImmutable                 ValidationWebhookError = "spec.virtualService is immutable"
	VirtualServiceReferenceIsEmpty                     ValidationWebhookError = "spec.virtualService cannot be empty, should contain one of ref or id"
	VirtualServiceReferenceIsNotUnique                 ValidationWebhookError = "spec.virtualService cannot contain both ref and id"
	VirtualServiceReferenceIsDeleting                  ValidationWebhookError = "spec.virtualService is being deleted"
	VirtualServiceHostNotFound                         ValidationWebhookError = "parent virtualService doesn't have any host"
	VirtualDeploymentReferenceIsEmpty                  ValidationWebhookError = "spec.virtualDeployment cannot be empty, should contain one of ref or id"
	VirtualDeploymentReferenceIsNotUnique              ValidationWebhookError = "spec.virtualDeployment cannot contain both ref and id"
	VirtualDeploymentReferenceIsDeleting               ValidationWebhookError = "spec.virtualDeployment is being deleted"
	VirtualDeploymentOnlyHaveHostnameOrListener        ValidationWebhookError = "service discovery and listeners should be provided together or be both empty"
	KubernetesServiceReferenceIsDeleting               ValidationWebhookError = "spec.service is being deleted"
	KubernetesServiceReferenceNotFound                 ValidationWebhookError = "spec.service has been deleted or does not exist"
	HostNameIsEmptyForDNS                              ValidationWebhookError = "hostname cannot be empty when service discovery type is DNS"
	HostNameShouldBeEmptyForDISABLED                   ValidationWebhookError = "hostname should be empty when service discovery type is DISABLED"
	IngressGatewayDeploymentPortsWithMultipleProtocols ValidationWebhookError = "ingressgatewaydeployment.spec cannot have multiple protocols."
	IngressGatewayDeploymentWithMultiplePortEmptyName  ValidationWebhookError = "ingressgatewaydeployment.spec.ports.name is required when multiple ports are specified"
	IngressGatewayDeploymentPortsWithNonUniqueNames    ValidationWebhookError = "ingressgatewaydeployment.spec.ports.name must be unique"
	IngressGatewayDeploymentInvalidMaxPod              ValidationWebhookError = "spec.deployment.autoscaling maxPods cannot be less than minPods."
	IngressGatewayDeploymentRedundantServicePorts      ValidationWebhookError = "ingressgatewaydeployment.spec has target ports without service "
	VirtualServiceMtlsNotSatisfied                     ValidationWebhookError = "virtualservice mtls mode does not meet the minimum level set on parent mesh"
	MeshMtlsNotSatisfied                               ValidationWebhookError = "mtls mode of dependent virtual services does not meet the minimum level being set on mesh"
	VirtualServiceHostsShouldNotBeEmpty                ValidationWebhookError = "virtualservice hosts should not be empty when there's virtual deployment has listeners and hostname"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL