Skip to content

Commit

Permalink
Merge pull request #605 from HumairAK/always_enable_server_config
Browse files Browse the repository at this point in the history
feat: always enable server config and make it customizable
  • Loading branch information
HumairAK authored Mar 15, 2024
2 parents 07b53bf + 46306ea commit ad47dda
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 36 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
6 changes: 3 additions & 3 deletions config/internal/apiserver/default/deployment.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ spec:
memory: {{.APIServer.Resources.Limits.Memory}}
{{ end }}
{{ end }}
{{ if or .APIServer.EnableSamplePipeline .CustomCABundle }}
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
mountPath: /config/sample_config.json
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
2 changes: 1 addition & 1 deletion config/internal/apiserver/default/server-config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: pipeline-server-config-{{.Name}}
name: ds-pipeline-server-config-{{.Name}}
namespace: {{.Namespace}}
labels:
app: {{.APIServerDefaultResourceName}}
Expand Down
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 @@ -148,6 +148,10 @@ spec:
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 2
volumeMounts:
- name: server-config
mountPath: /config/config.json
subPath: config.json
resources:
requests:
cpu: 250m
Expand Down Expand Up @@ -209,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 @@ -114,6 +114,10 @@ spec:
imagePullPolicy: Always
name: ds-pipeline-api-server
command: ['/bin/apiserver']
volumeMounts:
- name: server-config
mountPath: /config/config.json
subPath: config.json
args:
- --config=/config
- -logtostderr=true
Expand Down Expand Up @@ -210,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 @@ -159,6 +159,10 @@ spec:
limits:
cpu: 500m
memory: 1Gi
volumeMounts:
- name: server-config
mountPath: /config/config.json
subPath: config.json
- name: oauth-proxy
args:
- --https-address=:8443
Expand Down Expand Up @@ -213,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 ad47dda

Please sign in to comment.