github.com/webmeshproj/webmesh-cni@v0.0.27/internal/types/constants.go (about) 1 /* 2 Copyright 2023 Avi Zimmerman <avi.zimmerman@gmail.com>. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package types 18 19 import ( 20 "errors" 21 "fmt" 22 ) 23 24 const ( 25 // PodCIDREnvVar is the name of the environment variable that contains the pod CIDR. 26 PodCIDREnvVar = "WEBMESH_CNI_POD_CIDR" 27 // ServiceCIDREnvVar is the name of the environment variable that contains the service CIDR. 28 ServiceCIDREnvVar = "WEBMESH_CNI_SERVICE_CIDR" 29 // ClusterDomainEnvVar is the name of the environment variable that contains the cluster domain. 30 ClusterDomainEnvVar = "WEBMESH_CNI_CLUSTER_DOMAIN" 31 // DryRunEnvVar is the name of the environment variable that enables dry run mode. 32 DryRunEnvVar = "WEBMESH_CNI_INSTALL_DRY_RUN" 33 // NetConfTemplateEnvVar is the name of the environment variable that contains the CNI configuration. 34 NetConfTemplateEnvVar = "WEBMESH_CNI_NETWORK_CONFIG" 35 // DestConfFileNameEnvVar is the name of the file that contains the CNI configuration. 36 DestConfFileNameEnvVar = "WEBMESH_CNI_CONF_NAME" 37 // DestBinEnvVar is the destination directory for the CNI binaries. 38 DestBinEnvVar = "WEBMESH_CNI_BIN_DIR" 39 // DestConfEnvVar is the destination directory for the CNI configuration. 40 DestConfEnvVar = "WEBMESH_CNI_CONF_DIR" 41 // CNINetDirEnvVar is the directory containing host-local IPAM allocations. We release these 42 // when we start for the first time. 43 CNINetDirEnvVar = "WEBMESH_CNI_HOSTNET_DIR" 44 // NodeNameEnvVar is the name of the environment variable that contains the node name. 45 NodeNameEnvVar = "KUBERNETES_NODE_NAME" 46 // PodNamespaceEnvVar is the name of the environment variable that contains the pod namespace. 47 PodNamespaceEnvVar = "KUBERNETES_POD_NAMESPACE" 48 // KubeconfigEnvVar is the name of the environment variable that contains the kubeconfig. 49 KubeconfigEnvVar = "WEBMESH_CNI_KUBECONFIG" 50 // NodeNameReplaceStr is the string that will be replaced in the CNI configuration with the node name. 51 NodeNameReplaceStr = "__KUBERNETES_NODE_NAME__" 52 // PodNamespaceReplaceStr is the string that will be replaced in the CNI configuration with the pod namespace. 53 PodNamespaceReplaceStr = "__KUBERNETES_POD_NAMESPACE__" 54 // KubeAPIEndpointReplaceStr is the string that will be replaced in the CNI configuration with the Kubernetes API endpoint. 55 APIEndpointReplaceStr = "__KUBERNETES_API_ENDPOINT__" 56 // KubeconfigFilepathReplaceStr is the string that will be replaced in the CNI configuration with the kubeconfig filepath. 57 KubeconfigFilepathReplaceStr = "__KUBECONFIG_FILEPATH__" 58 // HostLocalNetDir is the directory containing host-local IPAM allocations. We release these when we start for the first time. 59 DefaultHostLocalNetDir = "/var/lib/cni/networks" 60 // DefaultDestBin is the default destination directory for the CNI binaries. 61 DefaultDestBin = "/opt/cni/bin" 62 // DefaultDestConfDir is the default destination directory for the CNI configuration. 63 DefaultDestConfDir = "/etc/cni/net.d" 64 // DefaultDestConfFilename is the default name of the CNI configuration file. 65 DefaultDestConfFilename = "10-webmesh.conflist" 66 // DefaultNetConfPath is the default path to the CNI configuration file. 67 DefaultNetConfPath = "/etc/cni/net.d/10-webmesh.conflist" 68 // Default kubeconfig path if not provided. 69 DefaultKubeconfigPath = "/etc/cni/net.d/webmesh-kubeconfig" 70 // DefaultNamespace is the default namespace to use for the plugin. 71 DefaultNamespace = "kube-system" 72 // PluginKubeconfigName is the name of the kubeconfig file for the plugin. 73 PluginKubeconfigName = "webmesh-kubeconfig" 74 // PluginBinaryName is the name of the plugin binary. 75 PluginBinaryName = "webmesh" 76 // KubeconfigContextName is the name of the context in the kubeconfig. 77 KubeconfigContextName = "webmesh-cni" 78 // IfacePrefix is the prefix for interface names. 79 IfacePrefix = "wmesh" 80 // IPAMLockID is the ID used for the IPAM lock. 81 IPAMLockID = "webmesh-cni-ipam" 82 ) 83 84 var ( 85 // ErrPeerContainerNotFound is returned when a container is not found. 86 ErrPeerContainerNotFound = fmt.Errorf("peer container not found") 87 ) 88 89 // IsPeerContainerNotFound returns true if the given error is a peer container not found error. 90 func IsPeerContainerNotFound(err error) bool { 91 return errors.Is(err, ErrPeerContainerNotFound) 92 }