Skip to content
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

feat: Use KFP multi user mode for GCP #1373

Merged
merged 4 commits into from
Jul 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ spec:
envFrom:
- configMapRef:
name: profile-controller-env
env:
- name: MINIO_ACCESS_KEY
valueFrom:
secretKeyRef:
name: mlpipeline-minio-artifact
key: accesskey
- name: MINIO_SECRET_KEY
valueFrom:
secretKeyRef:
name: mlpipeline-minio-artifact
key: secretkey
volumeMounts:
- name: hooks
mountPath: /hooks
Expand Down
31 changes: 18 additions & 13 deletions pipeline/installs/multi-user/pipelines-profile-controller/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import os
import base64

kfp_version = os.environ["KFP_VERSION"]
disable_istio_sidecar = os.environ.get("DISABLE_ISTIO_SIDECAR") == "true"
mlpipeline_minio_access_key = os.environ.get("MINIO_ACCESS_KEY")
mlpipeline_minio_secret_key = os.environ.get("MINIO_SECRET_KEY")


class Controller(BaseHTTPRequestHandler):
Expand Down Expand Up @@ -49,18 +52,6 @@ def sync(self, parent, children):
# parent is a namespace
namespace = parent.get("metadata", {}).get("name")
desired_resources = [
{
"apiVersion": "v1",
"kind": "Secret",
"metadata": {
"name": "mlpipeline-minio-artifact",
"namespace": namespace,
},
"data": {
"accesskey": "bWluaW8=", # base64 for minio
"secretkey": "bWluaW8xMjM=", # base64 for minio123
},
},
{
"apiVersion": "v1",
"kind": "ConfigMap",
Expand Down Expand Up @@ -255,7 +246,21 @@ def sync(self, parent, children):
}
},
]
print('Received request', parent, desired_resources)
print('Received request:', parent)
print('Desired resources except secrets:', desired_resources)
# Moved after the print argument because this is sensitive data.
desired_resources.append({
"apiVersion": "v1",
"kind": "Secret",
"metadata": {
"name": "mlpipeline-minio-artifact",
"namespace": namespace,
},
"data": {
"accesskey": base64.b64encode(mlpipeline_minio_access_key),
"secretkey": base64.b64encode(mlpipeline_minio_secret_key),
},
})

return {"status": desired_status, "children": desired_resources}

Expand Down
2 changes: 1 addition & 1 deletion stacks/gcp/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resources:
- ../../argo/base_v3
- ../../pipeline/minio/installs/gcp-pd
- ../../pipeline/mysql/installs/gcp-pd
- ../../pipeline/installs/generic
- ../../pipeline/installs/multi-user
- ../../metadata/v3
# This package will create a profile resource so it needs to be installed after the profiles CR
- ../../default-install/base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ spec:
key: password
name: mysql-secret-fd5gktm75t
- name: NAMESPACE_TO_WATCH
valueFrom:
fieldRef:
fieldPath: metadata.namespace
value: ""
image: gcr.io/ml-pipeline/cache-server:1.0.0-rc.3
imagePullPolicy: Always
name: server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ spec:
containers:
- env:
- name: NAMESPACE_TO_WATCH
valueFrom:
fieldRef:
fieldPath: metadata.namespace
value: ""
image: gcr.io/ml-pipeline/metadata-writer:1.0.0-rc.3
name: main
serviceAccountName: kubeflow-pipelines-metadata-writer
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ spec:
containers:
- env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
value: ""
image: gcr.io/ml-pipeline/persistenceagent:1.0.0-rc.3
imagePullPolicy: IfNotPresent
name: ml-pipeline-persistenceagent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ spec:
containers:
- env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
value: ""
image: gcr.io/ml-pipeline/scheduledworkflow:1.0.0-rc.3
imagePullPolicy: IfNotPresent
name: ml-pipeline-scheduledworkflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ spec:
spec:
containers:
- env:
- name: VIEWER_TENSORBOARD_POD_TEMPLATE_SPEC_PATH
value: /etc/config/viewer-pod-template.json
- name: DEPLOYMENT
value: KUBEFLOW
- name: ARTIFACTS_SERVICE_PROXY_NAME
value: ml-pipeline-ui-artifact
- name: ARTIFACTS_SERVICE_PROXY_PORT
value: "80"
- name: ARTIFACTS_SERVICE_PROXY_ENABLED
value: "true"
- name: ENABLE_AUTHZ
value: "true"
- name: KUBEFLOW_USERID_HEADER
valueFrom:
configMapKeyRef:
key: userid-header
name: kubeflow-config-4bkkg42k5m
- name: KUBEFLOW_USERID_PREFIX
valueFrom:
configMapKeyRef:
key: userid-prefix
name: kubeflow-config-4bkkg42k5m
- name: MINIO_NAMESPACE
valueFrom:
fieldRef:
Expand Down Expand Up @@ -61,4 +83,12 @@ spec:
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 2
volumeMounts:
- mountPath: /etc/config
name: config-volume
readOnly: true
serviceAccountName: ml-pipeline-ui
volumes:
- configMap:
name: ml-pipeline-ui-configmap
name: config-volume
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
spec:
containers:
- env:
- name: NAMESPACE
value: ""
valueFrom: null
- name: MAX_NUM_VIEWERS
value: "50"
- name: MINIO_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ spec:
spec:
containers:
- env:
- name: KUBEFLOW_USERID_HEADER
valueFrom:
configMapKeyRef:
key: userid-header
name: kubeflow-config-4bkkg42k5m
- name: KUBEFLOW_USERID_PREFIX
valueFrom:
configMapKeyRef:
key: userid-prefix
name: kubeflow-config-4bkkg42k5m
- name: POD_NAMESPACE
valueFrom:
fieldRef:
Expand Down Expand Up @@ -62,6 +72,9 @@ spec:
secretKeyRef:
key: secretkey
name: mlpipeline-minio-artifact
envFrom:
- configMapRef:
name: pipeline-api-server-config-f4t72426kt
image: gcr.io/ml-pipeline/api-server:1.0.0-rc.3
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
labels:
app: kubeflow-pipelines-profile-controller
name: kubeflow-pipelines-profile-controller
namespace: kubeflow
spec:
replicas: 1
selector:
matchLabels:
app: kubeflow-pipelines-profile-controller
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app: kubeflow-pipelines-profile-controller
spec:
containers:
- command:
- python
- /hooks/sync.py
env:
- name: MINIO_ACCESS_KEY
valueFrom:
secretKeyRef:
key: accesskey
name: mlpipeline-minio-artifact
- name: MINIO_SECRET_KEY
valueFrom:
secretKeyRef:
key: secretkey
name: mlpipeline-minio-artifact
envFrom:
- configMapRef:
name: kubeflow-pipelines-profile-controller-env-822cf46mft
image: python:3.7
name: profile-controller
ports:
- containerPort: 80
volumeMounts:
- mountPath: /hooks
name: hooks
volumes:
- configMap:
name: kubeflow-pipelines-profile-controller-code-m828g88mtm
name: hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: metacontroller.k8s.io/v1alpha1
kind: CompositeController
metadata:
labels:
app: kubeflow-pipelines-profile-controller
name: kubeflow-pipelines-profile-controller
namespace: kubeflow
spec:
childResources:
- apiVersion: v1
resource: secrets
updateStrategy:
method: OnDelete
- apiVersion: v1
resource: configmaps
updateStrategy:
method: OnDelete
- apiVersion: apps/v1
resource: deployments
updateStrategy:
method: InPlace
- apiVersion: v1
resource: services
updateStrategy:
method: InPlace
- apiVersion: networking.istio.io/v1alpha3
resource: destinationrules
updateStrategy:
method: InPlace
- apiVersion: rbac.istio.io/v1alpha1
resource: serviceroles
updateStrategy:
method: InPlace
- apiVersion: rbac.istio.io/v1alpha1
resource: servicerolebindings
updateStrategy:
method: InPlace
generateSelector: true
hooks:
sync:
webhook:
url: http://kubeflow-pipelines-profile-controller/sync
parentResource:
apiVersion: v1
resource: namespaces
resyncPeriodSeconds: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ml-pipeline-mysql
namespace: kubeflow
spec:
host: mysql.kubeflow.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ml-pipeline-ui
namespace: kubeflow
spec:
host: ml-pipeline-ui.kubeflow.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ml-pipeline-visualizationserver
namespace: kubeflow
spec:
host: ml-pipeline-visualizationserver.kubeflow.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ml-pipeline
namespace: kubeflow
spec:
host: ml-pipeline.kubeflow.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kubeflow-pipelines-cache-role
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
- update
- patch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- apiGroups:
- argoproj.io
resources:
- workflows
verbs:
- get
- list
- watch
- update
- patch
Loading