app

package
v3.0.0-...-e5452b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

View Source
const AppNameKey = "app-name"

AppNameKey is the name of the label to use containing the name of the kfctl app.

View Source
const ArtifactStoreDiskSuffix = "-artifact-store"
View Source
const CachedRegistries = "/opt/versioned_registries"

root dir of local cached VERSIONED REGISTRIES

View Source
const DefaultStorageAnnotation = "storageclass.beta.kubernetes.io/is-default-class"

DefaultStorageAnnotation is the Name of the default annotation used to indicate whether a storage class is the default.

View Source
const DmFolder = "gcp_config"
View Source
const GcloudPath = "gcloud"

Assume gcloud is on the path.

View Source
const IAM_ADMIN_ROLE = "roles/resourcemanager.projectIamAdmin"
View Source
const IstioFolder = "istio"
View Source
const JupyterPrototype = "jupyterhub"

The name of the prototype for Jupyter.

View Source
const K8sSpecPath = "../bootstrap/k8sSpec/v1.11.7/api/openapi-spec/swagger.json"

default k8s spec to use

View Source
const KfctlCreatePath = "/kfctl/apps/v1beta1/create"

KfctlCreatePath is the path on which to serve create requests

View Source
const KfctlGetpath = "/kfctl/apps/v1beta1/get"

KfctlGetpath is the path on which to query deployment status

View Source
const KubeflowFolder = "ks_app"
View Source
const LastRequestTime = "LastRequestTime"

LastRequestTime last deploy request time.

View Source
const MetadataStoreDiskSuffix = "-metadata-store"
View Source
const RecommendedConfigPathEnvVar = "KUBECONFIG"

RecommendedConfigPathEnvVar is a environment variable for path configuration

View Source
const RegistriesRoot = "/opt/registries"
View Source
const (
	RemoteName = "gcpsourcerepo"
)
View Source
const StartTime = "StartTime"

key used for storing start time of a request to deploy in the request contexts

Variables

View Source
var ClusterDmSpec = DmSpec{
	ConfigFile:   "../deployment/gke/deployment_manager_configs/cluster-kubeflow.yaml",
	TemplateFile: "../deployment/gke/deployment_manager_configs/cluster.jinja",
	DmNameSuffix: "",
}
View Source
var StorageDmSpec = DmSpec{
	ConfigFile:   "../deployment/gke/deployment_manager_configs/storage-kubeflow.yaml",
	TemplateFile: "../deployment/gke/deployment_manager_configs/storage.jinja",
	DmNameSuffix: "-storage",
}

Functions

func BuildClusterConfig

func BuildClusterConfig(ctx context.Context, token string, project string, zone string,
	clusterID string) (*rest.Config, error)

BuildClusterConfig creates a Kubernetes rest config. TODO(jlewi): This is a duplicate of BuildClusterConfig defined in v2/pkgs/utils/k8sAUth.go. When I tried to use that method I ran into problems because here we are using "k8s.io/client-go/v2/rest" and that code is using "k8s.io/client-go/rest"; duplicating the code was a quick hack. I think this might go away once we remove ksonnet since then we can use a single version of the go client library.

func CheckProjectAccess

func CheckProjectAccess(project string, ts oauth2.TokenSource) (bool, error)

CheckProjectAccess verifies whether the supplied token provides access to the indicated project. A false could indicate the credential provides insufficient privileges or is expired

TODO(jlewi): Add a unittest using https://onsi.github.io/gomega/#ghttp-testing-http-clients

func GetHealthzHandler

func GetHealthzHandler() http.Handler

func GetRepoName

func GetRepoName(project string) string

func GetRepoNameKfctl

func GetRepoNameKfctl(project string) string

func LoadConfig

func LoadConfig(path string, o interface{}) error

Load yaml config

func NewGcServer

func NewGcServer(targetnamespace string) (*gcServer, error)

func NewKfctlServer

func NewKfctlServer(appsDir string) (*kfctlServer, error)

NewServer returns a new kfctl server

func NewRouter

func NewRouter(c kubeclientset.Interface, image string, namespace string) (*kfctlRouter, error)

NewRouter returns a new router

func NewServer

func NewServer(appsDir string, gkeVersionOverride string, installIstio bool) (*ksServer, error)

NewServer constructs a ksServer.

func Pformat

func Pformat(value interface{}) (string, error)

Pformat returns a pretty format output of any value.

func PrepareAccount

func PrepareAccount(account string) string

func PrettyPrint

func PrettyPrint(value interface{}) string

PrettyPrint returns a pretty format output of any value. TODO(jlewi): Duplicates code in pkg/utils to avoid circular dependencies need to fix that.

func Run

func Run(opt *options.ServerOption) error

Run the application.

func SaveAppToRepo

func SaveAppToRepo(email string, repoPath string) error

Save ks app config local changes to project source repo. Not thread safe, be aware when call it.

func UpdatePolicy

func UpdatePolicy(currentPolicy *cloudresourcemanager.Policy, iamConf *IamConf, req ApplyIamRequest)

Types

type AppConfigFile

type AppConfigFile struct {
	// App describes a ksonnet application.
	App kstypes.AppConfig
}

AppConfigFile corresponds to a YAML file specifying information about the app to create.

type ApplyIamRequest

type ApplyIamRequest struct {
	Project string `json:"project"`
	Cluster string `json:"cluster"`
	Email   string `json:"email"`
	Token   string `json:"token"`
	Action  string `json:"action"`
}

type BasicAuth

type BasicAuth struct {
	Username string `json:"username,omitempty"`
	// Encoded password
	Password string `json:"password,omitempty"`
}

type C2DRequest

type C2DRequest struct {
	//ConfigFile URL
	ConfigFile string `json:"configFile,omitempty"`

	// GCP Project Id
	Project string `json:"project,omitempty"`

	// deploy Name
	Name string `json:"name,omitempty"`

	// user email
	Email string `json:"email,omitempty"`

	EndpointConfig EndpointConfig `json:"endpointConfig,omitempty"`

	// GKE Zone
	Zone string `json:"zone,omitempty"`

	// kubeflow Version
	Version string `json:"version,omitempty"`

	ShareAnonymousUsage bool `json:"shareAnonymousUsage,omitempty"`

	SkipInitProject bool `json:"skipInitProject,omitempty"`

	// Temporary service account access Token
	Token string `json:"token,omitempty"`
}

C2DRequest is the request body from click to deploy frontend

type CreateResponse

type CreateResponse struct {
}

CreateResponse collects the response for create request.

type DmConf

type DmConf struct {
	Imports   interface{} `json:"imports"`
	Resources []Resource  `json:"resources"`
}

type DmSpec

type DmSpec struct {
	// path to the deployment manager configuration file
	ConfigFile string
	// path to the deployment manager template file
	TemplateFile string
	// the suffix to append to the deployment name
	DmNameSuffix string
}

type EndpointConfig

type EndpointConfig struct {
	BasicAuth BasicAuth `json:"basicAuth,omitempty"`
	IAP       IAP       `json:"iap,omitempty"`
}

For GCP cloud endpoint

type GcService

type GcService interface {
	StartGC() error
}

type HealthzRequest

type HealthzRequest struct {
	Msg string
}

type HealthzResponse

type HealthzResponse struct {
	Reply string
}

type IAP

type IAP struct {
	OAuthClientId     string `json:"oAuthClientId,omitempty"`
	OAuthClientSecret string `json:"oAuthClientSecret,omitempty"`
}

type IamBinding

type IamBinding struct {
	Members []string `type:"members"`
	Roles   []string `type:"roles"`
}

type IamConf

type IamConf struct {
	IamBindings []IamBinding `json:"bindings"`
}

type InitProjectRequest

type InitProjectRequest struct {
	Project       string
	ProjectNumber string
	Token         string
}

type KfctlClient

type KfctlClient struct {
	// contains filtered or unexported fields
}

KfctlClient provides a client to the KfctlServer

func NewKfctlClient

func NewKfctlClient(instance string) (*KfctlClient, error)

NewKfctlClient returns a KfctlClient backed by an HTTP server living at the remote instance.

func (*KfctlClient) CreateDeployment

func (c *KfctlClient) CreateDeployment(ctx context.Context, req C2DRequest) (*kfdefsv1beta1.KfDef, error)

CreateDeployment issues a CreateDeployment to the requested backend

func (*KfctlClient) GetLatestKfDef

func (c *KfctlClient) GetLatestKfDef(req kfdefsv1beta1.KfDef) (*kfdefsv1beta1.KfDef, error)

type KfctlServiceV1Beta1

type KfctlServiceV1Beta1 interface {
	// CreateCreateDeployment creates a Kubeflow deployment
	CreateDeployment(context.Context, kfdefsv1beta1.KfDef) (*kfdefsv1beta1.KfDef, error)
	// GetLatestKfdef returns latest KfDef copy which include deployment status
	GetLatestKfDef(kfdefsv1beta1.KfDef) (*kfdefsv1beta1.KfDef, error)
}

type KsService

type KsService interface {
	// Apply ksonnet app to target GKE cluster
	BindRole(context.Context, string, string, string) error
	ApplyIamPolicy(context.Context, ApplyIamRequest) error
	GetProjectLock(string) *sync.Mutex
}

KsService defines an interface for working with ksonnet.

type LibrarySpec

type LibrarySpec struct {
	Version string
	Path    string
}

type MultiError

type MultiError struct {
	Errors []error
}

func (*MultiError) Collect

func (m *MultiError) Collect(err error)

func (MultiError) ToError

func (m MultiError) ToError() error

type ProjectAccessChecker

type ProjectAccessChecker func(string, oauth2.TokenSource) (bool, error)

ProjectAccessChecker defines a func that can be used to check project access

type RefreshableTokenSource

type RefreshableTokenSource struct {
	// contains filtered or unexported fields
}

RefreshableTokenSource is a static oauth token source that provides methods for refreshing the static token. The point of this token source is to allow a token to be refreshed by HTTP calls.

It is designed to be thread safe and to implement the TokenSource interface.

The TokenSource is scoped to a particular project which is set on construction.

On refresh we do an IAM check to make sure the new credential has access to the same project.

func NewRefreshableTokenSource

func NewRefreshableTokenSource(p string) (*RefreshableTokenSource, error)

NewRefreshableTokenSource creates a new RefreshableTokenSource.

func (*RefreshableTokenSource) Refresh

func (s *RefreshableTokenSource) Refresh(newToken oauth2.Token) error

func (*RefreshableTokenSource) Token

func (s *RefreshableTokenSource) Token() (*oauth2.Token, error)

type Resource

type Resource struct {
	Name       string                 `json:"name"`
	Type       string                 `json:"type"`
	Properties map[string]interface{} `json:"properties"`
}

type RouterService

type RouterService interface {
	// CreateCreateDeployment creates a Kubeflow deployment
	CreateDeployment(context.Context, C2DRequest) (*kfdefs.KfDef, error)
}

KfctlService defines an interface for deploying Kubeflow using kfctl. TODO(jlewi): This will likely need to change or be replaced when we migrate to the new API. https://github.com/kubeflow/kubeflow/tree/master/bootstrap/api. Currently this is just a skeleton for implementing the router. Depending on how we stage that change this will likely need to change.

https://github.com/kubeflow/kubeflow/pull/3045 is pending and contains changes to use kfctl to deploy from the backend.

type SourceRepo

type SourceRepo struct {
	// contains filtered or unexported fields
}

SourceRepo manages a local clone of a source repo.

func NewSourceRepo

func NewSourceRepo(ctx context.Context, project string, localDir string, repoName string, ts oauth2.TokenSource) (*SourceRepo, error)

NewSourceRepo initializes a repo object for the specified local directory. If the directory doesn't exist an error is raised.

If the remote repo doesn't exist it is created.

TODO(jlewi): What if the repo exists but the directory doesn't? In that case should we clone the repo to the local directory? What if the local directory exists but the repo doesn't?

In the current use cases with kfctl server the directory will always exist because it is created out of band by the kfctl server. So for now the code only handles the case where the repository exists.

func (*SourceRepo) CommitAndPushRepo

func (s *SourceRepo) CommitAndPushRepo(email string) error

CommitAndPush repo commits any changes and pushes them.

Not thread safe, be aware when call it.

func (*SourceRepo) Name

func (s *SourceRepo) Name() string

Name returns the name of the repository as expected by Google APIs.

type TokenRefresher

type TokenRefresher interface {
	Refresh(newToken oauth2.Token) error
	Token() (*oauth2.Token, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL