...

Source file src/edge-infra.dev/pkg/edge/constants/api.go

Documentation: edge-infra.dev/pkg/edge/constants

     1  // Package constants contains the strings used throughout the K8s ecosystem
     2  package constants
     3  
     4  import (
     5  	"errors"
     6  	"fmt"
     7  )
     8  
     9  // Domain is the base Domain used in all of our APIs, Labels, Annos, etc
    10  const Domain = "edge.ncr.com"
    11  
    12  // Tenant is the DNS compliant name for storing and referring to
    13  // tenants in labels or annotations
    14  const Tenant = "tenant." + Domain
    15  
    16  var (
    17  	// ErrNoFleetInfo occurs when an object doesn't have the expected
    18  	// fleet metadata
    19  	ErrNoFleetInfo = errors.New("required fleet metadata was not present")
    20  )
    21  
    22  // Cluster is the DNS compliant name for storing and referring to the
    23  // Cluster's name in labels or annotations
    24  const Cluster = "cluster." + Domain
    25  
    26  // Fleet is the annotation for the name of the fleet the resource is tied to
    27  const Fleet = "fleet." + Domain
    28  
    29  // Region is the annotation for the region the resource is tied to
    30  const Region = "region." + Domain
    31  
    32  // Workload is the label that the workload resource is tied to
    33  const Workload = "workload." + Domain
    34  
    35  // ClusterURI is used to store and reference the GCP resource URI for a GKE
    36  // cluster
    37  const ClusterURI = Cluster + "/uri"
    38  
    39  // ClusterComponent is used to store information about what cluster component
    40  // (ACM, GKE connect, K8s Cfg Connector, etc) a given resource is used for
    41  const ClusterComponent = Cluster + "/component"
    42  
    43  // Platform
    44  const (
    45  	// Platform is the DNS compliant name for storing and referring to metadata about
    46  	// the Edge platform itself. Presence of the label/annotation indicates that a
    47  	// given Kubernetes resource is a part of the Edge platform, and not
    48  	// - part of the Kubernetes core system (e.g., `kube-system`)
    49  	// - part of a BYO customer workload
    50  	// - part of a NCR business app (e.g., self-checkout)
    51  	Platform = "platform." + Domain
    52  	// PlatformComponent identifies a specific platform component by name.
    53  	PlatformComponent = Platform + "/component"
    54  	// PlatformOperationID identifies which end to end operation this resource is correlated with.
    55  	PlatformOperationID = Platform + "/operationId"
    56  	// ClusterEdgeIDLabel label key for cluster edge id
    57  	ClusterEdgeIDLabel = "id.cluster.edge.ncr.com"
    58  )
    59  
    60  // SDS Terminal labels used to identify components specific for terminals to configure
    61  const (
    62  	TerminalLabel   = "terminal.ncr.com"
    63  	ConfigTypeLabel = "configtype.ncr.com"
    64  )
    65  
    66  // bsl
    67  const (
    68  	BSL            = "bsl." + Domain
    69  	Banner         = BSL + "/banner"
    70  	Organization   = BSL + "/organization"
    71  	EnterpriseUnit = BSL + "/eu"
    72  	Site           = BSL + "/site"
    73  )
    74  
    75  // NamespaceSelectorType a set of permissible string values for a namespace selector type
    76  type NamespaceSelectorType string
    77  
    78  const (
    79  	PlatformNamespaceSelector = NamespaceSelectorType("edge-platform-ncr")
    80  	NCRNamespaceSelector      = NamespaceSelectorType("edge-ncr")
    81  	TenantNamespaceSelector   = NamespaceSelectorType("edge-tenant")
    82  	HelmNamespaceSelector     = NamespaceSelectorType("edge-helm")
    83  	EdgeNamespaceSelector     = NamespaceSelectorType("edge")
    84  	MonitoringNamespace       = "monitoring"
    85  )
    86  
    87  func (nt NamespaceSelectorType) Valid() bool {
    88  	for _, namespaceSelectorType := range []NamespaceSelectorType{EdgeNamespaceSelector, PlatformNamespaceSelector, NCRNamespaceSelector, TenantNamespaceSelector, HelmNamespaceSelector} {
    89  		if string(nt) == string(namespaceSelectorType) {
    90  			return true
    91  		}
    92  	}
    93  	return false
    94  }
    95  
    96  const (
    97  	EdgeDockerSecret  = "edge-docker-pull-secret" //nolint not credentials
    98  	EdgeHelmSecret    = "edge-helm-secret"
    99  	TenantNameFormat  = "tenant-%s"
   100  	TenantStoreFormat = "tenant-%s-fleet-store"
   101  	EdgeHelmURL       = "https://ncrvoyix.jfrog.io/artifactory/retail-helm-dev/"
   102  )
   103  
   104  const (
   105  	DefaultGCPRegion = "us-east1"
   106  	DefaultGCPZone   = "c"
   107  )
   108  
   109  // gke cluster labels add on cluster in gcp
   110  const (
   111  	GKEFleet        = "fleet"
   112  	GKEBanner       = "banner"
   113  	GKEOrganization = "organization"
   114  	GKECluster      = "cluster-name"
   115  	GKEClusterUUID  = "cluster-uuid"
   116  )
   117  
   118  // dsds k8s network service types
   119  const (
   120  	ServiceTypeClusterDNS         = "cluster-dns-ip"
   121  	ServiceTypePodNetworkCIDR     = "pod-network-cidr"
   122  	ServiceTypeServiceNetworkCIDR = "service-network-cidr"
   123  	ServiceTypeEgressTunnelsCIDR  = "egress-tunnels-cidr"
   124  	ServiceTypeDNS                = "dns"
   125  	ServiceTypeNTP                = "ntp"
   126  	ServiceTypeVIP                = "kube-vip"
   127  )
   128  
   129  var (
   130  	ClusterNetworkServiceDefaults = map[string]string{
   131  		ServiceTypePodNetworkCIDR:     "100.127.0.0/16",
   132  		ServiceTypeClusterDNS:         "10.96.0.10",
   133  		ServiceTypeServiceNetworkCIDR: "10.96.0.0/16",
   134  		ServiceTypeEgressTunnelsCIDR:  "10.80.0.0/22",
   135  	}
   136  	DefaultClusterLocation = fmt.Sprintf("%s-%s", DefaultGCPRegion, DefaultGCPZone)
   137  )
   138  
   139  // cluster network services that may not change after activation
   140  var (
   141  	FixedClusterServices = []string{
   142  		ServiceTypePodNetworkCIDR,
   143  		ServiceTypeServiceNetworkCIDR,
   144  		ServiceTypeEgressTunnelsCIDR,
   145  	}
   146  )
   147  

View as plain text