This repository was archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
SUBMARINE-532. Use Notebook CRD & controller to spawn jupyter notebook #335
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| set -e | ||
|
|
||
| readonly NOTEBOOK_CONTROLLER_IMAGE="gcr.io/kubeflow-images-public/notebook-controller:v1.1.0-g253890cb" | ||
|
|
||
| if [ -L "${BASH_SOURCE-$0}" ]; then | ||
| PWD=$(dirname "$(readlink "${BASH_SOURCE-$0}")") | ||
| else | ||
| PWD=$(dirname "${BASH_SOURCE-$0}") | ||
| fi | ||
| CURRENT_PATH=$(cd "${PWD}">/dev/null; pwd) | ||
| export CURRENT_PATH | ||
| export SUBMARINE_HOME=${CURRENT_PATH}/../.. | ||
| # lib.sh use the ROOT variable | ||
| export ROOT="${SUBMARINE_HOME}/submarine-cloud/" | ||
| export KUBECONFIG="${HOME}/.kube/kind-config-${clusterName:-kind}" | ||
|
|
||
| # shellcheck source=./../../submarine-cloud/hack/lib.sh | ||
| source "${SUBMARINE_HOME}/submarine-cloud/hack/lib.sh" | ||
|
|
||
| ########################################### | ||
| # Load local docker image into registry | ||
| # Globals: | ||
| # KIND_BIN | ||
| # Arguments: | ||
| # image | ||
| ########################################### | ||
| function load_image_to_registry() { | ||
| if [[ ! $(docker inspect "$1" > /dev/null) ]] ; then | ||
| docker pull "$1" | ||
| fi | ||
| ${KIND_BIN} load docker-image "$1" | ||
| } | ||
|
|
||
|
|
||
| function main() { | ||
|
|
||
| hack::ensure_kubectl | ||
|
|
||
| load_image_to_registry "${NOTEBOOK_CONTROLLER_IMAGE}" | ||
| ${KUBECTL_BIN} apply -k "${CURRENT_PATH}/notebook-controller" | ||
|
|
||
| } | ||
|
|
||
| main "$@" | ||
11 changes: 11 additions & 0 deletions
11
dev-support/k8s/notebook-controller/cluster-role-binding.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: role-binding | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: service-account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: role | ||
| rules: | ||
| - apiGroups: | ||
| - apps | ||
| resources: | ||
| - statefulsets | ||
| - deployments | ||
| verbs: | ||
| - '*' | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - pods | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - services | ||
| verbs: | ||
| - '*' | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - events | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - apiGroups: | ||
| - kubeflow.org | ||
| resources: | ||
| - notebooks | ||
| - notebooks/status | ||
| - notebooks/finalizers | ||
| verbs: | ||
| - '*' | ||
| - apiGroups: | ||
| - networking.istio.io | ||
| resources: | ||
| - virtualservices | ||
| verbs: | ||
| - '*' | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: kubeflow-notebooks-admin | ||
| labels: | ||
| rbac.authorization.kubeflow.org/aggregate-to-kubeflow-admin: "true" | ||
| aggregationRule: | ||
| clusterRoleSelectors: | ||
| - matchLabels: | ||
| rbac.authorization.kubeflow.org/aggregate-to-kubeflow-notebooks-admin: "true" | ||
| rules: [] | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: kubeflow-notebooks-edit | ||
| labels: | ||
| rbac.authorization.kubeflow.org/aggregate-to-kubeflow-edit: "true" | ||
| rbac.authorization.kubeflow.org/aggregate-to-kubeflow-notebooks-admin: "true" | ||
| rules: | ||
| - apiGroups: | ||
| - kubeflow.org | ||
| resources: | ||
| - notebooks | ||
| - notebooks/status | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - delete | ||
| - deletecollection | ||
| - patch | ||
| - update | ||
|
|
||
| --- | ||
|
|
||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: kubeflow-notebooks-view | ||
| labels: | ||
| rbac.authorization.kubeflow.org/aggregate-to-kubeflow-view: "true" | ||
| rules: | ||
| - apiGroups: | ||
| - kubeflow.org | ||
| resources: | ||
| - notebooks | ||
| - notebooks/status | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| apiVersion: apiextensions.k8s.io/v1beta1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: notebooks.kubeflow.org | ||
| spec: | ||
| group: kubeflow.org | ||
| names: | ||
| kind: Notebook | ||
| plural: notebooks | ||
| singular: notebook | ||
| scope: Namespaced | ||
| subresources: | ||
| status: {} | ||
| versions: | ||
| - name: v1alpha1 | ||
| served: true | ||
| storage: false | ||
| - name: v1beta1 | ||
| served: true | ||
| storage: true | ||
| - name: v1 | ||
| served: true | ||
| storage: false | ||
| validation: | ||
| openAPIV3Schema: | ||
| properties: | ||
| apiVersion: | ||
| description: 'APIVersion defines the versioned schema of this representation | ||
| of an object. Servers should convert recognized schemas to the latest | ||
| internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' | ||
| type: string | ||
| kind: | ||
| description: 'Kind is a string value representing the REST resource this | ||
| object represents. Servers may infer this from the endpoint the client | ||
| submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' | ||
| type: string | ||
| metadata: | ||
| type: object | ||
| spec: | ||
| properties: | ||
| template: | ||
| description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
| Important: Run "make" to regenerate code after modifying this file' | ||
| properties: | ||
| spec: | ||
| type: object | ||
| type: object | ||
| type: object | ||
| status: | ||
| properties: | ||
| conditions: | ||
| description: Conditions is an array of current conditions | ||
| items: | ||
| properties: | ||
| type: | ||
| description: Type of the confition/ | ||
| type: string | ||
| required: | ||
| - type | ||
| type: object | ||
| type: array | ||
| required: | ||
| - conditions | ||
| type: object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: deployment | ||
| spec: | ||
| template: | ||
| metadata: | ||
| annotations: | ||
| sidecar.istio.io/inject: "false" | ||
| spec: | ||
| containers: | ||
| - name: manager | ||
| image: gcr.io/kubeflow-images-public/notebook-controller:v1.1.0-g253890cb | ||
| command: | ||
| - /manager | ||
| imagePullPolicy: IfNotPresent | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /metrics | ||
| port: 8080 | ||
| initialDelaySeconds: 30 | ||
| periodSeconds: 30 | ||
| serviceAccountName: service-account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: deployment | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - name: manager | ||
| env: | ||
| # We use a patch to set the USE_ISTIO because in other patches | ||
| # we want to set it to a configMapRef and so if we include the value | ||
| # in the base when we do the merge we end up with 2 fields setting the value. | ||
| - name: USE_ISTIO | ||
| value: "false" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| resources: | ||
| - cluster-role-binding.yaml | ||
| - cluster-role.yaml | ||
| - crd.yaml | ||
| - deployment.yaml | ||
| - service-account.yaml | ||
| - service.yaml | ||
| namePrefix: notebook-controller- | ||
| namespace: default | ||
| patchesStrategicMerge: | ||
| - deployment_patch.yaml | ||
| commonLabels: | ||
| app: notebook-controller | ||
| kustomize.component: notebook-controller | ||
| images: | ||
| - name: gcr.io/kubeflow-images-public/notebook-controller | ||
| newName: gcr.io/kubeflow-images-public/notebook-controller | ||
| newTag: v1.1.0-g253890cb | ||
| configMapGenerator: | ||
| - name: parameters | ||
| literals: | ||
| - USE_ISTIO=false | ||
| - ISTIO_GATEWAY= | ||
| generatorOptions: | ||
| disableNameSuffixHash: true | ||
| vars: | ||
| - fieldref: | ||
| fieldPath: data.USE_ISTIO | ||
| name: USE_ISTIO | ||
| objref: | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| name: parameters | ||
| - fieldref: | ||
| fieldPath: data.ISTIO_GATEWAY | ||
| name: ISTIO_GATEWAY | ||
| objref: | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| name: parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: service-account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: service | ||
| spec: | ||
| ports: | ||
| - port: 443 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
set -euo pipefailThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
many shell scripts need to be set to
set -euo pipefail.Fix this problem in the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aylei Thanks for your review!
@liuxunorg Ok, I will fix other shell scripts too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lowc1012 Thanks!