Skip to content

feat(deployment): add option to deploy mysql in KFP standalone #9855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/kustomize/base/cache/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cache-deployment.yaml
- cache-service.yaml
- cache-role.yaml
- cache-rolebinding.yaml
- cache-sa.yaml
- cache-service.yaml
commonLabels:
app: cache-server
images:
Expand Down
97 changes: 97 additions & 0 deletions manifests/kustomize/base/cache/postgresql/cache-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cache-server
labels:
app: cache-server
spec:
replicas: 1
selector:
matchLabels:
app: cache-server
template:
metadata:
labels:
app: cache-server
spec:
containers:
- name: server
image: gcr.io/ml-pipeline/cache-server:dummy
env:
- name: DEFAULT_CACHE_STALENESS
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: DEFAULT_CACHE_STALENESS
- name: MAXIMUM_CACHE_STALENESS
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: MAXIMUM_CACHE_STALENESS
- name: CACHE_IMAGE
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: cacheImage
- name: CACHE_NODE_RESTRICTIONS
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: cacheNodeRestrictions
- name: DBCONFIG_DRIVER
value: pgx
- name: DBCONFIG_DB_NAME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: cacheDb
- name: DBCONFIG_HOST_NAME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: postgresDbHost
- name: DBCONFIG_PORT
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: postgresDbPort
- name: DBCONFIG_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: username
- name: DBCONFIG_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: NAMESPACE_TO_WATCH
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# If you update WEBHOOK_PORT, also change the value of the
# containerPort "webhook-api" to match.
- name: WEBHOOK_PORT
value: "8443"
args: ["--db_driver=$(DBCONFIG_DRIVER)",
"--db_host=$(DBCONFIG_HOST_NAME)",
"--db_port=$(DBCONFIG_PORT)",
"--db_name=$(DBCONFIG_DB_NAME)",
"--db_user=$(DBCONFIG_USER)",
"--db_password=$(DBCONFIG_PASSWORD)",
"--namespace_to_watch=$(NAMESPACE_TO_WATCH)",
"--listen_port=$(WEBHOOK_PORT)",
]
imagePullPolicy: Always
ports:
- containerPort: 8443
name: webhook-api
volumeMounts:
- name: webhook-tls-certs
mountPath: /etc/webhook/certs
readOnly: true
volumes:
- name: webhook-tls-certs
secret:
secretName: webhook-server-tls
serviceAccountName: kubeflow-pipelines-cache
13 changes: 13 additions & 0 deletions manifests/kustomize/base/cache/postgresql/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cache-deployment.yaml
- ../cache-role.yaml
- ../cache-rolebinding.yaml
- ../cache-sa.yaml
- ../cache-service.yaml
commonLabels:
app: cache-server
images:
- name: gcr.io/ml-pipeline/cache-server
newTag: 2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ vars:
fieldref:
fieldpath: data.defaultPipelineRoot
configurations:
- params.yaml
- params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ data:
namespace: `kubectl rollout restart deployment -n <your-namespace>`.
appName: pipeline
appVersion: 2.0.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we should still use 2.0.0 for the consistency across repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed due to version 2.0.1 was released yesterday, see #9899.

dbHost: mysql
dbPort: "3306"
dbHost: mysql # relic to be removed after release
dbPort: "3306" # relic to be removed after release
dbType: mysql
mysqlHost: mysql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Do we want to name the new mysqlPort key to be something similar to the definition in

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure understand. Did you mean to name it something like DBConfig.MySQLConfig.Port?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is right, because it is a configmap, you can call it like dbconfig_mysqlconfig_port.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this. The rest of the variable names are not consistent with their counterparts in config.json either. If we change all of them, this might lead to more backward compatibility issues.

mysqlPort: "3306"
mlmdDb: metadb
cacheDb: cachedb
pipelineDb: mlpipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kubeflow
bases:
- ../../../pipeline/postgres
- ../../../cache/postgres
- ../../../cache-deployer
resources:
- pipeline-install-config.yaml
- postgres-secret.yaml
vars:
- name: kfp-namespace
objref:
kind: Deployment
apiVersion: apps/v1
name: ml-pipeline
fieldref:
fieldpath: metadata.namespace
- name: kfp-app-name
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.appName
- name: kfp-app-version
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.appVersion
- name: kfp-artifact-bucket-name
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.bucketName
- name: kfp-default-pipeline-root
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.defaultPipelineRoot
configurations:
- params.yaml
10 changes: 10 additions & 0 deletions manifests/kustomize/base/installs/generic/postgres/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Allow Kustomize var to replace following fields.
varReference:
- path: data/config
kind: ConfigMap
- path: data/defaultPipelineRoot
kind: ConfigMap
- path: metadata/name
kind: Application
- path: spec/descriptor/version
kind: Application
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pipeline-install-config
data:
warning: |
1. Do not use kubectl to edit this configmap, because some values are used
during kustomize build. Instead, change the configmap and apply the entire
kustomize manifests again.
2. After updating the configmap, some deployments may need to be restarted
until the changes take effect. A quick way to restart all deployments in a
namespace: `kubectl rollout restart deployment -n <your-namespace>`.
appName: pipeline
appVersion: 2.0.0
dbHost: postgres # relic to be removed after release
dbPort: "5432" # relic to be removed after release
dbType: postgres
postgresHost: postgres
postgresPort: "5432"
mlmdDb: metadb
cacheDb: cachedb
pipelineDb: mlpipeline
bucketName: mlpipeline
## defaultPipelineRoot: Optional. Default pipeline root in v2 compatible mode.
## https://www.kubeflow.org/docs/components/pipelines/sdk/v2/v2-compatibility/
##
## If the field is not set, kfp-launcher configmaps won't be created and
## v2 compatible mode defaults to minio://mlpipeline/v2/artifacts as pipeline
## root.
##
## When not in Kubeflow Pipelines multi-user mode, the config works as you
## would normally expect.
##
## In Kubeflow Pipelines multi-user mode, the config creates default
## kfp-launcher configmaps in each user's namespace. Users can edit the
## kfp-launcher configmap's defaultPipelineRoot field afterwards to configure
## namespace-specific default pipeline root. The namespace specific changes in
## kfp-launcher configmap won't be overridden by pipeline-install-config.
##
## Caveat: when you update the config from a non-empty value, only new
## namespaces get the updated config by default. Owners of existing namespaces
## must delete the kfp-launcher configmap to get the new default config value.
##
## Examples:
## defaultPipelineRoot: minio://mlpipeline/v2/artifacts
## defaultPipelineRoot: gs://your-bucket/path/to/artifacts
## defaultPipelineRoot: s3://your-bucket/path/to/artifacts
##
## V2 Compatible Mode Feature stage:
## [Beta](https://github.com/kubeflow/pipelines/blob/master/docs/release/feature-stages.md#beta)
defaultPipelineRoot: ""
## autoUpdatePipelineDefaultVersion: States if the pipeline version
## should be updated by defult for a versioned pipeline or not when a new
## version is uploaded. This sets the deployment wide definition.
autoUpdatePipelineDefaultVersion: "true"
## cronScheduleTimezone: States the timezone which should be used for
## the cron scheduler. If not specified the local timezone of the
## cluster will be used. Valid values are UTC, Local or values according to
## the IANA Time Zone database, such as "America/New_York" and "Asia/Shanghai".
## Feature stage:
## [Alpha](https://github.com/kubeflow/pipelines/blob/master/docs/release/feature-stages.md#alpha)
cronScheduleTimezone: "UTC"
## cacheImage is the image that the mutating webhook will use to patch
## cached steps with. Will be used to echo a message announcing that
## the cached step result will be used. If not set it will default to
## 'gcr.io/google-containers/busybox'
cacheImage: "gcr.io/google-containers/busybox"
## cacheNodeRestrictions the dummy container runing if output is cached
## will run with the same affinity and node selector as the default pipeline
## step. This is defaulted to 'false' to allow the pod to be scheduled on
## any node and avoid defaulting to specific nodes. Allowed values are:
## 'false' and 'true'.
cacheNodeRestrictions: "false"
## MAXIMUM_CACHE_STALENESS configures caching according to
## https://www.kubeflow.org/docs/components/pipelines/overview/caching/ and
## https://www.kubeflow.org/docs/components/pipelines/overview/caching-v2/.
## Larger than MAXIMUM_CACHE_STALENESS per pipeline user set values are
## reduced to MAXIMUM_CACHE_STALENESS.
## The administrator of the storage backend can rely on it to delete old cache
## artifacts.
MAXIMUM_CACHE_STALENESS: ""
## MAXIMUM_CACHE_STALENESS: "P30D"
## DEFAULT_CACHE_STALENESS configures caching according to
## https://www.kubeflow.org/docs/components/pipelines/overview/caching/ and
## https://www.kubeflow.org/docs/components/pipelines/overview/caching-v2/.
## This value is used if the user did not set a value in the pipeline.
DEFAULT_CACHE_STALENESS: ""
## DEFAULT_CACHE_STALENESS: "P7D"
## ConMaxLifeTime will set the connection max lifetime for MySQL
## this is very important to setup when using external databases.
## See this issue for more details: https://github.com/kubeflow/pipelines/issues/5329
## Note: this value should be a string that can be parsed by `time.ParseDuration`.
## If this value doesn't include a unit abbreviation, the units will be assumed
## to be nanoseconds.
ConMaxLifeTime: "120s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Secret
apiVersion: v1
metadata:
name: postgres-secret
stringData:
username: user
password: "password"
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ spec:
configMapKeyRef:
name: pipeline-install-config
key: bucketName
# relic variables
- name: DBCONFIG_USER
valueFrom:
secretKeyRef:
Expand All @@ -58,11 +59,44 @@ spec:
configMapKeyRef:
name: pipeline-install-config
key: dbPort
# end of relic variables
- name: DBCONFIG_CONMAXLIFETIME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: ConMaxLifeTime
- name: DB_DRIVER_NAME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: dbType
# MySQL Config
- name: DBCONFIG_MYSQLCONFIG_USER
valueFrom:
secretKeyRef:
name: mysql-secret
key: username
- name: DBCONFIG_MYSQLCONFIG_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: password
- name: DBCONFIG_MYSQLCONFIG_DBNAME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: pipelineDb
- name: DBCONFIG_MYSQLCONFIG_HOST
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: mysqlHost
- name: DBCONFIG_MYSQLCONFIG_PORT
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: mysqlPort
# end of MySQL Config
- name: OBJECTSTORECONFIG_ACCESSKEY
valueFrom:
secretKeyRef:
Expand Down
Loading