Skip to content

Commit

Permalink
enable test for v1alpha2 (#465)
Browse files Browse the repository at this point in the history
* enable test for v1alpha2

* add KATIB-CORE-NAMESPACE env for controller

* update example filed

* share same image for two version controller

* add status in subresources of crd
  • Loading branch information
hougangliu authored and k8s-ci-robot committed Apr 26, 2019
1 parent bc57a6d commit 78a4563
Show file tree
Hide file tree
Showing 31 changed files with 1,478 additions and 10 deletions.
59 changes: 59 additions & 0 deletions examples/v1alpha2/random-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: "kubeflow.org/v1alpha2"
kind: Experiment
metadata:
namespace: kubeflow
name: random-experiment
spec:
parallelTrialCount: 3
maxTrialCount: 12
maxFailedTrialCount: 3
objective:
type: maximize
goal: 0.99
objectiveMetricName: Validation-accuracy
additionalMetricsNames:
- accuracy
algorithm:
algorithmName: random
trialTemplate:
goTemplate:
rawTemplate: |-
apiVersion: batch/v1
kind: Job
metadata:
name: {{.Trial}}
namespace: {{.NameSpace}}
spec:
template:
spec:
containers:
- name: {{.Trial}}
image: katib/mxnet-mnist-example
command:
- "python"
- "/mxnet/example/image-classification/train_mnist.py"
- "--batch-size=64"
{{- with .HyperParameters}}
{{- range .}}
- "{{.Name}}={{.Value}}"
{{- end}}
{{- end}}
restartPolicy: Never
parameters:
- name: --lr
parameterType: double
feasibleSpace:
min: "0.01"
max: "0.03"
- name: --num-layers
parameterType: int
feasibleSpace:
min: "2"
max: "5"
- name: --optimizer
parameterType: categorical
feasibleSpace:
list:
- sgd
- adam
- ftrl
4 changes: 4 additions & 0 deletions manifests/v1alpha2/0-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: kubeflow
29 changes: 29 additions & 0 deletions manifests/v1alpha2/katib-controller/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: experiments.kubeflow.org
spec:
group: kubeflow.org
version: v1alpha2
scope: Namespaced
subresources:
status: {}
names:
kind: Experiment
singular: experiment
plural: experiments
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: trials.kubeflow.org
spec:
group: kubeflow.org
version: v1alpha2
scope: Namespaced
subresources:
status: {}
names:
kind: Trial
singular: trial
plural: trials
32 changes: 32 additions & 0 deletions manifests/v1alpha2/katib-controller/katib-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: katib-controller
namespace: kubeflow
labels:
app: katib-controller
spec:
replicas: 1
selector:
matchLabels:
app: katib-controller
template:
metadata:
labels:
app: katib-controller
spec:
serviceAccountName: katib-controller
containers:
- name: katib-controller
image: katib/katib-controller
imagePullPolicy: Always
command: ["./katib-controller.v1alpha2"]
ports:
- containerPort: 443
name: webhook
protocol: TCP
env:
- name: KATIB_CORE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
77 changes: 77 additions & 0 deletions manifests/v1alpha2/katib-controller/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: katib-controller
rules:
- apiGroups:
- ""
resources:
- configmaps
- serviceaccounts
- services
verbs:
- "*"
- apiGroups:
- ""
resources:
- pods
- pods/log
- pods/status
verbs:
- "*"
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- "*"
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- create
- get
- apiGroups:
- admissionregistration.k8s.io
resources:
- validatingwebhookconfigurations
- mutatingwebhookconfigurations
verbs:
- '*'
- apiGroups:
- kubeflow.org
resources:
- experiments
- experiments/status
- trials
- trials/status
verbs:
- "*"
- apiGroups:
- kubeflow.org
resources:
- tfjobs
- pytorchjobs
verbs:
- "*"
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: katib-controller
namespace: kubeflow
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: katib-controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: katib-controller
subjects:
- kind: ServiceAccount
name: katib-controller
namespace: kubeflow
12 changes: 12 additions & 0 deletions manifests/v1alpha2/katib-controller/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: katib-controller
namespace: kubeflow
spec:
ports:
- port: 443
protocol: TCP
targetPort: 443
selector:
app: katib-controller
20 changes: 20 additions & 0 deletions manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: trial-template
namespace: kubeflow
data:
defaultTrialTemplate.yaml : |-
apiVersion: batch/v1
kind: Job
metadata:
name: {{.Trial}}
namespace: {{.NameSpace}}
spec:
template:
spec:
containers:
- name: {{.Trial}}
image: alpine
restartPolicy: Never
30 changes: 26 additions & 4 deletions prow_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# see kubeflow/testing/py/run_e2e_workflow.py
workflows:
- app_dir: kubeflow/katib/test/workflows
component: workflows
name: e2e
component: workflows-v1alpha1
name: e2e-v1alpha1
job_types:
- presubmit
include_dirs:
Expand All @@ -14,8 +14,8 @@ workflows:
registry: "gcr.io/kubeflow-ci"
# The postsubmit run publishes the docker images to gcr.io/kubeflow-images-public
- app_dir: kubeflow/katib/test/workflows
component: workflows
name: e2e-release
component: workflows-v1alpha1
name: e2e-v1alpha1-release
job_types:
- postsubmit
include_dirs:
Expand All @@ -24,3 +24,25 @@ workflows:
- test/*
params:
registry: "gcr.io/kubeflow-images-public"
- app_dir: kubeflow/katib/test/workflows
component: workflows-v1alpha2
name: e2e-v1alpha2
job_types:
- presubmit
include_dirs:
- pkg/*
- cmd/*
- test/*
params:
registry: "gcr.io/kubeflow-ci"
- app_dir: kubeflow/katib/test/workflows
component: workflows-v1alpha2
name: e2e-v1alpha2-release
job_types:
- postsubmit
include_dirs:
- pkg/*
- cmd/*
- test/*
params:
registry: "gcr.io/kubeflow-images-public"
28 changes: 28 additions & 0 deletions scripts/v1alpha2/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Copyright 2018 The Kubeflow Authors.
#
# 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.

set -o errexit
set -o nounset
set -o pipefail

PREFIX="katib"
CMD_PREFIX="cmd"

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/../..

cd ${SCRIPT_ROOT}

docker build -t ${PREFIX}/katib-controller -f ${CMD_PREFIX}/katib-controller/Dockerfile .
31 changes: 31 additions & 0 deletions scripts/v1alpha2/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright 2018 The Kubeflow Authors.
#
# 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.

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/../..

cd ${SCRIPT_ROOT}
kubectl apply -f manifests/v1alpha2/0-namespace.yaml
kubectl apply -f manifests/v1alpha2/katib-controller/crds.yaml
kubectl apply -f manifests/v1alpha2/katib-controller/rbac.yaml
kubectl apply -f manifests/v1alpha2/katib-controller/service.yaml
kubectl apply -f manifests/v1alpha2/katib-controller/trialTemplateConfigmap.yaml
kubectl apply -f manifests/v1alpha2/katib-controller/katib-controller.yaml
cd - > /dev/null
44 changes: 44 additions & 0 deletions test/scripts/v1alpha2/build-earlystopping-median.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Copyright 2018 The Kubeflow Authors.
#
# 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.

# This shell script is used to build an image from our argo workflow

exit 0

set -o errexit
set -o nounset
set -o pipefail

export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH}
REGISTRY="${GCP_REGISTRY}"
PROJECT="${GCP_PROJECT}"
GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-earlystopping-median
VERSION=$(git describe --tags --always --dirty)

echo "Activating service-account"
gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}

echo "Copy source to GOPATH"
mkdir -p ${GO_DIR}
cp -r cmd ${GO_DIR}/cmd
cp -r pkg ${GO_DIR}/pkg
cp -r vendor ${GO_DIR}/vendor

cd ${GO_DIR}

cp cmd/earlystopping/medianstopping/Dockerfile .
gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:${VERSION} --project=${PROJECT}
gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:${VERSION} ${REGISTRY}/${REPO_NAME}/earlystopping-medianstopping:latest --verbosity=info
Loading

0 comments on commit 78a4563

Please sign in to comment.