Skip to content

feat(backend): Add the ability to set a proxy for accessing external resources #11771

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 1 commit into from
Apr 10, 2025
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
24 changes: 22 additions & 2 deletions .github/actions/kfp-cluster/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
k8s_version:
description: "The Kubernetes version to use for the Kind cluster"
required: true
proxy:
description: "If KFP should be deployed with proxy configuration"
required: false
default: false

runs:
using: "composite"
Expand All @@ -17,10 +21,26 @@ runs:
version: v0.25.0
node_image: kindest/node:${{ inputs.k8s_version }}

- name: Deploy Squid
id: deploy-squid
if: ${{ (inputs.proxy == 'true' )}}
shell: bash
run: ./.github/resources/squid/deploy-squid.sh

- name: Build images
shell: bash
run: ./.github/resources/scripts/build-images.sh
run: |
if [ "${{ inputs.proxy }}" = "true" ]; then
./.github/resources/scripts/build-images.sh --proxy
else
./.github/resources/scripts/build-images.sh
fi

- name: Deploy KFP
shell: bash
run: ./.github/resources/scripts/deploy-kfp.sh
run: |
if [ "${{ inputs.proxy }}" = "true" ]; then
./.github/resources/scripts/deploy-kfp.sh --proxy
else
./.github/resources/scripts/deploy-kfp.sh
fi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../../../manifests/kustomize/env/platform-agnostic
- ../../../../../../manifests/kustomize/env/platform-agnostic

images:
- name: ghcr.io/kubeflow/kfp-api-server
Expand All @@ -16,4 +16,4 @@ images:
newTag: latest

patchesStrategicMerge:
- overlays/apiserver-env.yaml
- apiserver-env.yaml
11 changes: 11 additions & 0 deletions .github/resources/manifests/argo/overlays/proxy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../no-proxy

patches:
- path: proxy-env.yaml
target:
kind: Deployment
name: ml-pipeline
16 changes: 16 additions & 0 deletions .github/resources/manifests/argo/overlays/proxy/proxy-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml-pipeline
spec:
template:
spec:
containers:
- name: ml-pipeline-api-server
env:
- name: HTTP_PROXY
value: "http://squid.squid.svc.cluster.local:3128"
- name: HTTPS_PROXY
value: "http://squid.squid.svc.cluster.local:3128"
- name: NO_PROXY
value: "localhost,127.0.0.1,.svc.cluster.local,kubernetes.default.svc,metadata-grpc-service,0,1,2,3,4,5,6,7,8,9"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../../../manifests/kustomize/env/cert-manager/platform-agnostic-k8s-native
- ../../../../../../manifests/kustomize/env/cert-manager/platform-agnostic-k8s-native

images:
- name: ghcr.io/kubeflow/kfp-api-server
Expand All @@ -16,4 +16,4 @@ images:
newTag: latest

patchesStrategicMerge:
- overlays/apiserver-env.yaml
- apiserver-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../no-proxy

patches:
- path: proxy-env.yaml
target:
kind: Deployment
name: ml-pipeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml-pipeline
spec:
template:
spec:
containers:
- name: ml-pipeline-api-server
env:
- name: HTTP_PROXY
value: "http://squid.squid.svc.cluster.local:3128"
- name: HTTPS_PROXY
value: "http://squid.squid.svc.cluster.local:3128"
- name: NO_PROXY
value: "localhost,127.0.0.1,.svc.cluster.local,kubernetes.default.svc,metadata-grpc-service,0,1,2,3,4,5,6,7,8,9"
17 changes: 17 additions & 0 deletions .github/resources/scripts/deploy-kfp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ C_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$C_DIR" ]]; then C_DIR="$PWD"; fi
source "${C_DIR}/helper-functions.sh"

USE_PROXY=false

while getopts ":p-:" OPT; do
case $OPT in
-) [ "$OPTARG" = "proxy" ] && USE_PROXY=true || { echo "Unknown option --$OPTARG"; exit 1; };;
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;;
esac
done

shift $((OPTIND-1))

kubectl apply -k "manifests/kustomize/cluster-scoped-resources/"
kubectl apply -k "manifests/kustomize/base/crds"
kubectl wait crd/applications.app.k8s.io --for condition=established --timeout=60s || EXIT_CODE=$?
Expand All @@ -48,6 +59,12 @@ if [[ "$PIPELINE_STORE" == "kubernetes" ]]; then
TEST_MANIFESTS=".github/resources/manifests/kubernetes-native"
fi

if $USE_PROXY; then
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/proxy"
else
TEST_MANIFESTS="${TEST_MANIFESTS}/overlays/no-proxy"
fi

kubectl apply -k "${TEST_MANIFESTS}" || EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]
then
Expand Down
10 changes: 10 additions & 0 deletions .github/resources/squid/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM quay.io/fedora/fedora:41

RUN dnf install -y squid && \
dnf clean all

COPY squid.conf /etc/squid/squid.conf

EXPOSE 3128

CMD ["squid", "-N", "-d", "1"]
16 changes: 16 additions & 0 deletions .github/resources/squid/deploy-squid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

C_DIR="${BASH_SOURCE%/*}"
NAMESPACE="squid"

docker build --progress=plain -t "registry.domain.local/squid:test" -f ${C_DIR}/Containerfile ${C_DIR}
kind --name kfp load docker-image registry.domain.local/squid:test

kubectl apply -k ${C_DIR}/manifests

if ! kubectl -n ${NAMESPACE} wait --for=condition=available deployment/squid --timeout=60s; then
echo "Timeout occurred while waiting for the Squid deployment."
exit 1
fi
30 changes: 30 additions & 0 deletions .github/resources/squid/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: squid
namespace: squid
spec:
replicas: 1
selector:
matchLabels:
app: squid
template:
metadata:
labels:
app: squid
spec:
containers:
- name: squid
image: registry.domain.local/squid:test
ports:
- containerPort: 3128
volumeMounts:
- name: squid-cache
mountPath: /var/cache/squid
- name: squid-log
mountPath: /var/log/squid
volumes:
- name: squid-cache
emptyDir: { }
- name: squid-log
emptyDir: { }
4 changes: 4 additions & 0 deletions .github/resources/squid/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- deployment.yaml
- service.yaml
- namespace.yaml
4 changes: 4 additions & 0 deletions .github/resources/squid/manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: squid
12 changes: 12 additions & 0 deletions .github/resources/squid/manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: squid
namespace: squid
spec:
selector:
app: squid
ports:
- protocol: TCP
port: 3128
targetPort: 3128
8 changes: 8 additions & 0 deletions .github/resources/squid/squid.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Define an access control list (ACL) for all source IP addresses
acl all src all

# Allow HTTP access from all sources
http_access allow all

# Define the port Squid will listen on
http_port 3128
50 changes: 50 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,56 @@ jobs:
name: kfp-api-integration-tests-v2-artifacts-k8s-${{ matrix.k8s_version }}
path: /tmp/tmp*/*

api-integration-tests-v2-with-proxy:
runs-on: ubuntu-latest
strategy:
matrix:
k8s_version: [ "v1.31.0" ]
name: API integration tests v2 with proxy - K8s ${{ matrix.k8s_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Create KFP cluster
id: create-kfp-cluster
uses: ./.github/actions/kfp-cluster
with:
k8s_version: ${{ matrix.k8s_version }}
proxy: 'true'
continue-on-error: true

- name: Forward API port
id: forward-api-port
if: ${{ (steps.create-kfp-cluster.outcome == 'success' )}}
run: ./.github/resources/scripts/forward-port.sh "kubeflow" "ml-pipeline" 8888 8888
continue-on-error: true

- name: API integration tests v2
id: tests
if: ${{ (steps.forward-api-port.outcome == 'success' )}}
working-directory: ./backend/test/v2/integration
run: go test -v ./... -namespace kubeflow -args -runIntegrationTests=true -useProxy=true
continue-on-error: true

- name: Collect failed logs
if: ${{ (steps.create-kfp-cluster.outcome != 'success' ) || ( steps.forward-api-port.outcome != 'success' ) || ( steps.tests.outcome != 'success' )}}
run: |
./.github/resources/scripts/collect-logs.sh --ns squid --output /tmp/tmp_squid_pod_log.txt
./.github/resources/scripts/collect-logs.sh --ns kubeflow --output /tmp/tmp_pod_log.txt
exit 1

- name: Collect test results
if: always()
uses: actions/upload-artifact@v4
with:
name: kfp-api-integration-tests-v2-with-proxy-artifacts-k8s-${{ matrix.k8s_version }}
path: /tmp/tmp*/*

frontend-integration-test:
runs-on: ubuntu-latest
strategy:
Expand Down
Loading
Loading