/
defaults.go
180 lines (151 loc) · 7.1 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
Copyright 2023.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"fmt"
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
"github.com/spf13/viper"
"k8s.io/apimachinery/pkg/api/resource"
"time"
)
const (
DefaultImageValue = "MustSetInConfig"
CustomCABundleRootMountPath = "/dsp-custom-certs"
// GlobalODHCaBundleConfigMapName key and label values are a contract with
// ODH Platform https://github.com/opendatahub-io/architecture-decision-records/pull/28
GlobalODHCaBundleConfigMapName = "odh-trusted-ca-bundle"
CustomDSPTrustedCAConfigMapNamePrefix = "dsp-trusted-ca"
CustomDSPTrustedCAConfigMapKey = "dsp-ca.crt"
MLPipelineUIConfigMapPrefix = "ds-pipeline-ui-configmap-"
ArtifactScriptConfigMapNamePrefix = "ds-pipeline-artifact-script-"
ArtifactScriptConfigMapKey = "artifact_script"
DSPServicePrefix = "ds-pipeline"
DBSecretNamePrefix = "ds-pipeline-db-"
DBSecretKey = "password"
DBDefaultExtraParams = "{\"tls\":\"%t\"}"
MariaDBName = "mlpipeline"
MariaDBHostPrefix = "mariadb"
MariaDBHostPort = "3306"
MariaDBUser = "mlpipeline"
MariaDBNamePVCSize = "10Gi"
MinioHostPrefix = "minio"
MinioPort = "9000"
MinioScheme = "http"
MinioDefaultBucket = "mlpipeline"
MinioPVCSize = "10Gi"
ObjectStorageSecretName = "mlpipeline-minio-artifact" // hardcoded in kfp-tekton
ObjectStorageAccessKey = "accesskey"
ObjectStorageSecretKey = "secretkey"
MlmdGrpcPort = "8080"
RequeueTimeConfigName = "DSPO.RequeueTime"
)
// DSPO Config File Paths
const (
APIServerImagePath = "Images.ApiServer"
APIServerArtifactImagePath = "Images.Artifact"
PersistenceAgentImagePath = "Images.PersistentAgent"
ScheduledWorkflowImagePath = "Images.ScheduledWorkflow"
APIServerCacheImagePath = "Images.Cache"
APIServerMoveResultsImagePath = "Images.MoveResultsImage"
MariaDBImagePath = "Images.MariaDB"
OAuthProxyImagePath = "Images.OAuthProxy"
MlmdEnvoyImagePath = "Images.MlmdEnvoy"
MlmdGRPCImagePath = "Images.MlmdGRPC"
MlmdWriterImagePath = "Images.MlmdWriter"
)
// DSPA Status Condition Types
const (
DatabaseAvailable = "DatabaseAvailable"
ObjectStoreAvailable = "ObjectStoreAvailable"
APIServerReady = "APIServerReady"
PersistenceAgentReady = "PersistenceAgentReady"
ScheduledWorkflowReady = "ScheduledWorkflowReady"
CrReady = "Ready"
)
// DSPA Ready Status Condition Reasons
// As per k8s api convention: Reason is intended
// to be used in concise output, such as one-line
// kubectl get output, and in summarizing
// occurrences of causes
const (
MinimumReplicasAvailable = "MinimumReplicasAvailable"
FailingToDeploy = "FailingToDeploy"
Deploying = "Deploying"
ComponentDeploymentNotFound = "ComponentDeploymentNotFound"
)
// Any required Configmap paths can be added here,
// they will be automatically included for required
// validation check
var requiredFields = []string{
APIServerImagePath,
APIServerArtifactImagePath,
PersistenceAgentImagePath,
ScheduledWorkflowImagePath,
APIServerCacheImagePath,
APIServerMoveResultsImagePath,
MariaDBImagePath,
OAuthProxyImagePath,
}
// DefaultDBConnectionTimeout is the default DB storage healthcheck timeout
const DefaultDBConnectionTimeout = time.Second * 15
// DefaultObjStoreConnectionTimeout is the default Object storage healthcheck timeout
const DefaultObjStoreConnectionTimeout = time.Second * 15
const DefaultMaxConcurrentReconciles = 10
const DefaultRequeueTime = time.Second * 20
func GetConfigRequiredFields() []string {
return requiredFields
}
// Default ResourceRequirements
var (
APIServerResourceRequirements = createResourceRequirement(resource.MustParse("250m"), resource.MustParse("500Mi"), resource.MustParse("500m"), resource.MustParse("1Gi"))
PersistenceAgentResourceRequirements = createResourceRequirement(resource.MustParse("120m"), resource.MustParse("500Mi"), resource.MustParse("250m"), resource.MustParse("1Gi"))
ScheduledWorkflowResourceRequirements = createResourceRequirement(resource.MustParse("120m"), resource.MustParse("100Mi"), resource.MustParse("250m"), resource.MustParse("250Mi"))
MariaDBResourceRequirements = createResourceRequirement(resource.MustParse("300m"), resource.MustParse("800Mi"), resource.MustParse("1"), resource.MustParse("1Gi"))
MinioResourceRequirements = createResourceRequirement(resource.MustParse("200m"), resource.MustParse("100Mi"), resource.MustParse("250m"), resource.MustParse("1Gi"))
MlPipelineUIResourceRequirements = createResourceRequirement(resource.MustParse("100m"), resource.MustParse("256Mi"), resource.MustParse("100m"), resource.MustParse("256Mi"))
MlmdEnvoyResourceRequirements = createResourceRequirement(resource.MustParse("100m"), resource.MustParse("256Mi"), resource.MustParse("100m"), resource.MustParse("256Mi"))
MlmdGRPCResourceRequirements = createResourceRequirement(resource.MustParse("100m"), resource.MustParse("256Mi"), resource.MustParse("100m"), resource.MustParse("256Mi"))
MlmdWriterResourceRequirements = createResourceRequirement(resource.MustParse("100m"), resource.MustParse("256Mi"), resource.MustParse("100m"), resource.MustParse("256Mi"))
)
func createResourceRequirement(RequestsCPU resource.Quantity, RequestsMemory resource.Quantity, LimitsCPU resource.Quantity, LimitsMemory resource.Quantity) dspav1alpha1.ResourceRequirements {
return dspav1alpha1.ResourceRequirements{
Requests: &dspav1alpha1.Resources{
CPU: RequestsCPU,
Memory: RequestsMemory,
},
Limits: &dspav1alpha1.Resources{
CPU: LimitsCPU,
Memory: LimitsMemory,
},
}
}
func GetStringConfigWithDefault(configName, value string) string {
if !viper.IsSet(configName) {
return value
}
return viper.GetString(configName)
}
func GetDurationConfigWithDefault(configName string, value time.Duration) time.Duration {
if !viper.IsSet(configName) {
return value
}
return viper.GetDuration(configName)
}
// GetCABundleFileMountPath provides the location in pipeline step-copy-artifact step where the
// ca bundle is mounted for aws cli to connect to s3 store.
// Since pipeline step-copy-artifact step uses aws cli, and there are issues surrounding
// passing a path to aws cli (see: https://github.com/aws/aws-cli/issues/3425#issuecomment-402289636)
// as such for pipelines, we concatenate the certs into a single cert bundle and use a separate configmap for this
func GetCABundleFileMountPath() string {
return fmt.Sprintf("%s/%s", CustomCABundleRootMountPath, CustomDSPTrustedCAConfigMapKey)
}