Skip to content

Commit

Permalink
Cp from kubeflow (kubeflow#5)
Browse files Browse the repository at this point in the history
* update to reflect v3

* always return a rev version

* update to refect changes from kubeflow/kubeflow/bootstrap

* add prow which uses ksonnet, argo_client for now

* remove workflows e2e which just did run-tests

* add tf-operator back
  • Loading branch information
Kam Kasravi authored and k8s-ci-robot committed Aug 10, 2019
1 parent 3ec1c55 commit 17664e3
Show file tree
Hide file tree
Showing 51 changed files with 77,514 additions and 711 deletions.
63 changes: 63 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#**********************************************************************
# Builder
#
# Create a go runtime suitable for building and testing kfctl
ARG GOLANG_VERSION=1.12.7
FROM golang:$GOLANG_VERSION as builder

RUN apt-get update
RUN apt-get install -y git unzip

# junit report is used to conver go test output to junit for reporting
RUN go get -u github.com/jstemmer/go-junit-report

# We need gcloud to get gke credentials.
RUN \
cd /tmp && \
wget -nv https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash && \
chmod +x install_google_cloud_sdk.bash && \
./install_google_cloud_sdk.bash --disable-prompts --install-dir=/opt/

ENV PATH /go/bin:/usr/local/go/bin:/opt/google-cloud-sdk/bin:${PATH}

# use go modules
ENV GO111MODULE=on
ENV GOPATH=/go

# Create kfctl folder
RUN mkdir -p ${GOPATH}/src/github.com/kubeflow/kfctl
WORKDIR ${GOPATH}/src/github.com/kubeflow/kfctl

# Download dependencies first to optimize Docker caching.
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy in the source
COPY . .

#**********************************************************************
#
# kfctl_base
#
FROM builder as kfctl_base

RUN make build-kfctl

#**********************************************************************
#
# Final image base
#

FROM alpine:3.10.1 as barebones_base
RUN mkdir -p /opt/kubeflow
WORKDIR /opt/kubeflow

#**********************************************************************
#
# kfctl
#
FROM barebones_base as kfctl

COPY --from=kfctl_base /go/src/github.com/kubeflow/kfctl/bin/kfctl /usr/local/bin

CMD ["/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait"]
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.
#
GCLOUD_PROJECT ?= kubeflow-images-public
GOLANG_VERSION ?= 1.12
GOLANG_VERSION ?= 1.12.7
GOPATH ?= $(HOME)/go
# To build without the cache set the environment variable
# export DOCKER_BUILD_OPTS=--no-cache
KFCTL_IMG ?= gcr.io/$(GCLOUD_PROJECT)/kfctl
TAG ?= $(eval TAG := $(shell git describe --tags --long))$(TAG)
TAG ?= $(eval TAG := $(shell git describe --tags --long --always))$(TAG)
KFCTL_TARGET ?= kfctl
MOUNT_KUBE ?= -v $(HOME)/.kube:/root/.kube
MOUNT_GCP ?= -v $(HOME)/.config:/root/.config
Expand Down Expand Up @@ -70,12 +70,12 @@ ${GOPATH}/bin/deepcopy-gen:
GO111MODULE=off ${GO} get k8s.io/code-generator/cmd/deepcopy-gen

config/zz_generated.deepcopy.go: config/types.go
${GOPATH}/bin/deepcopy-gen -i github.com/kubeflow/kfctl/v2/config -O zz_generated.deepcopy && \
mv v2/config/zz_generated.deepcopy.go config/ && rm -rf v2
${GOPATH}/bin/deepcopy-gen -i github.com/kubeflow/kfctl/v3/config -O zz_generated.deepcopy && \
mv v3/config/zz_generated.deepcopy.go config/ && rm -rf v3

pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go: pkg/apis/apps/kfdef/v1alpha1/application_types.go
${GOPATH}/bin/deepcopy-gen -i github.com/kubeflow/kfctl/v2/pkg/apis/apps/kfdef/... -O zz_generated.deepcopy && \
mv v2/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go pkg/apis/apps/kfdef/v1alpha1/ && rm -rf v2
${GOPATH}/bin/deepcopy-gen -i github.com/kubeflow/kfctl/v3/pkg/apis/apps/kfdef/... -O zz_generated.deepcopy && \
mv v3/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go pkg/apis/apps/kfdef/v1alpha1/ && rm -rf v3

deepcopy: ${GOPATH}/bin/deepcopy-gen config/zz_generated.deepcopy.go pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go

Expand Down
214 changes: 59 additions & 155 deletions cmd/kfctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
- [Testing kfctl (tests plugin functionality, `kfctl init`, `kfctl generate`)](#testing-kfctl-tests-plugin-functionality-kfctl-init-kfctl-generate)
- [Testing `kfctl init` for all platforms](#testing-kfctl-init-for-all-platforms)
- [Testing `kfctl generate` for all platforms](#testing-kfctl-generate-for-all-platforms)
- [app.yaml example for --platform gcp](#appyaml-example-for---platform-gcp)
- [gcp-click-to-deploy (no changes)](#gcp-click-to-deploy-no-changes)
- [golang modules and versioned packages](#golang-modules-and-versioned-packages)

Expand Down Expand Up @@ -79,41 +78,42 @@ kfctl will statically include platforms that implement the KfApp interface.
These include:

- platform: **minikube**
- bootstrap/v2/pkg/client/minikube/minikube.go
- bootstrap/v3/pkg/client/minikube/minikube.go
- platform: **gcp**
- bootstrap/v2/pkg/client/gcp/gcp.go
- bootstrap/v3/pkg/client/gcp/gcp.go

kfctl also statically links package managers that are used by the platforms.
These include:
This includes:

- package manager: **ksonnet**
- bootstrap/v2/pkg/client/ksonnet/ksonnet.go
- package manager: **kustomize**
- bootstrap/v2/pkg/client/kustomize/kustomize.go
- bootstrap/v3/pkg/client/kustomize/kustomize.go

kfctl can dynamically load platforms and package managers that are not statically linked, as
described below in [Extending kfctl](#extending-kfctl).

## Usage

```kubeflow client tool
Usage:
kfctl [command]
Available Commands:
apply Deploy a generated kubeflow application.
delete Delete a kubeflow application.
generate Generate a kubeflow application where resources is one of 'platform|k8s|all'.
help Help about any command
init Create a kubeflow application under <[path/]name>
show Show a generated kubeflow application.
version Print the version of kfctl.
Flags:
-h, --help help for kfctl
Use "kfctl [command] --help" for more information about a command.
```
A client CLI to create kubeflow applications for specific platforms or 'on-prem'
to an existing k8s cluster.
Usage:
kfctl [command]
Available Commands:
apply Deploy a generated kubeflow application.
completion Generate shell completions
delete Delete a kubeflow application.
generate Generate a kubeflow application where resources is one of 'platform|k8s|all'.
help Help about any command
init Create a kubeflow application under <[path/]name>
show Show a generated kubeflow application.
version Print the version of kfctl.
Flags:
-h, --help help for kfctl
Use "kfctl [command] --help" for more information about a command.
```

Typical use-case, non-platform specific.
Expand All @@ -139,19 +139,27 @@ Usage:
kfctl init <[path/]name> [flags]
Flags:
-h, --help help for init
-n, --namespace string namespace where kubeflow will be deployed (default "kubeflow")
-p, --platform string one of 'gcp|minikube' (default "none")
--project string name of the gcp project if --platform gcp
-r, --repo string local github kubeflow repo
-V, --verbose verbose output default is false
-v, --version string desired version Kubeflow or latest tag if not provided by user (default "master")
--config string Static config file to use. Can be either a local path or a URL.
For example:
--config=https://raw.githubusercontent.com/kubeflow/kubeflow/master/bootstrap/config/kfctl_platform_existing.yaml
--config=kfctl_platform_gcp.yaml
--disable_usage_report disable_usage_report disable anonymous usage reporting.
-h, --help help for init
-n, --namespace string namespace where kubeflow will be deployed (default "kubeflow")
--package-manager string 'kustomize[@version]' (default "kustomize")
-p, --platform string one of 'aws|gcp|minikube'
--project string name of the gcp project if --platform gcp
-r, --repo string local github kubeflow repo
--skip-init-gcp-project Set if you want to skip project initialization. Only meaningful if --platform gcp. Default to false
--use_basic_auth use_basic_auth use basic auth service instead of IAP.
--use_istio use_istio use istio for auth and traffic routing. (default true)
-V, --verbose verbose output default is false
-v, --version string desired version of Kubeflow or master if not specified. Version can be master (eg --version master) or a git tag (eg --version=v0.5.0), or a PR (eg --version pull/<id>). (default "master")
```

### **generate**

(kubeflow/bootstrap/cmd/kfctl/cmd/generate.go)

```
Generate a kubeflow application where resources is one of 'platform|k8s|all'.
Expand All @@ -171,7 +179,7 @@ Flags:
--ipName string ipName if '--platform gcp'
--mount-local mount-local if '--platform minikube'
-V, --verbose verbose output default is false
--zone string zone if '--platform gcp' (default "us-east1-d")```
--zone string zone if '--platform gcp' (default "us-east1-d")
```

### **apply**
Expand All @@ -185,11 +193,21 @@ Usage:
kfctl apply [all(=default)|k8s|platform] [flags]
Flags:
-h, --help help for apply
--oauth_id string OAuth Client ID, GCP only. Required if ENV CLIENT_ID is not set. Value passed will take precedence to ENV.
--oauth_secret string OAuth Client ID, GCP only. Required if ENV CLIENT_SECRET is not set. Value passed will take precedence to ENV.
-V, --verbose verbose output default is false```
-h, --help help for apply
-V, --verbose verbose output default is false
$ ☞
$ ☞
$ ☞
$ ☞
$ ☞ kfctl help apply
Deploy a generated kubeflow application.
Usage:
kfctl apply [all(=default)|k8s|platform] [flags]
Flags:
-h, --help help for apply
-V, --verbose verbose output default is false
```

### **delete**
Expand Down Expand Up @@ -257,125 +275,11 @@ make test-init
make test-generate
```

#### app.yaml example for --platform gcp
```yaml
apiVersion: client.apps.kubeflow.org/v1alpha1
kind: Client
metadata:
creationTimestamp: null
name: gcp
namespace: kubeflow
spec:
appdir: /Users/kdkasrav/go/src/github.com/kubeflow/kfctl/test/gcp
componentParams:
application:
- name: components
value: <list-of-components>
cert-manager:
- initRequired: true
name: acmeEmail
value: gcp-deploy@constant-cubist-173123.iam.gserviceaccount.com
cloud-endpoints:
- name: secretName
value: admin-gcp-sa
iap-ingress:
- initRequired: true
name: ipName
value: gcp-ip
- initRequired: true
name: hostname
value: gcp.endpoints.constant-cubist-173123.cloud.goog
jupyter:
- name: jupyterHubAuthenticator
value: iap
- name: platform
value: gke
pipeline:
- name: mysqlPd
value: gcp-storage-metadata-store
- name: minioPd
value: gcp-storage-artifact-store
components:
- ambassador
- application
- argo
- centraldashboard
- cert-manager
- cloud-endpoints
- iap-ingress
- jupyter
- jupyter-web-app
- katib
- metacontroller
- notebook-controller
- pipeline
- pytorch-operator
- tensorboard
- tf-job-operator
email: gcp-deploy@constant-cubist-173123.iam.gserviceaccount.com
hostname: gcp.endpoints.constant-cubist-173123.cloud.goog
ipName: gcp-ip
packages:
- application
- argo
- common
- examples
- gcp
- jupyter
- katib
- metacontroller
- modeldb
- mpi-job
- pipeline
- pytorch-job
- seldon
- tensorboard
- tf-serving
- tf-training
platform: gcp
project: XXXXXX
repo: /Users/kdkasrav/go/src/github.com/kubeflow/kfctl/test/gcp/.cache/2673/kubeflow
useBasicAuth: false
version: "2673"
zone: us-east1-d
status: {}
```

## gcp-click-to-deploy (no changes)

Ksonnet types have been moved to `github.com/kubeflow/kfctl/v2/pkg/apis/apps/ksonnet/v1alpha1`
References to Ksonnet types have been removed

## golang modules and versioned packages

Both ksonnet and kustomize package managers are loaded as .so's.
(They will be statically linked soon see [#2635](https://github.com/kubeflow/kubeflow/issues/2635))
The complication is that ksonnet and kustomize do not have an overlap of kubernetes versions as well
as client-go, and controller-runtime.

- **ksonnet** (highest version)
- k8s.io/api kubernetes-1.10.4
- k8s.io/apimachinery kubernetes-1.10.4
- k8s.io/client-go v7.0.0
- sigs.k8s.io/controller-runtime v0.1.1

- **kustomize** (cannot downgrade to kubernetes-1.10.4, client-go v7.0.0)
- k8s.io/api kubernetes-1.13.4
- k8s.io/apimachinery kubernetes-1.13.4
- k8s.io/client-go v10.0.0
- sigs.k8s.io/controller-runtime v0.1.10

kustomize leverages golang modules by using 'v2' versions of
the above libraries.

We insert golang package versioning for these libraries despite the fact that kubernetes has yet to move to golang modules. Updating these libraries to use golang modules is straight-forward and can be done using local git clones. Background information on how this is done can be found [here](https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher).

Currently a build artifact was hand built and checked into PR #2548 as bootstrap/hack/v2.zip.
This build artifact holds versioned packages for the above libraries. This hand-built artifact needs to be removed and replaced with a golang tool such as [mod](https://github.com/marwan-at-work/mod) that can do this algorithmically and as part of building kfctl.

The [mod](https://github.com/marwan-at-work/mod) tool needs to be modified in the following ways:
1. Update literal references to versioned packages as found [here](https://github.com/kubernetes/api/blob/kubernetes-1.13.4/apps/v1/generated.pb.go#L62) and [here](https://github.com/kubernetes/api/blob/kubernetes-1.13.4/apps/v1/generated.pb.go#L63).
2. Move a subset of libraries tagged as [+incompatible](https://groups.google.com/forum/#!topic/golang-codereviews/t-xcPhCn3FI) within the go.mod file, instead of all of them.
3. Create a local archive of these versioned packages
4. Update go.mod files that reference the versioned packages with a replace directive pointing to the the local archive location.
5. Do not update the git repos or push changes back to git
kustomize leverages golang modules by declaring a 'v3' version in go.mod

4 changes: 2 additions & 2 deletions cmd/kfctl/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cmd

import (
"fmt"
kftypes "github.com/kubeflow/kfctl/v2/pkg/apis/apps"
"github.com/kubeflow/kfctl/v2/pkg/kfapp/coordinator"
kftypes "github.com/kubeflow/kfctl/v3/pkg/apis/apps"
"github.com/kubeflow/kfctl/v3/pkg/kfapp/coordinator"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
4 changes: 2 additions & 2 deletions cmd/kfctl/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package cmd

import (
"fmt"
kftypes "github.com/kubeflow/kfctl/v2/pkg/apis/apps"
"github.com/kubeflow/kfctl/v2/pkg/kfapp/coordinator"
kftypes "github.com/kubeflow/kfctl/v3/pkg/apis/apps"
"github.com/kubeflow/kfctl/v3/pkg/kfapp/coordinator"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
Loading

0 comments on commit 17664e3

Please sign in to comment.