From 0a2d3124de3741e0708679804f513f8bc08e3584 Mon Sep 17 00:00:00 2001 From: cegao Date: Mon, 19 Apr 2021 16:07:39 +0800 Subject: [PATCH 01/13] UPDATE Signed-off-by: cegao --- api/v1alpha1/jupyterkernelspec_types.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/v1alpha1/jupyterkernelspec_types.go b/api/v1alpha1/jupyterkernelspec_types.go index d003d78..6c0128f 100644 --- a/api/v1alpha1/jupyterkernelspec_types.go +++ b/api/v1alpha1/jupyterkernelspec_types.go @@ -29,6 +29,8 @@ type JupyterKernelSpecSpec struct { Env []v1.EnvVar `json:"env,omitempty"` Command []string `json:"command,omitempty"` // TODO(gaocegege): Support resources and so on. + + Template *v1.PodTemplate `json:"template,omitempty"` } // JupyterKernelSpecStatus defines the observed state of JupyterKernelSpec From 9223505f1986c1d2fdfca04e3bb5a81543a978c9 Mon Sep 17 00:00:00 2001 From: cegao Date: Thu, 6 May 2021 16:41:16 +0800 Subject: [PATCH 02/13] feat: Add config Signed-off-by: cegao --- ...ow.tkestack.io_jupyterkerneltemplates.yaml | 30 +++++++++++++++++++ config/crd/kustomization.yaml | 3 ++ ...cainjection_in_jupyterkerneltemplates.yaml | 8 +++++ .../webhook_in_jupyterkerneltemplates.yaml | 17 +++++++++++ .../jupyterkerneltemplate_editor_role.yaml | 24 +++++++++++++++ .../jupyterkerneltemplate_viewer_role.yaml | 20 +++++++++++++ config/rbac/role.yaml | 20 +++++++++++++ ...ack.io_v1alpha1_jupyterkerneltemplate.yaml | 15 ++++++++++ 8 files changed, 137 insertions(+) create mode 100644 config/crd/bases/kubeflow.tkestack.io_jupyterkerneltemplates.yaml create mode 100644 config/crd/patches/cainjection_in_jupyterkerneltemplates.yaml create mode 100644 config/crd/patches/webhook_in_jupyterkerneltemplates.yaml create mode 100644 config/rbac/jupyterkerneltemplate_editor_role.yaml create mode 100644 config/rbac/jupyterkerneltemplate_viewer_role.yaml create mode 100644 config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkerneltemplate.yaml diff --git a/config/crd/bases/kubeflow.tkestack.io_jupyterkerneltemplates.yaml b/config/crd/bases/kubeflow.tkestack.io_jupyterkerneltemplates.yaml new file mode 100644 index 0000000..2aef764 --- /dev/null +++ b/config/crd/bases/kubeflow.tkestack.io_jupyterkerneltemplates.yaml @@ -0,0 +1,30 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: jupyterkerneltemplates.kubeflow.tkestack.io +spec: + group: kubeflow.tkestack.io + names: + kind: JupyterKernelTemplate + listKind: JupyterKernelTemplateList + plural: jupyterkerneltemplates + singular: jupyterkerneltemplate + scope: Namespaced + subresources: + status: {} + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index cf1f974..549fd1a 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -5,6 +5,7 @@ resources: - bases/kubeflow.tkestack.io_jupyternotebooks.yaml - bases/kubeflow.tkestack.io_jupytergateways.yaml - bases/kubeflow.tkestack.io_jupyterkernelspecs.yaml +- bases/kubeflow.tkestack.io_jupyterkerneltemplates.yaml # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: @@ -13,6 +14,7 @@ patchesStrategicMerge: #- patches/webhook_in_jupyternotebooks.yaml #- patches/webhook_in_jupytergateways.yaml #- patches/webhook_in_jupyterkernelspecs.yaml +#- patches/webhook_in_jupyterkerneltemplates.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. @@ -20,6 +22,7 @@ patchesStrategicMerge: #- patches/cainjection_in_jupyternotebooks.yaml #- patches/cainjection_in_jupytergateways.yaml #- patches/cainjection_in_jupyterkernelspecs.yaml +#- patches/cainjection_in_jupyterkerneltemplates.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_jupyterkerneltemplates.yaml b/config/crd/patches/cainjection_in_jupyterkerneltemplates.yaml new file mode 100644 index 0000000..ab0f19f --- /dev/null +++ b/config/crd/patches/cainjection_in_jupyterkerneltemplates.yaml @@ -0,0 +1,8 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +# CRD conversion requires k8s 1.13 or later. +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: jupyterkerneltemplates.kubeflow.tkestack.io diff --git a/config/crd/patches/webhook_in_jupyterkerneltemplates.yaml b/config/crd/patches/webhook_in_jupyterkerneltemplates.yaml new file mode 100644 index 0000000..3ec21d4 --- /dev/null +++ b/config/crd/patches/webhook_in_jupyterkerneltemplates.yaml @@ -0,0 +1,17 @@ +# The following patch enables conversion webhook for CRD +# CRD conversion requires k8s 1.13 or later. +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: jupyterkerneltemplates.kubeflow.tkestack.io +spec: + conversion: + strategy: Webhook + webhookClientConfig: + # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, + # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) + caBundle: Cg== + service: + namespace: system + name: webhook-service + path: /convert diff --git a/config/rbac/jupyterkerneltemplate_editor_role.yaml b/config/rbac/jupyterkerneltemplate_editor_role.yaml new file mode 100644 index 0000000..6813d77 --- /dev/null +++ b/config/rbac/jupyterkerneltemplate_editor_role.yaml @@ -0,0 +1,24 @@ +# permissions for end users to edit jupyterkerneltemplates. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: jupyterkerneltemplate-editor-role +rules: +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates/status + verbs: + - get diff --git a/config/rbac/jupyterkerneltemplate_viewer_role.yaml b/config/rbac/jupyterkerneltemplate_viewer_role.yaml new file mode 100644 index 0000000..34bfeb6 --- /dev/null +++ b/config/rbac/jupyterkerneltemplate_viewer_role.yaml @@ -0,0 +1,20 @@ +# permissions for end users to view jupyterkerneltemplates. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: jupyterkerneltemplate-viewer-role +rules: +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates + verbs: + - get + - list + - watch +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates/status + verbs: + - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 7877da5..0bcb6df 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -78,6 +78,26 @@ rules: - get - patch - update +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - kubeflow.tkestack.io + resources: + - jupyterkerneltemplates/status + verbs: + - get + - patch + - update - apiGroups: - kubeflow.tkestack.io resources: diff --git a/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkerneltemplate.yaml b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkerneltemplate.yaml new file mode 100644 index 0000000..cdd163b --- /dev/null +++ b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkerneltemplate.yaml @@ -0,0 +1,15 @@ +apiVersion: kubeflow.tkestack.io/v1alpha1 +kind: JupyterKernelTemplate +metadata: + name: jupyterkerneltemplate-sample +spec: + template: + metadata: + app: enterprise-gateway + component: kernel + template: + spec: + restartPolicy: Never + containers: + - name: kernel + From 8504f06e7a3681107d3b3509acab7aabab288b2a Mon Sep 17 00:00:00 2001 From: cegao Date: Thu, 6 May 2021 16:41:36 +0800 Subject: [PATCH 03/13] fix: Add git ignore file Signed-off-by: cegao --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5f79572..c961faf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ bin *~ vendor/ -/enterprise_gateway/ \ No newline at end of file +/enterprise_gateway/ +.vscode/ From 4bdcdea26643483a3f048bf69d422c81fa9af80c Mon Sep 17 00:00:00 2001 From: cegao Date: Fri, 7 May 2021 09:51:25 +0800 Subject: [PATCH 04/13] feat: Update api doc Signed-off-by: cegao --- docs/api/generated.asciidoc | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/docs/api/generated.asciidoc b/docs/api/generated.asciidoc index adc7b73..b4e3783 100644 --- a/docs/api/generated.asciidoc +++ b/docs/api/generated.asciidoc @@ -18,6 +18,8 @@ Package v1alpha1 contains API Schema definitions for the kubeflow.tkestack.io v1 - xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupytergatewaylist[$$JupyterGatewayList$$] - xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkernelspec[$$JupyterKernelSpec$$] - xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkernelspeclist[$$JupyterKernelSpecList$$] +- xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplate[$$JupyterKernelTemplate$$] +- xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatelist[$$JupyterKernelTemplateList$$] - xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyternotebook[$$JupyterNotebook$$] - xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyternotebooklist[$$JupyterNotebookList$$] @@ -170,6 +172,67 @@ JupyterKernelSpecSpec defines the desired state of JupyterKernelSpec +[id="{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplate"] +==== JupyterKernelTemplate + +JupyterKernelTemplate is the Schema for the jupyterkerneltemplates API + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatelist[$$JupyterKernelTemplateList$$] +**** + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`apiVersion`* __string__ | `kubeflow.tkestack.io/v1alpha1` +| *`kind`* __string__ | `JupyterKernelTemplate` +| *`TypeMeta`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#typemeta-v1-meta[$$TypeMeta$$]__ | +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta[$$ObjectMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + +| *`spec`* __xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatespec[$$JupyterKernelTemplateSpec$$]__ | +| *`status`* __xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatestatus[$$JupyterKernelTemplateStatus$$]__ | +|=== + + +[id="{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatelist"] +==== JupyterKernelTemplateList + +JupyterKernelTemplateList contains a list of JupyterKernelTemplate + + + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`apiVersion`* __string__ | `kubeflow.tkestack.io/v1alpha1` +| *`kind`* __string__ | `JupyterKernelTemplateList` +| *`TypeMeta`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#typemeta-v1-meta[$$TypeMeta$$]__ | +| *`metadata`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#listmeta-v1-meta[$$ListMeta$$]__ | Refer to Kubernetes API documentation for fields of `metadata`. + +| *`items`* __xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplate[$$JupyterKernelTemplate$$]__ | +|=== + + +[id="{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplatespec"] +==== JupyterKernelTemplateSpec + +JupyterKernelTemplateSpec defines the desired state of JupyterKernelTemplate + +.Appears In: +**** +- xref:{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyterkerneltemplate[$$JupyterKernelTemplate$$] +**** + +[cols="25a,75a", options="header"] +|=== +| Field | Description +| *`template`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#podtemplate-v1-core[$$PodTemplate$$]__ | +|=== + + + + [id="{anchor_prefix}-github-com-tkestack-elastic-jupyter-operator-api-v1alpha1-jupyternotebook"] ==== JupyterNotebook From c5f1ec39eb264d40aef7cd3e1c8ee2b3debb0c76 Mon Sep 17 00:00:00 2001 From: cegao Date: Fri, 7 May 2021 09:51:48 +0800 Subject: [PATCH 05/13] feat: Add CRDs Signed-off-by: cegao --- api/v1alpha1/jupyterkernelspec_types.go | 2 - api/v1alpha1/jupyterkerneltemplate_types.go | 58 ++++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 94 +++++++++++++++++++ .../jupyterkerneltemplate_controller.go | 53 +++++++++++ controllers/suite_test.go | 3 + main.go | 8 ++ 6 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 api/v1alpha1/jupyterkerneltemplate_types.go create mode 100644 controllers/jupyterkerneltemplate_controller.go diff --git a/api/v1alpha1/jupyterkernelspec_types.go b/api/v1alpha1/jupyterkernelspec_types.go index 6c0128f..d003d78 100644 --- a/api/v1alpha1/jupyterkernelspec_types.go +++ b/api/v1alpha1/jupyterkernelspec_types.go @@ -29,8 +29,6 @@ type JupyterKernelSpecSpec struct { Env []v1.EnvVar `json:"env,omitempty"` Command []string `json:"command,omitempty"` // TODO(gaocegege): Support resources and so on. - - Template *v1.PodTemplate `json:"template,omitempty"` } // JupyterKernelSpecStatus defines the observed state of JupyterKernelSpec diff --git a/api/v1alpha1/jupyterkerneltemplate_types.go b/api/v1alpha1/jupyterkerneltemplate_types.go new file mode 100644 index 0000000..ed64350 --- /dev/null +++ b/api/v1alpha1/jupyterkerneltemplate_types.go @@ -0,0 +1,58 @@ +// Tencent is pleased to support the open source community by making TKEStack +// available. + +// Copyright (C) 2012-2020 Tencent. All Rights Reserved. + +// Licensed 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 + +// https://opensource.org/licenses/Apache-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 OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// JupyterKernelTemplateSpec defines the desired state of JupyterKernelTemplate +type JupyterKernelTemplateSpec struct { + Template *v1.PodTemplate `json:"template,omitempty"` +} + +// JupyterKernelTemplateStatus defines the observed state of JupyterKernelTemplate +type JupyterKernelTemplateStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// JupyterKernelTemplate is the Schema for the jupyterkerneltemplates API +type JupyterKernelTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec JupyterKernelTemplateSpec `json:"spec,omitempty"` + Status JupyterKernelTemplateStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// JupyterKernelTemplateList contains a list of JupyterKernelTemplate +type JupyterKernelTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []JupyterKernelTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&JupyterKernelTemplate{}, &JupyterKernelTemplateList{}) +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index d6f7049..825915d 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -246,6 +246,100 @@ func (in *JupyterKernelSpecStatus) DeepCopy() *JupyterKernelSpecStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JupyterKernelTemplate) DeepCopyInto(out *JupyterKernelTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JupyterKernelTemplate. +func (in *JupyterKernelTemplate) DeepCopy() *JupyterKernelTemplate { + if in == nil { + return nil + } + out := new(JupyterKernelTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *JupyterKernelTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JupyterKernelTemplateList) DeepCopyInto(out *JupyterKernelTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]JupyterKernelTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JupyterKernelTemplateList. +func (in *JupyterKernelTemplateList) DeepCopy() *JupyterKernelTemplateList { + if in == nil { + return nil + } + out := new(JupyterKernelTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *JupyterKernelTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JupyterKernelTemplateSpec) DeepCopyInto(out *JupyterKernelTemplateSpec) { + *out = *in + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(v1.PodTemplate) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JupyterKernelTemplateSpec. +func (in *JupyterKernelTemplateSpec) DeepCopy() *JupyterKernelTemplateSpec { + if in == nil { + return nil + } + out := new(JupyterKernelTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JupyterKernelTemplateStatus) DeepCopyInto(out *JupyterKernelTemplateStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JupyterKernelTemplateStatus. +func (in *JupyterKernelTemplateStatus) DeepCopy() *JupyterKernelTemplateStatus { + if in == nil { + return nil + } + out := new(JupyterKernelTemplateStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JupyterNotebook) DeepCopyInto(out *JupyterNotebook) { *out = *in diff --git a/controllers/jupyterkerneltemplate_controller.go b/controllers/jupyterkerneltemplate_controller.go new file mode 100644 index 0000000..d277d0f --- /dev/null +++ b/controllers/jupyterkerneltemplate_controller.go @@ -0,0 +1,53 @@ +// Tencent is pleased to support the open source community by making TKEStack +// available. + +// Copyright (C) 2012-2020 Tencent. All Rights Reserved. + +// Licensed 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 + +// https://opensource.org/licenses/Apache-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 OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +package controllers + +import ( + "context" + + "github.com/go-logr/logr" + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + kubeflowtkestackiov1alpha1 "github.com/tkestack/elastic-jupyter-operator/api/v1alpha1" +) + +// JupyterKernelTemplateReconciler reconciles a JupyterKernelTemplate object +type JupyterKernelTemplateReconciler struct { + client.Client + Log logr.Logger + Scheme *runtime.Scheme +} + +// +kubebuilder:rbac:groups=kubeflow.tkestack.io,resources=jupyterkerneltemplates,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=kubeflow.tkestack.io,resources=jupyterkerneltemplates/status,verbs=get;update;patch + +func (r *JupyterKernelTemplateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { + _ = context.Background() + _ = r.Log.WithValues("jupyterkerneltemplate", req.NamespacedName) + + // your logic here + + return ctrl.Result{}, nil +} + +func (r *JupyterKernelTemplateReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&kubeflowtkestackiov1alpha1.JupyterKernelTemplate{}). + Complete(r) +} diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 5104851..413d30e 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -71,6 +71,9 @@ var _ = BeforeSuite(func(done Done) { err = kubeflowtkestackiov1alpha1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) + err = kubeflowtkestackiov1alpha1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + // +kubebuilder:scaffold:scheme k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) diff --git a/main.go b/main.go index 587c210..6957aca 100644 --- a/main.go +++ b/main.go @@ -94,6 +94,14 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "JupyterKernelSpec") os.Exit(1) } + if err = (&controllers.JupyterKernelTemplateReconciler{ + Client: mgr.GetClient(), + Log: ctrl.Log.WithName("controllers").WithName("JupyterKernelTemplate"), + Scheme: mgr.GetScheme(), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "JupyterKernelTemplate") + os.Exit(1) + } // +kubebuilder:scaffold:builder setupLog.Info("starting manager") From ea3db87a422b9fcad0aca54a43b548a36bd87707 Mon Sep 17 00:00:00 2001 From: cegao Date: Fri, 7 May 2021 09:52:03 +0800 Subject: [PATCH 06/13] chore: Update golang dependencies Signed-off-by: cegao --- go.mod | 3 +++ go.sum | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/go.mod b/go.mod index 55cdf19..7b1316b 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,11 @@ require ( github.com/elastic/crd-ref-docs v0.0.7 // indirect github.com/go-logr/logr v0.1.0 github.com/google/addlicense v0.0.0-20200906110928-a0294312aa76 // indirect + github.com/mitchellh/go-homedir v1.1.0 github.com/onsi/ginkgo v1.12.1 github.com/onsi/gomega v1.10.1 + github.com/spf13/cobra v0.0.5 + github.com/spf13/viper v1.3.2 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect k8s.io/api v0.18.6 k8s.io/apimachinery v0.18.6 diff --git a/go.sum b/go.sum index 94a12f4..3a780f3 100644 --- a/go.sum +++ b/go.sum @@ -209,6 +209,7 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.1 h1:v6IdmkCnDhJG/S0ivr58PeIfg+tyhqQYy4YsCsQ0Pdc= @@ -240,6 +241,7 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -261,7 +263,9 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -292,6 +296,7 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -333,17 +338,21 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From 07ab9ddea7dbf54d42592d180c4b53bc754e0f40 Mon Sep 17 00:00:00 2001 From: cegao Date: Fri, 7 May 2021 09:52:16 +0800 Subject: [PATCH 07/13] feat: Add launchers Signed-off-by: cegao --- cli/LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++ cli/cmd/root.go | 132 +++++++++++++++++++++++++++++++ cli/main.go | 22 ++++++ 3 files changed, 356 insertions(+) create mode 100644 cli/LICENSE create mode 100644 cli/cmd/root.go create mode 100644 cli/main.go diff --git a/cli/LICENSE b/cli/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/cli/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/cli/cmd/root.go b/cli/cmd/root.go new file mode 100644 index 0000000..7faa98e --- /dev/null +++ b/cli/cmd/root.go @@ -0,0 +1,132 @@ +/* +Copyright © 2021 NAME HERE + +Licensed 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. +*/ +package cmd + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/spf13/cobra" + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes/scheme" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/config" + + "github.com/tkestack/elastic-jupyter-operator/api/v1alpha1" +) + +var kernelID, portRange, responseAddr, + publicKey, sparkContextInitMode, + kernelTemplateName, kernelTemplateNamespace string + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "kubeflow-launcher", + Short: "Launch kernels", + Long: `Launch kernels in the jupyter enterprise gateway`, + Run: func(cmd *cobra.Command, args []string) { + if kernelTemplateName == "" || kernelTemplateNamespace == "" { + panic(fmt.Errorf("Failed to get the template's name or namespace")) + } + + if err := v1alpha1.AddToScheme(scheme.Scheme); err != nil { + panic(err) + } + + cfg, err := config.GetConfig() + if err != nil { + panic(err) + } + + cli, err := client.New(cfg, client.Options{ + Scheme: scheme.Scheme, + }) + if err != nil { + panic(err) + } + + kt := &v1alpha1.JupyterKernelTemplate{} + if err := cli.Get(context.TODO(), client.ObjectKey{ + Namespace: kernelTemplateNamespace, + Name: kernelTemplateName, + }, kt); err != nil { + panic(err) + } + + tpl := kt.Spec.Template + + // Set image from the kernel spec. + image := os.Getenv("KERNEL_IMAGE") + if image != "" && len(tpl.Template.Spec.Containers) != 0 { + tpl.Template.Spec.Containers[0].Image = image + } + + pod := &v1.Pod{ + ObjectMeta: tpl.ObjectMeta, + Spec: tpl.Template.Spec, + } + + pod.Name = os.Getenv("KERNEL_POD_NAME") + pod.Namespace = os.Getenv("KERNEL_POD_NAMESPACE") + if pod.Labels == nil { + pod.Labels = make(map[string]string) + } + pod.Labels["kernel_id"] = os.Getenv("KERNEL_ID") + + if err := cli.Create(context.TODO(), pod); err != nil { + panic(err) + } + + log.Println(kernelID, portRange, + responseAddr, publicKey, sparkContextInitMode) + log.Println("done") + + }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func init() { + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + + rootCmd.Flags().StringVar(&kernelID, + "RemoteProcessProxy.kernel-id", "", "kernel id") + rootCmd.Flags().StringVar(&portRange, + "RemoteProcessProxy.port-range", "", "port range") + rootCmd.Flags().StringVar(&responseAddr, + "RemoteProcessProxy.response-address", "", "response address") + rootCmd.Flags().StringVar(&publicKey, + "RemoteProcessProxy.public-key", "", "public key") + rootCmd.Flags().StringVar(&sparkContextInitMode, + "RemoteProcessProxy.spark-context-initialization-mode", + "", "spark context init mode") + + rootCmd.Flags().StringVar(&kernelTemplateName, + "kernel-template-name", "", "kernel template CRD name") + rootCmd.Flags().StringVar(&kernelTemplateNamespace, + "kernel-template-namespace", "", "kernel template CRD namesapce") +} diff --git a/cli/main.go b/cli/main.go new file mode 100644 index 0000000..1561a0b --- /dev/null +++ b/cli/main.go @@ -0,0 +1,22 @@ +/* +Copyright © 2021 NAME HERE + +Licensed 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. +*/ +package main + +import "github.com/tkestack/elastic-jupyter-operator/cli/cmd" + +func main() { + cmd.Execute() +} From e4fc7762a809611296b17cea308d107c7dab5239 Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 16:06:06 +0800 Subject: [PATCH 08/13] feat: Add class name Signed-off-by: cegao --- api/v1alpha1/jupyterkernelspec_types.go | 1 + pkg/kernelspec/generate.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/api/v1alpha1/jupyterkernelspec_types.go b/api/v1alpha1/jupyterkernelspec_types.go index d003d78..e00403f 100644 --- a/api/v1alpha1/jupyterkernelspec_types.go +++ b/api/v1alpha1/jupyterkernelspec_types.go @@ -28,6 +28,7 @@ type JupyterKernelSpecSpec struct { Image string `json:"image,omitempty"` Env []v1.EnvVar `json:"env,omitempty"` Command []string `json:"command,omitempty"` + ClassName string `json:"className,omitempty"` // TODO(gaocegege): Support resources and so on. } diff --git a/pkg/kernelspec/generate.go b/pkg/kernelspec/generate.go index 40f40c5..b38e0b7 100644 --- a/pkg/kernelspec/generate.go +++ b/pkg/kernelspec/generate.go @@ -104,6 +104,11 @@ func (g generator) desiredJSON() (string, error) { }, Argv: g.kernelSpec.Spec.Command, } + + // Set the class name to desired. + if g.kernelSpec.Spec.ClassName != "" { + c.Metadata.ProcessProxy.ClassName = g.kernelSpec.Spec.ClassName + } v, err := json.Marshal(c) return string(v), err } From ae5d9fccd94eb5537d21dcdfdf4b3dbbbaea6ed8 Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 16:06:19 +0800 Subject: [PATCH 09/13] feat: Add support to custom launcher Signed-off-by: cegao --- ...lpha1_jupyterkernelspec-custom-launcher.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml diff --git a/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml new file mode 100644 index 0000000..74da415 --- /dev/null +++ b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml @@ -0,0 +1,17 @@ +apiVersion: kubeflow.tkestack.io/v1alpha1 +kind: JupyterKernelSpec +metadata: + name: python-kubernetes +spec: + language: Python + displayName: "Python on Kubernetes as a JupyterKernelSpec" + image: ccr.ccs.tencentyun.com/kubeflow-oteam/jupyter-kernel-py:2.5.0 + command: + # Use the default scripts to launch the kernel. + - "kubeflow-launcher" + - "--RemoteProcessProxy.kernel-id" + - "{kernel_id}" + - "--RemoteProcessProxy.port-range" + - "{port_range}" + - "--RemoteProcessProxy.response-address" + - "{response_address}" From cd9db57a65443110981227a7c9677904c0025d1c Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 17:08:54 +0800 Subject: [PATCH 10/13] feat: Add env Signed-off-by: cegao --- cli/LICENSE | 202 ------------------------------------------------ cli/cmd/root.go | 63 ++++++++++++++- 2 files changed, 59 insertions(+), 206 deletions(-) delete mode 100644 cli/LICENSE diff --git a/cli/LICENSE b/cli/LICENSE deleted file mode 100644 index d645695..0000000 --- a/cli/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 7faa98e..0f8ca8b 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -30,6 +30,22 @@ import ( "github.com/tkestack/elastic-jupyter-operator/api/v1alpha1" ) +const ( + envKernelPodName = "KERNEL_POD_NAME" + envKernelImage = "KERNEL_IMAGE" + envKernelNamespace = "KERNEL_NAMESPACE" + envKernelID = "KERNEL_ID" + envPortRange = "EG_PORT_RANGE" + envResponseAddress = "EG_RESPONSE_ADDRESS" + envPublicKey = "EG_PUBLIC_KEY" + envKernelLanguage = "KERNEL_LANGUAGE" + envKernelName = "KERNEL_NAME" + envKernelSpark = "KERNEL_SPARK_CONTEXT_INIT_MODE" + envKernelUsername = "KERNEL_USERNAME" + + labelKernelID = "kernel_id" +) + var kernelID, portRange, responseAddr, publicKey, sparkContextInitMode, kernelTemplateName, kernelTemplateNamespace string @@ -71,7 +87,7 @@ var rootCmd = &cobra.Command{ tpl := kt.Spec.Template // Set image from the kernel spec. - image := os.Getenv("KERNEL_IMAGE") + image := os.Getenv(envKernelImage) if image != "" && len(tpl.Template.Spec.Containers) != 0 { tpl.Template.Spec.Containers[0].Image = image } @@ -81,12 +97,51 @@ var rootCmd = &cobra.Command{ Spec: tpl.Template.Spec, } - pod.Name = os.Getenv("KERNEL_POD_NAME") - pod.Namespace = os.Getenv("KERNEL_POD_NAMESPACE") + pod.Name = os.Getenv(envKernelPodName) + pod.Namespace = os.Getenv(envKernelNamespace) if pod.Labels == nil { pod.Labels = make(map[string]string) } - pod.Labels["kernel_id"] = os.Getenv("KERNEL_ID") + pod.Labels[labelKernelID] = kernelID + + pod.Spec.Containers[0].Env = append(pod.Spec.Containers[0].Env, + v1.EnvVar{ + Name: envPortRange, + Value: portRange, + }, + v1.EnvVar{ + Name: envResponseAddress, + Value: responseAddr, + }, + v1.EnvVar{ + Name: envPublicKey, + Value: publicKey, + }, + v1.EnvVar{ + Name: envKernelID, + Value: kernelID, + }, + v1.EnvVar{ + Name: envKernelLanguage, + Value: os.Getenv(envKernelLanguage), + }, + v1.EnvVar{ + Name: envKernelName, + Value: os.Getenv(envKernelName), + }, + v1.EnvVar{ + Name: envKernelNamespace, + Value: os.Getenv(envKernelNamespace), + }, + v1.EnvVar{ + Name: envKernelSpark, + Value: sparkContextInitMode, + }, + v1.EnvVar{ + Name: envKernelUsername, + Value: os.Getenv(envKernelUsername), + }, + ) if err := cli.Create(context.TODO(), pod); err != nil { panic(err) From 669771abe72e20be1d39cade61cdf6f83677be2e Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 17:09:02 +0800 Subject: [PATCH 11/13] chore: Add new permission Signed-off-by: cegao --- hack/enterprise_gateway/prepare.yaml | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 hack/enterprise_gateway/prepare.yaml diff --git a/hack/enterprise_gateway/prepare.yaml b/hack/enterprise_gateway/prepare.yaml old mode 100644 new mode 100755 index 59ef6c5..636d91c --- a/hack/enterprise_gateway/prepare.yaml +++ b/hack/enterprise_gateway/prepare.yaml @@ -30,6 +30,9 @@ rules: - apiGroups: ["rbac.authorization.k8s.io"] resources: ["rolebindings"] verbs: ["get", "list", "create", "delete"] + - apiGroups: ["kubeflow.tkestack.io"] + resources: ["jupyterkerneltemplates"] + verbs: ["get", "list", "create", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole From a95997c0ed2fdf9982d0556b33ccce3c323cf50d Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 17:13:47 +0800 Subject: [PATCH 12/13] feat: Update API to support custom gateway image Signed-off-by: cegao --- api/v1alpha1/jupytergateway_types.go | 2 ++ api/v1alpha1/jupyterkernelspec_types.go | 2 ++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ ...tack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml | 3 +++ docs/api/generated.asciidoc | 2 ++ pkg/gateway/generate.go | 4 ++++ pkg/kernelspec/generate.go | 7 +++++++ 7 files changed, 25 insertions(+) diff --git a/api/v1alpha1/jupytergateway_types.go b/api/v1alpha1/jupytergateway_types.go index 2f6d60c..47b8c96 100644 --- a/api/v1alpha1/jupytergateway_types.go +++ b/api/v1alpha1/jupytergateway_types.go @@ -46,6 +46,8 @@ type JupyterGatewaySpec struct { // +optional Resources *v1.ResourceRequirements `json:"resources,omitempty"` + Image string `json:"image,omitempty"` + ClusterRole *string `json:"clusterRole,omitempty"` } diff --git a/api/v1alpha1/jupyterkernelspec_types.go b/api/v1alpha1/jupyterkernelspec_types.go index e00403f..a520376 100644 --- a/api/v1alpha1/jupyterkernelspec_types.go +++ b/api/v1alpha1/jupyterkernelspec_types.go @@ -29,6 +29,8 @@ type JupyterKernelSpecSpec struct { Env []v1.EnvVar `json:"env,omitempty"` Command []string `json:"command,omitempty"` ClassName string `json:"className,omitempty"` + + Template *v1.ObjectReference `json:"template,omitempty"` // TODO(gaocegege): Support resources and so on. } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 825915d..521e453 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -219,6 +219,11 @@ func (in *JupyterKernelSpecSpec) DeepCopyInto(out *JupyterKernelSpecSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(v1.ObjectReference) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JupyterKernelSpecSpec. diff --git a/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml index 74da415..05121d0 100644 --- a/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml +++ b/config/samples/kubeflow.tkestack.io_v1alpha1_jupyterkernelspec-custom-launcher.yaml @@ -6,6 +6,9 @@ spec: language: Python displayName: "Python on Kubernetes as a JupyterKernelSpec" image: ccr.ccs.tencentyun.com/kubeflow-oteam/jupyter-kernel-py:2.5.0 + template: + namespace: default + name: jupyterkerneltemplate-sample command: # Use the default scripts to launch the kernel. - "kubeflow-launcher" diff --git a/docs/api/generated.asciidoc b/docs/api/generated.asciidoc index b4e3783..938e245 100644 --- a/docs/api/generated.asciidoc +++ b/docs/api/generated.asciidoc @@ -167,6 +167,8 @@ JupyterKernelSpecSpec defines the desired state of JupyterKernelSpec | *`image`* __string__ | | *`env`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#envvar-v1-core[$$EnvVar$$] array__ | | *`command`* __string array__ | +| *`className`* __string__ | +| *`template`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectreference-v1-core[$$ObjectReference$$]__ | |=== diff --git a/pkg/gateway/generate.go b/pkg/gateway/generate.go index 2c93868..82823c9 100644 --- a/pkg/gateway/generate.go +++ b/pkg/gateway/generate.go @@ -245,6 +245,10 @@ func (g generator) DesiredDeploymentWithoutOwner( }, } + if g.gateway.Spec.Image != "" { + d.Spec.Template.Spec.Containers[0].Image = g.gateway.Spec.Image + } + if g.gateway.Spec.CullIdleTimeout != nil { env := v1.EnvVar{ Name: "EG_CULL_IDLE_TIMEOUT", diff --git a/pkg/kernelspec/generate.go b/pkg/kernelspec/generate.go index b38e0b7..36989f5 100644 --- a/pkg/kernelspec/generate.go +++ b/pkg/kernelspec/generate.go @@ -47,6 +47,9 @@ const ( fileName = "kernel.json" defaultClassName = "enterprise_gateway.services.processproxies.k8s.KubernetesProcessProxy" + + keyKernelTemplateName = "--kernel-template-name" + keyKernelTemplateNamespace = "--kernel-template-namespace" ) // generator defines the generator which is used to generate @@ -109,6 +112,10 @@ func (g generator) desiredJSON() (string, error) { if g.kernelSpec.Spec.ClassName != "" { c.Metadata.ProcessProxy.ClassName = g.kernelSpec.Spec.ClassName } + // Set the namespace and name for the jupyter kernel spec. + c.Argv = append(c.Argv, + keyKernelTemplateName, g.kernelSpec.Spec.Template.Name, + keyKernelTemplateNamespace, g.kernelSpec.Spec.Template.Namespace) v, err := json.Marshal(c) return string(v), err } From 7f912dc64540289ce4bde936b2f82f590550acc9 Mon Sep 17 00:00:00 2001 From: cegao Date: Sat, 8 May 2021 17:14:00 +0800 Subject: [PATCH 13/13] chore: Update API Signed-off-by: cegao --- docs/api/generated.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api/generated.asciidoc b/docs/api/generated.asciidoc index 938e245..1f301e5 100644 --- a/docs/api/generated.asciidoc +++ b/docs/api/generated.asciidoc @@ -86,6 +86,7 @@ JupyterGatewaySpec defines the desired state of JupyterGateway | *`cullIdleTimeout`* __integer__ | Timeout (in seconds) after which a kernel is considered idle and ready to be culled. Values of 0 or lower disable culling. Very short timeouts may result in kernels being culled for users with poor network connections. Ref https://jupyter-notebook.readthedocs.io/en/stable/config.html | *`cullInterval`* __integer__ | The interval (in seconds) on which to check for idle kernels exceeding the cull timeout value. | *`resources`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#resourcerequirements-v1-core[$$ResourceRequirements$$]__ | Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ +| *`image`* __string__ | | *`clusterRole`* __string__ | |===