Skip to content

Commit

Permalink
Propagate Disk name to ks application (kubeflow#2363)
Browse files Browse the repository at this point in the history
* deploy gce pd

* add storage deployment

* revert

* add flag

* check status

* fix

* fix unused variable

* refactor

* remove

* comments

* pass disk name

* propagate disk name to ks app

* merge
  • Loading branch information
IronPan committed Feb 4, 2019
1 parent 9bbe23c commit 55d0474
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions bootstrap/cmd/bootstrap/app/gcpUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (s *ksServer) InsertDeployment(ctx context.Context, req CreateRequest, dmSp
dmconf.Resources[0].Name = req.Name
dmconf.Resources[0].Properties["zone"] = req.Zone
dmconf.Resources[0].Properties["ipName"] = req.IpName
dmconf.Resources[0].Properties["createPipelinePersistentStorage"]=req.StorageOption.CreatePipelinePersistentStorage
// https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.zones.clusters
if s.gkeVersionOverride != "" {
dmconf.Resources[0].Properties["cluster-version"] = s.gkeVersionOverride
Expand Down
26 changes: 23 additions & 3 deletions bootstrap/cmd/bootstrap/app/ksServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const KubeflowFolder = "ks_app"
const DmFolder = "gcp_config"
const CloudShellFolder = "kf_util"

const PipelineDbDiskSuffix = "-pipeline-db"
const PipelineNfsDiskSuffix = "-pipeline-nfs"

type DmSpec struct {
// path to the deployment manager configuration file
ConfigFile string
Expand Down Expand Up @@ -176,6 +179,11 @@ func NewServer(appsDir string, registries []RegistryConfig, gkeVersionOverride s
return s, nil
}

type StorageOption struct {
// Whether to create persistent storage for storing all Kubeflow Pipeline artifacts or not.
CreatePipelinePersistentStorage bool
}

// CreateRequest represents a request to create a ksonnet application.
type CreateRequest struct {
// Name for the app.
Expand Down Expand Up @@ -207,8 +215,7 @@ type CreateRequest struct {
// For test: GCP service account client id
SAClientId string

// Whether to create persistent storage for storing all Kubeflow artifacts or not.
CreatePersistentStorage bool
StorageOption StorageOption
}

// basicServerResponse is general response contains nil if handler raise no error, otherwise an error message.
Expand Down Expand Up @@ -1216,13 +1223,26 @@ func makeDeployEndpoint(svc KsService) endpoint.Endpoint {
}

var storageDmDeployment *deploymentmanager.Deployment
if req.CreatePersistentStorage {

if req.StorageOption.CreatePipelinePersistentStorage {
var err error
storageDmDeployment, err = svc.InsertDeployment(ctx, req, StorageDmSpec)
if err != nil {
r.Err = err.Error()
return r, err
}
req.AppConfig.Parameters = append(
req.AppConfig.Parameters,
KsParameter{
Component: "pipeline",
Name: "mysqlPd",
Value: req.Name + StorageDmSpec.DmNameSuffix + PipelineDbDiskSuffix})
req.AppConfig.Parameters = append(
req.AppConfig.Parameters,
KsParameter{
Component: "pipeline",
Name: "nfsPd",
Value: req.Name + StorageDmSpec.DmNameSuffix + PipelineNfsDiskSuffix})
}

clusterDmDeployment, err := svc.InsertDeployment(ctx, req, ClusterDmSpec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ resources:
type: storage.jinja
properties:
zone: SET_THE_ZONE
createPipelinePersistentStorage: SET_CREAT_PIPELINE_PERSISTENT_STORAGE
disks:
- sizeGb: 20
diskType: pd-standard
name: pipeline-db
usage: pipeline-db
- sizeGb: 200
diskType: pd-standard
name: pipeline-nfs
usage: pipeline-nfs
enable_cloudsql: false
database:
name: mlpipeline
Expand Down
4 changes: 3 additions & 1 deletion deployment/gke/deployment_manager_configs/storage.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ See the License for the specific language governing permissions and
limitations under the License.
#}

{% macro diskName(diskObj) -%}{{ env["deployment"]}}-{{ diskObj["name"] }}{%- endmacro %}
{% macro diskName(diskObj) -%}{{ env["deployment"]}}-{{ diskObj["usage"] }}{%- endmacro %}

{% set NAME_PREFIX = env['deployment'] %}
{% set SQL_INSTANCE_NAME = env['deployment'] + '-mysql' %}

resources:
{% if properties['createPipelinePersistentStorage'] %}
{% for diskObj in properties["disks"] %}
- name: {{ diskName(diskObj) }}
type: compute.v1.disk
Expand All @@ -25,6 +26,7 @@ resources:
sizeGb: {{ diskObj["sizeGb"] }}
type: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/diskTypes/{{ diskObj["diskType"] }}
{% endfor %}
{% endif %}

{% if properties['enable_cloudsql'] %}
- name: {{ SQL_INSTANCE_NAME }}
Expand Down
11 changes: 7 additions & 4 deletions deployment/gke/deployment_manager_configs/storage.jinja.schema
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ properties:
items:
type: object
required:
- name
- usage
properties:
name:
type: string
description: Suffix for this disk
sizeGb:
type: integer
default: 200
Expand All @@ -43,6 +40,12 @@ properties:
enum:
- pd-standard
- pd-ssd
usage:
type: string
description: what is the disk used for
enum:
- pipeline-db
- pipeline-nfs

cloudsql:
type: object
Expand Down

0 comments on commit 55d0474

Please sign in to comment.