Skip to content

Commit

Permalink
feat: allow custom server config via dspa
Browse files Browse the repository at this point in the history
Signed-off-by: Humair Khan <HumairAK@users.noreply.github.com>
  • Loading branch information
HumairAK committed Mar 15, 2024
1 parent b9390ef commit 3f01f4c
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 40 deletions.
10 changes: 7 additions & 3 deletions api/v1alpha1/dspipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type APIServer struct {
ArtifactImage string `json:"artifactImage,omitempty"`
CacheImage string `json:"cacheImage,omitempty"`
// Image used for internal artifact passing handling within Tekton taskruns. This field specifies the image used in the 'move-all-results-to-tekton-home' step.
MoveResultsImage string `json:"moveResultsImage,omitempty"`
*ArtifactScriptConfigMap `json:"artifactScriptConfigMap,omitempty"`
MoveResultsImage string `json:"moveResultsImage,omitempty"`
ArtifactScriptConfigMap *ScriptConfigMap `json:"artifactScriptConfigMap,omitempty"`
// Inject the archive step script. Default: true
// +kubebuilder:default:=true
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -118,6 +118,10 @@ type APIServer struct {
// server pod to trust this connection. CA Bundle should be provided
// as values within configmaps, mapped to keys.
CABundle *CABundle `json:"cABundle,omitempty"`

// CustomServerConfig is a custom config file that you can provide
// for the api server to use instead.
CustomServerConfig *ScriptConfigMap `json:"customServerConfigMap,omitempty"`
}

type CABundle struct {
Expand All @@ -129,7 +133,7 @@ type CABundle struct {
ConfigMapKey string `json:"configMapKey"`
}

type ArtifactScriptConfigMap struct {
type ScriptConfigMap struct {
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
}
Expand Down
37 changes: 21 additions & 16 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ spec:
default: true
description: 'Default: true'
type: boolean
customServerConfigMap:
description: CustomServerConfig is a custom config file that you
can provide for the api server to use instead.
properties:
key:
type: string
name:
type: string
type: object
dbConfigConMaxLifetimeSec:
default: 120
description: 'Default: 120'
Expand Down
4 changes: 2 additions & 2 deletions config/internal/apiserver/default/deployment.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ spec:
volumeMounts:
- name: server-config
mountPath: /config/config.json
subPath: config.json
subPath: {{ .APIServer.CustomServerConfig.Key }}
{{ if or .APIServer.EnableSamplePipeline .CustomCABundle }}
{{ if .APIServer.EnableSamplePipeline }}
- name: sample-config
Expand Down Expand Up @@ -289,7 +289,7 @@ spec:
secretName: ds-pipelines-proxy-tls-{{.Name}}
- name: server-config
configMap:
name: pipeline-server-config-{{.Name}}
name: {{ .APIServer.CustomServerConfig.Name }}
{{ if .CustomCABundle }}
- name: ca-bundle
configMap:
Expand Down
10 changes: 5 additions & 5 deletions config/internal/apiserver/default/server-config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pipeline-server-config-{{.Name}}
namespace: {{.Namespace}}
labels:
app: {{.APIServerDefaultResourceName}}
component: data-science-pipelines
name: ds-pipeline-server-config-{{.Name}}
namespace: {{.Namespace}}
labels:
app: {{.APIServerDefaultResourceName}}
component: data-science-pipelines
data:
config.json: |
{{ if eq .DSPVersion "v2" }}
Expand Down
2 changes: 1 addition & 1 deletion config/overlays/make-deploy/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ patchesStrategicMerge:
images:
- name: controller
newName: quay.io/opendatahub/data-science-pipelines-operator
newTag: main
newTag: pr-605
5 changes: 4 additions & 1 deletion controllers/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const (
MLPipelineUIConfigMapPrefix = "ds-pipeline-ui-configmap-"
ArtifactScriptConfigMapNamePrefix = "ds-pipeline-artifact-script-"
ArtifactScriptConfigMapKey = "artifact_script"
DSPServicePrefix = "ds-pipeline"

CustomServerConfigMapNamePrefix = "ds-pipeline-server-config-"
CustomServerConfigMapNameKey = "config.json"
DSPServicePrefix = "ds-pipeline"

DefaultDBSecretNamePrefix = "ds-pipeline-db-"
DefaultDBSecretKey = "password"
Expand Down
9 changes: 8 additions & 1 deletion controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,19 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
setResourcesDefault(config.APIServerResourceRequirements, &p.APIServer.Resources)

if p.APIServer.ArtifactScriptConfigMap == nil {
p.APIServer.ArtifactScriptConfigMap = &dspa.ArtifactScriptConfigMap{
p.APIServer.ArtifactScriptConfigMap = &dspa.ScriptConfigMap{
Name: config.ArtifactScriptConfigMapNamePrefix + dsp.Name,
Key: config.ArtifactScriptConfigMapKey,
}
}

if p.APIServer.CustomServerConfig == nil {
p.APIServer.CustomServerConfig = &dspa.ScriptConfigMap{
Name: config.CustomServerConfigMapNamePrefix + dsp.Name,
Key: config.CustomServerConfigMapNameKey,
}
}

// Check for cert bundle provided by the platform instead of by the DSPA user
// If it exists, include this cert for tls verifications
globalCABundleCFGMapName := config.GlobalODHCaBundleConfigMapName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ spec:
- name: server-config
configMap:
defaultMode: 420
name: pipeline-server-config-testdsp0
name: ds-pipeline-server-config-testdsp0
- configMap:
defaultMode: 420
name: sample-config-testdsp0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pipeline-server-config-testdsp0
name: ds-pipeline-server-config-testdsp0
namespace: default
labels:
app: ds-pipeline-testdsp0
Expand Down
5 changes: 5 additions & 0 deletions controllers/testdata/declarative/case_2/deploy/cr.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Test:
# Various DSPA fields, resources, apiserver fields, custom script
apiVersion: datasciencepipelinesapplications.opendatahub.io/v1alpha1
kind: DataSciencePipelinesApplication
metadata:
Expand All @@ -22,6 +24,9 @@ spec:
dbConfigConMaxLifetimeSec: 125
collectMetrics: true
autoUpdatePipelineDefaultVersion: true
customServerConfigMap:
name: testserverconfigmapdspa2
key: testserverconfigmapkeydspa2
resources:
requests:
cpu: "1231m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ spec:
volumeMounts:
- name: server-config
mountPath: /config/config.json
subPath: config.json
subPath: testserverconfigmapkeydspa2
- mountPath: /config/sample_config.json
name: sample-config
subPath: sample_config.json
Expand Down Expand Up @@ -220,7 +220,7 @@ spec:
- name: server-config
configMap:
defaultMode: 420
name: pipeline-server-config-testdsp2
name: testserverconfigmapdspa2
- configMap:
defaultMode: 420
name: sample-config-testdsp2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,6 @@ spec:
defaultMode: 420
- name: server-config
configMap:
name: pipeline-server-config-testdsp3
name: ds-pipeline-server-config-testdsp3
defaultMode: 420
serviceAccountName: ds-pipeline-testdsp3
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,5 @@ spec:
- name: server-config
configMap:
defaultMode: 420
name: pipeline-server-config-testdsp4
name: ds-pipeline-server-config-testdsp4
serviceAccountName: ds-pipeline-testdsp4
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,6 @@ spec:
defaultMode: 420
- configMap:
defaultMode: 420
name: pipeline-server-config-testdsp5
name: ds-pipeline-server-config-testdsp5
name: server-config
serviceAccountName: ds-pipeline-testdsp5
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ spec:
defaultMode: 420
- name: server-config
configMap:
name: pipeline-server-config-testdsp6
name: ds-pipeline-server-config-testdsp6
defaultMode: 420
- name: ca-bundle
configMap:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pipeline-server-config-testdsp6
name: ds-pipeline-server-config-testdsp6
namespace: default
labels:
app: ds-pipeline-testdsp6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ spec:
- name: server-config
configMap:
defaultMode: 420
name: pipeline-server-config-testdsp7
name: ds-pipeline-server-config-testdsp7
- configMap:
defaultMode: 420
name: sample-config-testdsp7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ spec:
defaultMode: 420
- name: server-config
configMap:
name: pipeline-server-config-testdsp8
name: ds-pipeline-server-config-testdsp8
defaultMode: 420
- name: ca-bundle
configMap:
Expand Down

0 comments on commit 3f01f4c

Please sign in to comment.