Skip to content

Commit c8b071a

Browse files
committed
Implement e2e TLS test.
Signed-off-by: agoins <[email protected]>
1 parent 426e211 commit c8b071a

40 files changed

+232
-116
lines changed

.github/actions/kfp-cluster/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ runs:
5959
ARGS="${ARGS} --cache-disabled"
6060
elif [ "${{inputs.pipeline_store }}" = "kubernetes" ]; then
6161
ARGS="${ARGS} --deploy-k8s-native"
62-
elif [ "${{inputs.pod_to_pod_tls_enabled }}" = "false"]; then
63-
ARGS="${ARGS} --tls-enabled
62+
elif [ "${{inputs.pod_to_pod_tls_enabled }}" = "true" ]; then
63+
ARGS="${ARGS} --tls-enabled"
6464
fi
6565
6666
./.github/resources/scripts/deploy-kfp.sh $ARGS
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
apiVersion: v1
2-
kind: Pod
1+
apiVersion: apps/v1
2+
kind: Deployment
33
metadata:
4-
name: title
5-
labels:
6-
role: title
4+
name: ml-pipeline
75
spec:
8-
containers:
9-
- name: title
10-
image: nginx
11-
imagePullPolicy: IfNotPresent
12-
ports:
13-
- name: title
14-
containerPort: 80
15-
protocol: TCP
16-
restartPolicy: Always
17-
6+
template:
7+
spec:
8+
containers:
9+
- name: ml-pipeline-api-server
10+
env:
11+
- name: V2_DRIVER_IMAGE
12+
value: kind-registry:5000/driver
13+
- name: V2_LAUNCHER_IMAGE
14+
value: kind-registry:5000/launcher
15+
- name: LOG_LEVEL
16+
value: "debug"
17+
- name: TLS_ENABLED
18+
value: "true"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- ../../../../../../manifests/kustomize/env/cert-manager/platform-agnostic-multi-user-tls
6+
patches:
7+
- path: apiserver-env.yaml
8+
target:
9+
kind: Deployment
10+
name: ml-pipeline

.github/resources/scripts/deploy-kfp.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST_MANIFESTS=".github/resources/manifests/argo"
2828
PIPELINES_STORE="database"
2929
USE_PROXY=false
3030
CACHE_DISABLED=false
31-
POD_TO_POD_TLS_ENABLED=true
31+
POD_TO_POD_TLS_ENABLED=false
3232

3333
# Loop over script arguments passed. This uses a single switch-case
3434
# block with default value in case we want to make alternative deployments
@@ -47,10 +47,14 @@ while [ "$#" -gt 0 ]; do
4747
CACHE_DISABLED=true
4848
shift
4949
;;
50+
--tls-enabled)
51+
POD_TO_POD_TLS_ENABLED=true
52+
shift
53+
;;
5054
esac
5155
done
5256

53-
if [ "${USE_PROXY}" == "true" && "${PIPELINES_STORE}" == "kubernetes" ]; then
57+
if [ "${USE_PROXY}" == "true" ] && [ "${PIPELINES_STORE}" == "kubernetes" ]; then
5458
echo "ERROR: Kubernetes Pipeline store cannot be deployed with proxy support."
5559
exit 1
5660
fi
@@ -81,7 +85,7 @@ elif $USE_PROXY; then
8185
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/proxy"
8286
elif [ "${PIPELINES_STORE}" == "kubernetes" ]; then
8387
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/kubernetes-native"
84-
if $POD_TO_POD_TLS_ENABLED; then
88+
elif $POD_TO_POD_TLS_ENABLED; then
8589
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/tls-enabled"
8690
else
8791
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/no-proxy"

.github/workflows/e2e-test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,63 @@ jobs:
293293
name: kfp-api-integration-tests-v2-with-proxy-artifacts-k8s-${{ matrix.k8s_version }}
294294
path: /tmp/tmp*/*
295295

296+
api-integration-tests-v2-with-tls-enabled:
297+
runs-on: ubuntu-latest
298+
strategy:
299+
matrix:
300+
k8s_version: [ "v1.31.0" ]
301+
name: API integration tests v2 with TLS enabled - K8s ${{ matrix.k8s_version }}
302+
steps:
303+
- name: Checkout code
304+
uses: actions/checkout@v4
305+
306+
- name: Set up Python
307+
uses: actions/setup-python@v4
308+
with:
309+
python-version: 3.9
310+
311+
- name: Create KFP cluster
312+
id: create-kfp-cluster
313+
uses: ./.github/actions/kfp-cluster
314+
with:
315+
k8s_version: ${{ matrix.k8s_version }}
316+
pod_to_pod_tls_enabled: 'true'
317+
continue-on-error: true
318+
319+
- name: Forward API port
320+
id: forward-api-port
321+
if: ${{ steps.create-kfp-cluster.outcome == 'success' }}
322+
run: ./.github/resources/scripts/forward-port.sh "kubeflow" "ml-pipeline" 8888 8888
323+
continue-on-error: true
324+
325+
- name: Forward MLMD port
326+
id: forward-mlmd-port
327+
if: ${{ steps.forward-api-port.outcome == 'success' }}
328+
run: kubectl -n kubeflow port-forward svc/metadata-grpc-service 8080:8080 &
329+
continue-on-error: true
330+
331+
- name: API integration tests v2
332+
id: tests
333+
if: ${{ steps.forward-mlmd-port.outcome == 'success' }}
334+
working-directory: ./backend/test/v2/integration
335+
run: go test -v ./... -namespace kubeflow -args -runIntegrationTests=true -tls_enabled=true
336+
env:
337+
PULL_NUMBER: ${{ github.event.pull_request.number }}
338+
continue-on-error: true
339+
340+
- name: Collect failed logs
341+
if: ${{ steps.create-kfp-cluster.outcome != 'success' || steps.forward-api-port.outcome != 'success' || steps.tests.outcome != 'success' }}
342+
run: |
343+
./.github/resources/scripts/collect-logs.sh --ns kubeflow --output /tmp/tmp_pod_log.txt
344+
exit 1
345+
346+
- name: Collect test results
347+
if: always()
348+
uses: actions/upload-artifact@v4
349+
with:
350+
name: kfp-api-integration-tests-v2-with-tls-enabled-artifacts-k8s-${{ matrix.k8s_version }}
351+
path: /tmp/tmp*/*
352+
296353
api-integration-tests-v2-with-cache-disabled:
297354
runs-on: ubuntu-latest
298355
strategy:

backend/src/apiserver/config/proxy/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
HttpsProxyEnv = "HTTPS_PROXY"
2525
NoProxyEnv = "NO_PROXY"
2626
defaultNoProxyValue = "localhost,127.0.0.1,.svc.cluster.local,kubernetes.default.svc,metadata-grpc-service,0,1,2,3,4,5,6,7,8,9"
27+
tlsEnabled = "TLS_ENABLED"
2728
)
2829

2930
type Config interface {

backend/src/v2/cacheutils/cache_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ func TestGenerateCacheKey(t *testing.T) {
135135
wantErr: false,
136136
},
137137
}
138-
//todo: add case fpr tlsEnabled testing? Also, should tlsEnabled be set to false here?
139138
cacheClient, err := NewClient(false, false)
140139
require.NoError(t, err)
141140
for _, test := range tests {
@@ -258,8 +257,6 @@ func TestGenerateFingerPrint(t *testing.T) {
258257
fingerPrint: "0a4cc1f15cdfad5170e1358518f7128c5278500a670db1b9a3f3d83b93db396e",
259258
},
260259
}
261-
//todo: add case fpr tlsEnabled testing? Also, should tlsEnabled be set to false here?
262-
//TODO: fixed
263260
cacheClient, err := NewClient(false, false)
264261
require.NoError(t, err)
265262
for _, test := range tests {

backend/src/v2/client_manager/client_manager.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ type ClientManager struct {
2626
}
2727

2828
type Options struct {
29-
MLMDServerAddress string
30-
MLMDServerPort string
31-
CacheDisabled bool
29+
MLMDServerAddress string
30+
MLMDServerPort string
31+
CacheDisabled bool
32+
MLPipelineTLSEnabled bool
3233
}
3334

3435
// NewClientManager creates and Init a new instance of ClientManager.
@@ -63,7 +64,7 @@ func (cm *ClientManager) init(opts *Options) error {
6364
if err != nil {
6465
return err
6566
}
66-
cacheClient, err := initCacheClient(opts.CacheDisabled)
67+
cacheClient, err := initCacheClient(opts.CacheDisabled, opts.MLPipelineTLSEnabled)
6768
if err != nil {
6869
return err
6970
}
@@ -89,7 +90,6 @@ func initMetadataClient(address string, port string) (metadata.ClientInterface,
8990
return metadata.NewClient(address, port)
9091
}
9192

92-
// todo: should this be auto-set to false
93-
func initCacheClient(cacheDisabled bool) (cacheutils.Client, error) {
94-
return cacheutils.NewClient(cacheDisabled, false)
93+
func initCacheClient(cacheDisabled bool, mlPipelineServiceTLSEnabled bool) (cacheutils.Client, error) {
94+
return cacheutils.NewClient(cacheDisabled, mlPipelineServiceTLSEnabled)
9595
}

backend/src/v2/cmd/driver/main.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787
publishLogs = flag.String("publish_logs", "true", "Whether to publish component logs to the object store")
8888
cacheDisabledFlag = flag.Bool("cache_disabled", false, "Disable cache globally.")
8989

90-
mlPipelineServiceTLSEnabledStr = flag.String("mlPipelineServiceTLSEnabled", "false", "Set to 'true' if mlpipeline api server serves over TLS (default: 'false').")
90+
mlPipelineServiceTLSEnabledStr = flag.String("ml_pipeline_service_tls_enabled", "false", "Set to 'true' if mlpipeline api server serves over TLS (default: 'false').")
9191
)
9292

9393
// func RootDAG(pipelineName string, runID string, component *pipelinespec.ComponentSpec, task *pipelinespec.PipelineTaskSpec, mlmd *metadata.Client) (*Execution, error) {
@@ -191,20 +191,20 @@ func drive() (err error) {
191191
return err
192192
}
193193
options := driver.Options{
194-
PipelineName: *pipelineName,
195-
RunID: *runID,
196-
RunName: *runName,
197-
RunDisplayName: *runDisplayName,
198-
Namespace: namespace,
199-
Component: componentSpec,
200-
Task: taskSpec,
201-
DAGExecutionID: *dagExecutionID,
202-
IterationIndex: *iterationIndex,
203-
PipelineLogLevel: *logLevel,
204-
PublishLogs: *publishLogs,
205-
CacheDisabled: *cacheDisabledFlag,
206-
DriverType: *driverType,
207-
TaskName: *taskName,
194+
PipelineName: *pipelineName,
195+
RunID: *runID,
196+
RunName: *runName,
197+
RunDisplayName: *runDisplayName,
198+
Namespace: namespace,
199+
Component: componentSpec,
200+
Task: taskSpec,
201+
DAGExecutionID: *dagExecutionID,
202+
IterationIndex: *iterationIndex,
203+
PipelineLogLevel: *logLevel,
204+
PublishLogs: *publishLogs,
205+
CacheDisabled: *cacheDisabledFlag,
206+
DriverType: *driverType,
207+
TaskName: *taskName,
208208
MLPipelineTLSEnabled: mlPipelineServiceTLSEnabled,
209209
}
210210
var execution *driver.Execution

backend/src/v2/cmd/launcher-v2/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var (
4646
logLevel = flag.String("log_level", "1", "The verbosity level to log.")
4747
publishLogs = flag.String("publish_logs", "true", "Whether to publish component logs to the object store")
4848
cacheDisabledFlag = flag.Bool("cache_disabled", false, "Disable cache globally.")
49-
mlPipelineServiceTLSEnabledStr = flag.String("mlPipelineServiceTLSEnabled", "false", "Set to 'true' if mlpipeline api server serves over TLS (default: 'false').")
49+
mlPipelineServiceTLSEnabledStr = flag.String("ml_pipeline_service_tls_enabled", "false", "Set to 'true' if mlpipeline api server serves over TLS (default: 'false').")
5050
)
5151

5252
func main() {
@@ -111,9 +111,10 @@ func run() error {
111111
return nil
112112
case "container":
113113
clientOptions := &client_manager.Options{
114-
MLMDServerAddress: launcherV2Opts.MLMDServerAddress,
115-
MLMDServerPort: launcherV2Opts.MLMDServerPort,
116-
CacheDisabled: launcherV2Opts.CacheDisabled,
114+
MLMDServerAddress: launcherV2Opts.MLMDServerAddress,
115+
MLMDServerPort: launcherV2Opts.MLMDServerPort,
116+
CacheDisabled: launcherV2Opts.CacheDisabled,
117+
MLPipelineTLSEnabled: launcherV2Opts.MLPipelineTLSEnabled,
117118
}
118119
clientManager, err := client_manager.NewClientManager(clientOptions)
119120
if err != nil {

0 commit comments

Comments
 (0)