Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dev-support/docker-images/jupyter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM $BASE_IMAGE

ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_PREFIX="/jupyter/"
ARG NB_PREFIX="/"
ARG NB_PORT=8888

USER root
Expand Down Expand Up @@ -72,9 +72,7 @@ RUN mv /tini /usr/local/bin/tini && chmod +x /usr/local/bin/tini

# Install python package
RUN pip uninstall -y enum34
RUN pip3 --no-cache-dir install \
jupyterhub \
jupyterlab
RUN pip3 --no-cache-dir install jupyterlab

# Configure container startup
EXPOSE $NB_PORT
Expand Down
62 changes: 62 additions & 0 deletions dev-support/k8s/deploy-notebook-controller.sh
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about set -euo pipefail

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lowc1012 Thanks!


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 dev-support/k8s/notebook-controller/cluster-role-binding.yaml
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
107 changes: 107 additions & 0 deletions dev-support/k8s/notebook-controller/cluster-role.yaml
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
64 changes: 64 additions & 0 deletions dev-support/k8s/notebook-controller/crd.yaml
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
23 changes: 23 additions & 0 deletions dev-support/k8s/notebook-controller/deployment.yaml
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
15 changes: 15 additions & 0 deletions dev-support/k8s/notebook-controller/deployment_patch.yaml
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"
42 changes: 42 additions & 0 deletions dev-support/k8s/notebook-controller/kustomization.yaml
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
4 changes: 4 additions & 0 deletions dev-support/k8s/notebook-controller/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: service-account
7 changes: 7 additions & 0 deletions dev-support/k8s/notebook-controller/service.yaml
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
Loading