Skip to content

Commit

Permalink
[Manifest] Apply kustomize best practices to standalone manifest (#3978)
Browse files Browse the repository at this point in the history
* Use configMapKeyRef for env vars

* Allow easy customization of cluster-scoped resources namespace

* clean up

* Clean up

* Simplify var replacement with direct configmap value ref

* clean up params.env
  • Loading branch information
Bobgy committed Jun 16, 2020
1 parent 0e7c05c commit 7339da0
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ metadata:
data:
config: |
{
namespace: $(NAMESPACE),
namespace: $(kfp-namespace),
executorImage: gcr.io/ml-pipeline/argoexec:v2.7.5-license-compliance,
artifactRepository:
{
s3: {
bucket: $(BUCKET_NAME),
bucket: $(kfp-artifact-bucket-name),
keyPrefix: artifacts,
endpoint: minio-service.$(NAMESPACE):9000,
endpoint: minio-service.$(kfp-namespace):9000,
insecure: true,
accessKeySecret: {
name: mlpipeline-minio-artifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: kubeflow-pipelines-cache-deployer-sa
namespace: $(NAMESPACE)
# namespace will be added by kustomize automatically according to the namespace field in kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubeflow-pipelines-cache-deployer-sa
name: kubeflow-pipelines-cache-deployer-sa
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ kind: Kustomization
resources:
- cache-deployer-clusterrole.yaml
- cache-deployer-clusterrolebinding.yaml
# HACK: although a service account(SA) is not a cluster-scoped resource.
# Presence of a SA referred by a clusterrolebinding allows kustomize to auto-add
# namespace for the clusterrolebinding's SA ref.
- cache-deployer-sa.yaml

2 changes: 0 additions & 2 deletions manifests/kustomize/base/cache-deployer/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ kind: Kustomization
resources:
- cache-deployer-role.yaml
- cache-deployer-rolebinding.yaml
- cache-deployer-sa.yaml
- cache-deployer-deployment.yaml

12 changes: 6 additions & 6 deletions manifests/kustomize/base/cache/cache-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ spec:
- name: DBCONFIG_DB_NAME
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: cache_db
name: pipeline-install-config
key: cacheDb
- name: DBCONFIG_HOST_NAME
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: host
name: pipeline-install-config
key: dbHost
- name: DBCONFIG_PORT
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: port
name: pipeline-install-config
key: dbPort
- name: DBCONFIG_USER
valueFrom:
secretKeyRef:
Expand Down
45 changes: 5 additions & 40 deletions manifests/kustomize/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kubeflow
bases:
- application
- argo
- pipeline
- metadata
- mysql
- cache
- cache-deployer
resources:
Expand Down Expand Up @@ -37,63 +37,28 @@ secretGenerator:
- name: mysql-secret
env: params-db-secret.env
vars:
- name: NAMESPACE
- name: kfp-namespace
objref:
kind: Deployment
apiVersion: apps/v1
name: ml-pipeline
fieldref:
fieldpath: metadata.namespace
- name: APP_NAME
- name: kfp-app-name
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.appName
- name: APP_VERSION
- name: kfp-app-version
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.appVersion
- name: DBSERVICE_HOST
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.dbHost
- name: DBSERVICE_PORT
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.dbPort
- name: DBNAME_MLMD
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.mlmdDb
- name: DBNAME_CACHE
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.cacheDb
- name: DBNAME_PIPELINE
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.pipelineDb
- name: BUCKET_NAME
- name: kfp-artifact-bucket-name
objref:
kind: ConfigMap
name: pipeline-install-config
Expand Down
12 changes: 6 additions & 6 deletions manifests/kustomize/base/metadata/metadata-grpc-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ spec:
- name: MYSQL_DATABASE
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: mlmd_db
name: pipeline-install-config
key: mlmdDb
- name: MYSQL_HOST
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: host
name: pipeline-install-config
key: dbHost
- name: MYSQL_PORT
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: port
name: pipeline-install-config
key: dbPort
command: ["/bin/metadata_store_server"]
args: ["--grpc_port=8080",
"--mysql_config_database=$(MYSQL_DATABASE)",
Expand Down
5 changes: 0 additions & 5 deletions manifests/kustomize/base/mysql/kustomization.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions manifests/kustomize/base/mysql/mysql-configmap.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions manifests/kustomize/base/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@
varReference:
- path: data/config
kind: ConfigMap
- path: data/bucket_name
kind: ConfigMap
- path: data/project_id
kind: ConfigMap
- path: data/host
kind: ConfigMap
- path: data/port
kind: ConfigMap
- path: data/mlmd_db
kind: ConfigMap
- path: data/cache_db
kind: ConfigMap
- path: data/pipeline_db
kind: ConfigMap
- path: metadata/name
kind: Application
- path: spec/descriptor/version
kind: Application
- path: spec/template/spec/containers/image
kind: Deployment
4 changes: 2 additions & 2 deletions manifests/kustomize/base/pipeline-application.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: app.k8s.io/v1beta1
kind: Application
metadata:
name: $(APP_NAME)
name: $(kfp-app-name)
annotations:
kubernetes-engine.cloud.google.com/icon: >-
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAyCAYAAADx/eOPAAALuUlEQVRogd2afWxd9XnHP99bK4pS3yhiGUIRiiJUVVVqbq8ppdR20ibqpuIMtDRkUYERp29J57gMZVuxsrZiK7oZXVv5re1AiOuoG+N1DMkuytprsGPEVMouxqQZJVHEWIdQlGVxZlmZdb/747zcc869jpMO+seOdPz7nd/L83tev89zzjX8Bq795Rq9o17zXp+Tey+Ijkyboela29DRWkhffyT733pH/Z3este9F2cC6N0kNjxtjD+FdRD8UF9X7u97y7UbQFPAivC0BdllS381slun3s3z3xVhhqeds90tqR/oMB7u68z19ZZra0E/l1if3WOziPx3skrDPTr+bvDxfxImEIJbgX6gGBJ7EfHJX/ySReDHwO9KYAenyWCMFKw21GSeslwa2Z17+TcuzPBRr7B8m6Df5oOJqdPAR/u6cm/2lmv3At+IT3GiXZqbcaxSLsfRoTsvn7XL2jE87ZXGnwf+VGiDY86ETM1wU1+XjvSW/RlgTJADQ2QaCZKWcX1/aDIcjE8i3SdzZLjn0lm8pJXD02417BM+gLmq2Rqjr/d16Vu95dp6wc8Ra5O8NrPIcoZCvIR1H+KZkd2qLcfnRYUZOuorJO+3uQt0RerolGYZR7r5+C9ZATwPviGyQprd6Liszy3bnwVKwGMjPbnFyxJmeNpX2T4gaR/QmmSpyYZTho/2depMb9k/kNh3KawuJ1bWauHzUcyXRpZAv5Zmg7aHBLcmNN9ECAFeAO3s69KZ3nLtDuF9dnBs0IT9JO24rbPb0JfP2syCZpFfE5q1mRWcvlgMNcwMTRq9z/+OWXdx4AGjvX1deqC37DbwPwOrMgsufol5mWMWs1ivEbjTrOCtLNNb+udygqsNbUBtopR/NkuuwTJ6Hxsw67KSuvH5MPDA/nJttfGTdUFCMUlp/ALwOtIs9muBxpnFnBzuSQf21oP/BbXclVvumWuTaDN8WNBm2GizJkxPM0CDMA2WGZ72bbb/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xBTgorACKrRGf5bczOiVLrhUL74B2F9oHVjBd/iLwTWEhr+CIWaLYumDjIWLHha+aSwvRs1iJmJ9Kb9ZJRETS3ACsMC8i1ZNwgXZDYWTmU/1WhfeAW8Cjo+UL7wDrGik8jfid0kYz/Z2ODepv+GPIY+FAznpcUJhAo9w5mh81CFtEsWieCTzwXkogmfKBSyh8ttA98EDPqoPouYqYLxYEPMVY8itmEeTM+KEaqZhVAkiPPIL6QDPhLFiYQSC9J7M3mGlF/24zWSvwIM1xoH2gF/sFiTcSPxQakqUJxsIPx4jGCr0AzCUYTbROJ7DPAdsbSAX9ZwgDs3qTDiMGUOxF/1DgfekLVsPf0sw8DPARsDNwy8iYBXov4p0L7wC2MF99CfBJ4rqmbJbO/qYE+x1jx5HK8Xtp/aFgHDM/FX+RM9FFjHjjj4NV3HvlPsP4g+SqQgm6zCuvJQnHgi4wVz2JuAj8RnLGEVaCf8Y8cuRQ2L0mYEBB2Gb8ZHKD4NQBx+0Qpf7LQPrAVVGqiiWTpCcEn4QcLxcF7C7+aXMDahT1YX5IS5DHE/ZfC4yULEwr0DtIOWwuuvwZ8rVLKP1soDqzHPGJoyRao9b4SXiQQ30A8eO1/PJ8D7gK+BtQSJcQM8AXGlg747LUkmi91lad8J3CuZ5OeBii0D64ET2FdH1N0omWJvgLPkvwM8LmZf7lrnm3VO4CHsM4DH2P8I8vGSfK67P9q8v9wWPAcQLH4PbBHbK6Pq+3M9+Ml+6FL2dyC+WmhOLiWseKPMDeDd12uIPBrWCZ5Xds++AHsAwGlBKnoB5747c2J+aSJEuvRL8CDv/2Zz+cqh/LL/gPD//vrfwFjcI5oX6jDBwAAAABJRU5ErkJggg==
Expand All @@ -12,7 +12,7 @@ spec:
matchLabels:
application-crd-id: kubeflow-pipelines
descriptor:
version: $(APP_VERSION)
version: $(kfp-app-version)
type: Kubeflow Pipelines
description: |-
Reusable end-to-end ML workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ spec:
- name: OBJECTSTORECONFIG_SECURE
value: "false"
- name: OBJECTSTORECONFIG_BUCKETNAME
value: $(BUCKET_NAME)
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: bucketName
- name: DBCONFIG_USER
valueFrom:
secretKeyRef:
Expand All @@ -36,18 +39,18 @@ spec:
- name: DBCONFIG_DBNAME
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: pipeline_db
name: pipeline-install-config
key: pipelineDb
- name: DBCONFIG_HOST
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: host
name: pipeline-install-config
key: dbHost
- name: DBCONFIG_PORT
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: port
name: pipeline-install-config
key: dbPort
image: gcr.io/ml-pipeline/api-server:dummy
imagePullPolicy: IfNotPresent
name: ml-pipeline-api-server
Expand Down
35 changes: 17 additions & 18 deletions manifests/kustomize/cluster-scoped-resources/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: kubeflow

resources:
- namespace.yaml
bases:
- ../base/application/cluster-scoped
- ../base/argo/cluster-scoped
- ../base/pipeline/cluster-scoped
- ../base/cache-deployer/cluster-scoped

resources:
- namespace.yaml

# Used by Kustomize
configMapGenerator:
- name: pipeline-cluster-scoped-install-config
env: params.env

vars:
- name: NAMESPACE
objref:
kind: ConfigMap
name: pipeline-cluster-scoped-install-config
apiVersion: v1
fieldref:
fieldpath: data.namespace

# NOTE: var name must be unique globally to allow composition of multiple kustomize
# packages. Therefore, we added prefix `kfp-cluster-scoped-` to distinguish it from
# others.
- name: kfp-cluster-scoped-namespace
objref:
# cache deployer sa's metadata.namespace will be first transformed by namespace field in kustomization.yaml
# so that we only need to change kustomization.yaml's namespace field for namespace customization.
kind: ServiceAccount
name: kubeflow-pipelines-cache-deployer-sa
apiVersion: v1
fieldref:
fieldpath: metadata.namespace
configurations:
- params.yaml
- params.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: $(NAMESPACE)
name: '$(kfp-cluster-scoped-namespace)'
1 change: 0 additions & 1 deletion manifests/kustomize/cluster-scoped-resources/params.env

This file was deleted.

2 changes: 0 additions & 2 deletions manifests/kustomize/cluster-scoped-resources/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
varReference:
- path: metadata/name
kind: Namespace
- path: subjects/namespace
kind: ClusterRoleBinding
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ spec:
containers:
- image: gcr.io/cloudsql-docker/gce-proxy:1.14
name: cloudsqlproxy
env:
- name: GCP_CLOUDSQL_INSTANCE_NAME
valueFrom:
configMapKeyRef:
name: pipeline-install-config
key: gcsCloudSqlInstanceName
command: ["/cloud_sql_proxy",
"-dir=/cloudsql",
"-instances=$(GCP_CLOUDSQL_INSTANCE_NAME)=tcp:0.0.0.0:3306",
Expand All @@ -37,4 +43,4 @@ spec:
name: cloudsql
volumes:
- name: cloudsql
emptyDir:
emptyDir:
13 changes: 5 additions & 8 deletions manifests/kustomize/env/gcp/gcp-configurations-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ spec:
- name: ml-pipeline-api-server
env:
- name: HAS_DEFAULT_BUCKET
valueFrom:
configMapKeyRef:
name: gcp-default-config
key: "has_default_bucket"
value: 'true'
- name: BUCKET_NAME
valueFrom:
configMapKeyRef:
name: gcp-default-config
key: "bucket_name"
name: pipeline-install-config
key: bucketName
- name: PROJECT_ID
valueFrom:
configMapKeyRef:
name: gcp-default-config
key: "project_id"
name: pipeline-install-config
key: gcsProjectId

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7339da0

Please sign in to comment.