github.com/pachyderm/pachyderm@v1.13.4/src/server/pkg/serviceenv/config.go (about) 1 package serviceenv 2 3 // Configuration is the generic configuration structure used to access configuration fields. 4 type Configuration struct { 5 *GlobalConfiguration 6 *PachdSpecificConfiguration 7 *WorkerSpecificConfiguration 8 } 9 10 // GlobalConfiguration contains the global configuration. 11 type GlobalConfiguration struct { 12 FeatureFlags 13 EtcdHost string `env:"ETCD_SERVICE_HOST,required"` 14 EtcdPort string `env:"ETCD_SERVICE_PORT,required"` 15 PPSWorkerPort uint16 `env:"PPS_WORKER_GRPC_PORT,default=80"` 16 Port uint16 `env:"PORT,default=650"` 17 HTTPPort uint16 `env:"HTTP_PORT,default=652"` 18 PeerPort uint16 `env:"PEER_PORT,default=653"` 19 S3GatewayPort uint16 `env:"S3GATEWAY_PORT,default=600"` 20 PPSEtcdPrefix string `env:"PPS_ETCD_PREFIX,default=pachyderm_pps"` 21 Namespace string `env:"PACH_NAMESPACE,default=default"` 22 StorageRoot string `env:"PACH_ROOT,default=/pach"` 23 CacheRoot string `env:"PACH_CACHE_ROOT,default=/pach-cache"` 24 GCPercent int `env:"GC_PERCENT,default=50"` 25 LokiHost string `env:"LOKI_SERVICE_HOST"` 26 LokiPort string `env:"LOKI_SERVICE_PORT"` 27 SamlPort uint16 `env:"SAML_PORT,default=654"` 28 OidcPort uint16 `env:"OIDC_PORT,default=657"` 29 30 // PPSSpecCommitID is only set for workers and sidecar pachd instances. 31 // Because both pachd and worker need to know the spec commit (the worker so 32 // that it can avoid jobs for other versions of the same pipelines and the 33 // sidecar so that it can serve the S3 gateway) it's stored in the 34 // GlobalConfiguration, but it isn't set in a cluster's main pachd containers. 35 PPSSpecCommitID string `env:"PPS_SPEC_COMMIT"` 36 } 37 38 // PachdFullConfiguration contains the full pachd configuration. 39 type PachdFullConfiguration struct { 40 GlobalConfiguration 41 PachdSpecificConfiguration 42 } 43 44 // PachdSpecificConfiguration contains the pachd specific configuration. 45 type PachdSpecificConfiguration struct { 46 StorageConfiguration 47 NumShards uint64 `env:"NUM_SHARDS,default=32"` 48 StorageBackend string `env:"STORAGE_BACKEND,default="` 49 StorageHostPath string `env:"STORAGE_HOST_PATH,default="` 50 EtcdPrefix string `env:"ETCD_PREFIX,default="` 51 PFSEtcdPrefix string `env:"PFS_ETCD_PREFIX,default=pachyderm_pfs"` 52 AuthEtcdPrefix string `env:"PACHYDERM_AUTH_ETCD_PREFIX,default=pachyderm_auth"` 53 EnterpriseEtcdPrefix string `env:"PACHYDERM_ENTERPRISE_ETCD_PREFIX,default=pachyderm_enterprise"` 54 KubeAddress string `env:"KUBERNETES_PORT_443_TCP_ADDR,required"` 55 Metrics bool `env:"METRICS,default=true"` 56 Init bool `env:"INIT,default=false"` 57 BlockCacheBytes string `env:"BLOCK_CACHE_BYTES,default=1G"` 58 PFSCacheSize string `env:"PFS_CACHE_SIZE,default=0"` 59 WorkerImage string `env:"WORKER_IMAGE,default="` 60 WorkerSidecarImage string `env:"WORKER_SIDECAR_IMAGE,default="` 61 WorkerImagePullPolicy string `env:"WORKER_IMAGE_PULL_POLICY,default="` 62 LogLevel string `env:"LOG_LEVEL,default=info"` 63 IAMRole string `env:"IAM_ROLE,default="` 64 ImagePullSecret string `env:"IMAGE_PULL_SECRET,default="` 65 NoExposeDockerSocket bool `env:"NO_EXPOSE_DOCKER_SOCKET,default=false"` 66 ExposeObjectAPI bool `env:"EXPOSE_OBJECT_API,default=false"` 67 MemoryRequest string `env:"PACHD_MEMORY_REQUEST,default=1T"` 68 WorkerUsesRoot bool `env:"WORKER_USES_ROOT,default=true"` 69 DeploymentID string `env:"CLUSTER_DEPLOYMENT_ID,default="` 70 RequireCriticalServersOnly bool `env:"REQUIRE_CRITICAL_SERVERS_ONLY",default=false"` 71 MetricsEndpoint string `env:"METRICS_ENDPOINT",default="` 72 // TODO: Merge this with the worker specific pod name (PPS_POD_NAME) into a global configuration pod name. 73 PachdPodName string `env:"PACHD_POD_NAME,required"` 74 } 75 76 // StorageConfiguration contains the storage configuration. 77 type StorageConfiguration struct { 78 StorageMemoryThreshold int64 `env:"STORAGE_MEMORY_THRESHOLD"` 79 StorageShardThreshold int64 `env:"STORAGE_SHARD_THRESHOLD"` 80 StorageLevelZeroSize int64 `env:"STORAGE_LEVEL_ZERO_SIZE"` 81 StorageLevelSizeBase int `env:"STORAGE_LEVEL_SIZE_BASE"` 82 StorageUploadConcurrencyLimit int `env:"STORAGE_UPLOAD_CONCURRENCY_LIMIT,default=100"` 83 StoragePutFileConcurrencyLimit int `env:"STORAGE_PUT_FILE_CONCURRENCY_LIMIT,default=100"` 84 StorageGCPolling string `env:"STORAGE_GC_POLLING"` 85 StorageGCTimeout string `env:"STORAGE_GC_TIMEOUT"` 86 StorageCompactionMaxFanIn int `env:"STORAGE_COMPACTION_MAX_FANIN,default=50"` 87 StorageFileSetsMaxOpen int `env:"STORAGE_FILESETS_MAX_OPEN,default=50"` 88 StorageDiskCacheSize int `env:"STORAGE_DISK_CACHE_SIZE,default=100"` 89 } 90 91 // WorkerFullConfiguration contains the full worker configuration. 92 type WorkerFullConfiguration struct { 93 GlobalConfiguration 94 WorkerSpecificConfiguration 95 } 96 97 // WorkerSpecificConfiguration contains the worker specific configuration. 98 type WorkerSpecificConfiguration struct { 99 // Worker gets its own IP here, via the k8s downward API. It then writes that 100 // IP back to etcd so that pachd can discover it 101 PPSWorkerIP string `env:"PPS_WORKER_IP,required"` 102 // The name of the pipeline that this worker belongs to 103 PPSPipelineName string `env:"PPS_PIPELINE_NAME,required"` 104 // The name of this pod 105 PodName string `env:"PPS_POD_NAME,required"` 106 } 107 108 // FeatureFlags contains the configuration for feature flags. XXX: if you're 109 // adding a new feature flag then you need to make sure it gets propagated to 110 // the workers and their sidecars, this should be done in: 111 // src/server/pps/server/worker_rc.go in the workerPodSpec func. 112 type FeatureFlags struct { 113 StorageV2 bool `env:"STORAGE_V2,default=false"` 114 DisableCommitProgressCounter bool `env:"DISABLE_COMMIT_PROGRESS_COUNTER,default=false"` 115 LokiLogging bool `env:"LOKI_LOGGING,default=false"` 116 } 117 118 // NewConfiguration creates a generic configuration from a specific type of configuration. 119 func NewConfiguration(config interface{}) *Configuration { 120 configuration := &Configuration{} 121 switch v := config.(type) { 122 case *GlobalConfiguration: 123 configuration.GlobalConfiguration = v 124 return configuration 125 case *PachdFullConfiguration: 126 configuration.GlobalConfiguration = &v.GlobalConfiguration 127 configuration.PachdSpecificConfiguration = &v.PachdSpecificConfiguration 128 return configuration 129 case *WorkerFullConfiguration: 130 configuration.GlobalConfiguration = &v.GlobalConfiguration 131 configuration.WorkerSpecificConfiguration = &v.WorkerSpecificConfiguration 132 return configuration 133 default: 134 return nil 135 } 136 }