Skip to content

Commit 9b518e0

Browse files
Deploy and manage Kubernetes webhook based on pipelineStorage flag
Signed-off-by: VaniHaripriya <[email protected]>
1 parent 30c8d8a commit 9b518e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1300
-538
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: dspa-webhook-selfsigned-issuer
5+
namespace: opendatahub
6+
spec:
7+
selfSigned: {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: dspa-webhook-cert
5+
namespace: opendatahub
6+
spec:
7+
commonName: dspa-webhook-cert
8+
isCA: false
9+
dnsNames:
10+
- ds-pipelines-webhook
11+
- ds-pipelines-webhook.opendatahub
12+
- ds-pipelines-webhook.opendatahub.svc
13+
- ds-pipelines-webhook.opendatahub.svc.cluster.local
14+
issuerRef:
15+
kind: Issuer
16+
name: dspa-webhook-selfsigned-issuer
17+
group: cert-manager.io
18+
secretName: ds-pipelines-webhook-tls
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: opendatahub
4+
resources:
5+
- cert-issuer.yaml
6+
- certificate.yaml

.github/scripts/tests/collect_logs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function display_pod_info {
3030
local NAMESPACE=$1
3131
local POD_NAMES
3232

33-
POD_NAMES=$(kubectl -n "${DSPA_NS}" get pods -o custom-columns=":metadata.name")
33+
POD_NAMES=$(kubectl -n "${NAMESPACE}" get pods -o custom-columns=":metadata.name")
3434

3535
if [[ -z "${POD_NAMES}" ]]; then
3636
echo "No pods found in namespace '${NAMESPACE}'."

.github/scripts/tests/tests.sh

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ CLEAN_INFRA=false
1616
K8SAPISERVERHOST=""
1717
DSPA_NAMESPACE="test-dspa"
1818
DSPA_EXTERNAL_NAMESPACE="dspa-ext"
19+
DSPA_K8S_NAMESPACE="test-k8s-dspa"
1920
MINIO_NAMESPACE="test-minio"
2021
MARIADB_NAMESPACE="test-mariadb"
2122
PYPISERVER_NAMESPACE="test-pypiserver"
23+
CERT_MANAGER_NAMESPACE="cert-manager"
2224
DSPA_DEPLOY_WAIT_TIMEOUT="300"
2325
INTEGRATION_TESTS_DIR="${GIT_WORKSPACE}/tests"
2426
DSPA_PATH="${GIT_WORKSPACE}/tests/resources/dspa-lite.yaml"
2527
DSPA_EXTERNAL_PATH="${GIT_WORKSPACE}/tests/resources/dspa-external-lite.yaml"
28+
DSPA_K8S_PATH="${GIT_WORKSPACE}/tests/resources/dspa-k8s.yaml"
2629
CONFIG_DIR="${GIT_WORKSPACE}/config"
2730
RESOURCES_DIR_CRD="${GIT_WORKSPACE}/.github/resources"
2831
OPENDATAHUB_NAMESPACE="opendatahub"
@@ -127,6 +130,17 @@ deploy_pypi_server() {
127130
( cd "${GIT_WORKSPACE}/.github/resources/pypiserver/base" && kubectl -n $PYPISERVER_NAMESPACE apply -k . )
128131
}
129132

133+
deploy_cert_manager() {
134+
echo "---------------------------------"
135+
echo "Create Cert Manager Namespace"
136+
echo "---------------------------------"
137+
kubectl create namespace $CERT_MANAGER_NAMESPACE
138+
echo "---------------------------------"
139+
echo "Deploy Cert Manager"
140+
echo "---------------------------------"
141+
( kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml )
142+
}
143+
130144
wait_for_dspo_dependencies() {
131145
echo "---------------------------------"
132146
echo "Wait for DSPO Dependencies"
@@ -164,6 +178,13 @@ create_namespace_dspa_external_connections() {
164178
kubectl create namespace $DSPA_EXTERNAL_NAMESPACE
165179
}
166180

181+
create_dspa_k8s_namespace() {
182+
echo "---------------------------------"
183+
echo "Create DSPA Namespace with Kubernetes Pipeline Storage"
184+
echo "---------------------------------"
185+
kubectl create namespace $DSPA_K8S_NAMESPACE
186+
}
187+
167188
apply_mariadb_minio_secrets_configmaps_external_namespace() {
168189
echo "---------------------------------"
169190
echo "Apply MariaDB and Minio Secrets and Configmaps in the External Namespace"
@@ -175,7 +196,17 @@ apply_pip_server_configmap() {
175196
echo "---------------------------------"
176197
echo "Apply PIP Server ConfigMap"
177198
echo "---------------------------------"
178-
( cd "${GIT_WORKSPACE}/.github/resources/pypiserver/base" && kubectl apply -f $RESOURCES_DIR_PYPI/nginx-tls-config.yaml -n $DSPA_NAMESPACE )
199+
for ns in $DSPA_NAMESPACE $DSPA_K8S_NAMESPACE; do
200+
echo "Applying ConfigMap in namespace: $ns"
201+
( cd "${GIT_WORKSPACE}/.github/resources/pypiserver/base" && kubectl apply -f "$RESOURCES_DIR_PYPI/nginx-tls-config.yaml" -n "$ns" )
202+
done
203+
}
204+
205+
apply_webhook_certs() {
206+
echo "---------------------------------"
207+
echo "Apply Webhook Certs"
208+
echo "---------------------------------"
209+
( cd "${GIT_WORKSPACE}/.github/resources/webhook" && kubectl -n $OPENDATAHUB_NAMESPACE apply -k . )
179210
}
180211

181212
run_tests() {
@@ -192,6 +223,20 @@ run_tests_dspa_external_connections() {
192223
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=${K8SAPISERVERHOST} DSPANAMESPACE=${DSPA_EXTERNAL_NAMESPACE} DSPAPATH=${DSPA_EXTERNAL_PATH} ENDPOINT_TYPE=${ENDPOINT_TYPE} MINIONAMESPACE=${MINIO_NAMESPACE} )
193224
}
194225

226+
run_tests_dspa_k8s() {
227+
echo "---------------------------------"
228+
echo "Run tests for DSPA with Kubernetes Pipeline Storage"
229+
echo "---------------------------------"
230+
if [ "$TARGET" = "kind" ]; then
231+
echo "Detected kind target: deploying cert-manager"
232+
deploy_cert_manager
233+
echo "Waiting for Cert Manager pods to be ready"
234+
kubectl wait -n $CERT_MANAGER_NAMESPACE --timeout=90s --for=condition=Ready pods --all
235+
apply_webhook_certs
236+
fi
237+
( cd $GIT_WORKSPACE && make integrationtest K8SAPISERVERHOST=${K8SAPISERVERHOST} DSPANAMESPACE=${DSPA_K8S_NAMESPACE} DSPAPATH=${DSPA_K8S_PATH} ENDPOINT_TYPE=${ENDPOINT_TYPE})
238+
}
239+
195240
undeploy_kind_resources() {
196241
echo "---------------------------------"
197242
echo "Clean up resources created for testing on kind"
@@ -205,6 +250,7 @@ remove_namespace_created_for_rhoai() {
205250
echo "---------------------------------"
206251
kubectl delete projects $DSPA_NAMESPACE --now || true
207252
kubectl delete projects $DSPA_EXTERNAL_NAMESPACE --now || true
253+
kubectl delete projects $DSPA_K8S_NAMESPACE --now || true
208254
kubectl delete projects $MINIO_NAMESPACE --now || true
209255
kubectl delete projects $MARIADB_NAMESPACE --now || true
210256
kubectl delete projects $PYPISERVER_NAMESPACE --now || true
@@ -224,6 +270,7 @@ setup_kind_requirements() {
224270
upload_python_packages_to_pypi_server
225271
create_dspa_namespace
226272
create_namespace_dspa_external_connections
273+
create_dspa_k8s_namespace
227274
apply_mariadb_minio_secrets_configmaps_external_namespace
228275
apply_pip_server_configmap
229276
}
@@ -241,6 +288,7 @@ setup_openshift_ci_requirements() {
241288
upload_python_packages_to_pypi_server
242289
create_dspa_namespace
243290
create_namespace_dspa_external_connections
291+
create_dspa_k8s_namespace
244292
apply_mariadb_minio_secrets_configmaps_external_namespace
245293
apply_pip_server_configmap
246294
}
@@ -253,6 +301,7 @@ setup_rhoai_requirements() {
253301
upload_python_packages_to_pypi_server
254302
create_dspa_namespace
255303
create_namespace_dspa_external_connections
304+
create_dspa_k8s_namespace
256305
apply_mariadb_minio_secrets_configmaps_external_namespace
257306
apply_pip_server_configmap
258307
}
@@ -309,6 +358,16 @@ while [ "$#" -gt 0 ]; do
309358
exit 1
310359
fi
311360
;;
361+
--dspa-k8s-namespace)
362+
shift
363+
if [[ -n "$1" ]]; then
364+
DSPA_K8S_NAMESPACE="$1"
365+
shift
366+
else
367+
echo "Error: --dspa-k8s-namespace requires a value"
368+
exit 1
369+
fi
370+
;;
312371
--dspa-path)
313372
shift
314373
if [[ -n "$1" ]]; then
@@ -329,6 +388,16 @@ while [ "$#" -gt 0 ]; do
329388
exit 1
330389
fi
331390
;;
391+
--dspa-k8s-path)
392+
shift
393+
if [[ -n "$1" ]]; then
394+
DSPA_K8S_PATH="$1"
395+
shift
396+
else
397+
echo "Error: --dspa-k8s-path requires a value"
398+
exit 1
399+
fi
400+
;;
332401
--kube-config)
333402
shift
334403
if [[ -n "$1" ]]; then
@@ -377,3 +446,4 @@ fi
377446

378447
run_tests
379448
run_tests_dspa_external_connections
449+
run_tests_dspa_k8s

.github/workflows/kind-integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ jobs:
6161
run: |
6262
./collect_logs.sh --dspa-ns test-dspa --dspo-ns opendatahub
6363
./collect_logs.sh --dspa-ns dspa-ext --dspo-ns opendatahub
64+
./collect_logs.sh --dspa-ns test-k8s-dspa --dspo-ns opendatahub
6465
exit 1

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ IMG ?= quay.io/opendatahub/data-science-pipelines-operator:main
5252
ENVTEST_K8S_VERSION = 1.25.0
5353
# Namespace to deploy the operator
5454
OPERATOR_NS ?= opendatahub
55+
# Namespace where the webhook and related resources live
56+
DSPO_NAMESPACE ?= $(OPERATOR_NS)
5557
# Namespace to deploy v2 infrastructure
5658
V2INFRA_NS ?= openshift-pipelines
5759
# Namespace to deploy argo infrastructure
@@ -127,7 +129,7 @@ unittest: manifests generate fmt vet envtest ## Run tests.
127129

128130
.PHONY: functest
129131
functest: manifests generate fmt vet envtest ## Run tests.
130-
export SSL_CERT_FILE=${ROOT_DIR}/controllers/testdata/tls/ca-bundle.crt && KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... --tags=test_functional -coverprofile cover.out
132+
export SSL_CERT_FILE=${ROOT_DIR}/controllers/testdata/tls/ca-bundle.crt && export DSPO_NAMESPACE=$(DSPO_NAMESPACE) && KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... --tags=test_functional -coverprofile cover.out
131133

132134
.PHONY: integrationtest
133135
integrationtest: ## Run integration tests

api/v1/dspipeline_types.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,20 @@ type APIServer struct {
152152
// +kubebuilder:validation:Optional
153153
ArtifactSignedURLExpirySeconds *int `json:"artifactSignedURLExpirySeconds"`
154154

155-
// The Pipeline Storage type for Pipelines and Pipeline Versions. It can be
156-
// either 'database' or 'kubernetes'. Default to 'database'.
155+
// The storage for pipeline definitions (pipelines and pipeline versions). It can be
156+
// either 'database' or 'kubernetes' (Pipeline and PipelineVersion kinds). Defaults to 'database'.
157157
// +kubebuilder:default:=database
158158
// +kubebuilder:validation:Optional
159-
PipelineStorage string `json:"pipelineStorage"`
159+
// +kubebuilder:validation:Enum=database;kubernetes
160+
PipelineStorage string `json:"pipelineStorage,omitempty"`
160161

161162
// Enable/disable caching in the DSP API server. Default: true
162163
// +kubebuilder:default:=true
163164
CacheEnabled *bool `json:"cacheEnabled,omitempty"`
165+
166+
// WebhookAnnotations is a map of annotations to add to the validating and mutating webhooks.
167+
// +kubebuilder:validation:Optional
168+
WebhookAnnotations map[string]string `json:"webhookAnnotations,omitempty"`
164169
}
165170

166171
type CABundle struct {

api/v1/zz_generated.deepcopy.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/dspipeline_types.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,20 @@ type APIServer struct {
204204
// +kubebuilder:validation:Optional
205205
ArtifactSignedURLExpirySeconds *int `json:"artifactSignedURLExpirySeconds"`
206206

207-
// The Pipeline Storage type for Pipelines and Pipeline Versions. It can be
208-
// either 'database' or 'kubernetes'. Default to 'database'.
207+
// The storage for pipeline definitions (pipelines and pipeline versions). It can be
208+
// either 'database' or 'kubernetes' (Pipeline and PipelineVersion kinds). Defaults to 'database'.
209209
// +kubebuilder:default:=database
210210
// +kubebuilder:validation:Optional
211-
PipelineStorage string `json:"pipelineStorage"`
211+
// +kubebuilder:validation:Enum=database;kubernetes
212+
PipelineStorage string `json:"pipelineStorage,omitempty"`
212213

213214
// Enable/disable caching in the DSP API server. Default: true
214215
// +kubebuilder:default:=true
215216
CacheEnabled *bool `json:"cacheEnabled,omitempty"`
217+
218+
// WebhookAnnotations is a map of annotations to add to the validating and mutating webhooks.
219+
// +kubebuilder:validation:Optional
220+
WebhookAnnotations map[string]string `json:"webhookAnnotations,omitempty"`
216221
}
217222

218223
type CABundle struct {

0 commit comments

Comments
 (0)