Skip to content

Commit

Permalink
Merge pull request #607 from VaniHaripriya/RHOAIENG-3780-New
Browse files Browse the repository at this point in the history
Parameterize CABundle mountpath in dspa
  • Loading branch information
openshift-merge-bot[bot] authored Apr 8, 2024
2 parents c103f8f + bc281b4 commit a688370
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 15 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha1/dspipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ type APIServer struct {
// +kubebuilder:default:=true
// +kubebuilder:validation:Optional
AutoUpdatePipelineDefaultVersion bool `json:"autoUpdatePipelineDefaultVersion"`
// This is the path where the ca bundle will be mounted in the
// pipeline server and user executor pods
// +kubebuilder:validation:Optional
CABundleFileMountPath string `json:"caBundleFileMountPath"`
// This is the filename of the ca bundle that will be created in the
// pipeline server and user executor pods
// +kubebuilder:validation:Optional
CABundleFileName string `json:"caBundleFileName"`
}

type CABundle struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ spec:
- configMapKey
- configMapName
type: object
caBundleFileMountPath:
description: This is the path where the ca bundle will be mounted
in the pipeline server and user executor pods
type: string
caBundleFileName:
description: This is the folder where the ca bundle will be created
in the pipeline server and user executor pods
type: string
cacheImage:
description: 'Deprecated: DSP V1 only, will be removed in the
future.'
Expand Down
2 changes: 2 additions & 0 deletions config/samples/v2/dspa-all-fields/dspa_all_fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
limits:
cpu: 500m
memory: 1Gi
CABundleFileMountPath: /your/certbundle/path.crt
CABundleFileName: certbundlefilename.crt
# requires this configmap to be created beforehand,
cABundle:
configMapKey: keyname
Expand Down
18 changes: 14 additions & 4 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"context"
"encoding/base64"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/json"
"math/rand"
"strings"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/json"

"github.com/go-logr/logr"
mf "github.com/manifestival/manifestival"
dspa "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
Expand Down Expand Up @@ -553,6 +554,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
p.MLMD = dsp.Spec.MLMD.DeepCopy()
p.CustomCABundleRootMountPath = config.CustomCABundleRootMountPath
p.PiplinesCABundleMountPath = config.GetCABundleFileMountPath()
dspTrustedCAConfigMapKey := config.CustomDSPTrustedCAConfigMapKey

log := loggr.WithValues("namespace", p.Namespace).WithValues("dspa_name", p.Name)

Expand Down Expand Up @@ -646,6 +648,14 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
}
}

if p.APIServer.CABundleFileMountPath != "" {
p.CustomCABundleRootMountPath = p.APIServer.CABundleFileMountPath
}
if p.APIServer.CABundleFileName != "" {
dspTrustedCAConfigMapKey = p.APIServer.CABundleFileName
}
p.PiplinesCABundleMountPath = fmt.Sprintf("%s/%s", p.CustomCABundleRootMountPath, dspTrustedCAConfigMapKey)

// There are situations where global & user provided certs, or a provided ca trust configmap(s) have various trust bundles
// (for example in the case of "odh-trusted-ca-bundle") there is "odh-ca-bundle.crt" and "ca-bundle.crt".
// We create a separate configmap and concatenate all the certs into a single bundle, because passing a
Expand Down Expand Up @@ -673,7 +683,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
}

p.CustomCABundle = &dspa.CABundle{
ConfigMapKey: config.CustomDSPTrustedCAConfigMapKey,
ConfigMapKey: dspTrustedCAConfigMapKey,
ConfigMapName: fmt.Sprintf("%s-%s", config.CustomDSPTrustedCAConfigMapNamePrefix, p.Name),
}

Expand Down Expand Up @@ -712,7 +722,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
// We need to update the default SSL_CERT_DIR to include
// dsp custom cert path, used by DSP Api Server
var certDirectories = []string{
config.CustomCABundleRootMountPath,
p.CustomCABundleRootMountPath,
"/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139
"/etc/pki/tls/certs", // Fedora/RHEL
}
Expand Down
4 changes: 4 additions & 0 deletions controllers/testdata/declarative/case_6/deploy/03_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# When a user provides a cABundle in the DSPA, it is also included in the concatenated dsp custom ca cert configmap
# When external db is used the server config created for api server uses tls=true
# MLMD grpc server mounts the dspa cert and passes it into grpc server
# When a user provides a caBundleFileMountPath, it will be used to mount the ca bundle
# When a user provides ca bundle configmapkey, it will be used instead of default one
apiVersion: datasciencepipelinesapplications.opendatahub.io/v1alpha1
kind: DataSciencePipelinesApplication
metadata:
Expand All @@ -12,6 +14,8 @@ spec:
apiServer:
deploy: true
enableSamplePipeline: false
caBundleFileMountPath: /dspa/custom-certs
caBundleFileName: user-ca-bundle.crt
cABundle:
configMapKey: user-ca-bundle.crt
configMapName: user-ca-bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ spec:
- name: ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_NAME
value: dsp-trusted-ca-testdsp6
- name: ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_KEY
value: dsp-ca.crt
value: user-ca-bundle.crt
- name: ARTIFACT_COPY_STEP_CABUNDLE_MOUNTPATH
value: /dsp-custom-certs
value: /dspa/custom-certs
- name: SSL_CERT_DIR
value: "/dsp-custom-certs:/etc/ssl/certs:/etc/pki/tls/certs"
value: "/dspa/custom-certs:/etc/ssl/certs:/etc/pki/tls/certs"
- name: AUTO_UPDATE_PIPELINE_DEFAULT_VERSION
value: "true"
- name: DBCONFIG_CONMAXLIFETIMESEC
Expand Down Expand Up @@ -158,7 +158,7 @@ spec:
mountPath: /config/config.json
subPath: config.json
- name: ca-bundle
mountPath: /dsp-custom-certs
mountPath: /dspa/custom-certs
- name: oauth-proxy
args:
- --https-address=:8443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
aws_cp() {
aws s3 --endpoint http://minio-testdsp6.default.svc.cluster.local:9000 --ca-bundle /dsp-custom-certs/dsp-ca.crt cp $1.tgz s3://mlpipeline/artifacts/$PIPELINERUN/$PIPELINETASK/$1.tgz
aws s3 --endpoint http://minio-testdsp6.default.svc.cluster.local:9000 --ca-bundle /dspa/custom-certs/user-ca-bundle.crt cp $1.tgz s3://mlpipeline/artifacts/$PIPELINERUN/$PIPELINETASK/$1.tgz
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
metadata:
name: dsp-trusted-ca-testdsp6
data:
dsp-ca.crt: |
user-ca-bundle.crt: |
-----BEGIN CERTIFICATE-----
MIIFLTCCAxWgAwIBAgIUIvY4jV0212P/ddjuCZhcUyJfoocwDQYJKoZIhvcNAQEL
BQAwJjELMAkGA1UEBhMCWFgxFzAVBgNVBAMMDnJoLWRzcC1kZXZzLmlvMB4XDTI0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
- --mysql_config_user=$(DBCONFIG_USER)
- --mysql_config_password=$(DBCONFIG_PASSWORD)
- --enable_database_upgrade=true
- --mysql_config_sslrootcert=/dsp-custom-certs/dsp-ca.crt
- --mysql_config_sslrootcert=/dspa/custom-certs/user-ca-bundle.crt
command:
- /bin/metadata_store_server
env:
Expand Down Expand Up @@ -73,7 +73,7 @@ spec:
cpu: 100m
memory: 256Mi
volumeMounts:
- mountPath: /dsp-custom-certs
- mountPath: /dspa/custom-certs
name: ca-bundle
serviceAccountName: ds-pipeline-metadata-grpc-testdsp6
volumes:
Expand Down
1 change: 1 addition & 0 deletions controllers/testdata/declarative/case_8/deploy/02_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
apiServer:
deploy: true
enableSamplePipeline: false
caBundleFileName: testcabundleconfigmapkey8.crt
cABundle:
configMapName: testcabundleconfigmap8
configMapKey: testcabundleconfigmapkey8.crt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
- name: ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_NAME
value: dsp-trusted-ca-testdsp8
- name: ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_KEY
value: dsp-ca.crt
value: testcabundleconfigmapkey8.crt
- name: ARTIFACT_COPY_STEP_CABUNDLE_MOUNTPATH
value: /dsp-custom-certs
- name: SSL_CERT_DIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
aws_cp() {
aws s3 --endpoint http://minio-testdsp8.default.svc.cluster.local:9000 --ca-bundle /dsp-custom-certs/dsp-ca.crt cp $1.tgz s3://mlpipeline/artifacts/$PIPELINERUN/$PIPELINETASK/$1.tgz
aws s3 --endpoint http://minio-testdsp8.default.svc.cluster.local:9000 --ca-bundle /dsp-custom-certs/testcabundleconfigmapkey8.crt cp $1.tgz s3://mlpipeline/artifacts/$PIPELINERUN/$PIPELINETASK/$1.tgz
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
metadata:
name: dsp-trusted-ca-testdsp8
data:
dsp-ca.crt: |-
testcabundleconfigmapkey8.crt: |-
-----BEGIN CERTIFICATE-----
MIIFLTCCAxWgAwIBAgIUIvY4jV0212P/ddjuCZhcUyJfoocwDQYJKoZIhvcNAQEL
BQAwJjELMAkGA1UEBhMCWFgxFzAVBgNVBAMMDnJoLWRzcC1kZXZzLmlvMB4XDTI0
Expand Down

0 comments on commit a688370

Please sign in to comment.