Documentation ¶
Index ¶
- Constants
- Variables
- func BuildClusterConfig(ctx context.Context, token string, project string, zone string, ...) (*rest.Config, error)
- func CheckProjectAccess(project string, ts oauth2.TokenSource) (bool, error)
- func GetHealthzHandler() http.Handler
- func GetRepoName(project string) string
- func GetRepoNameKfctl(project string) string
- func LoadConfig(path string, o interface{}) error
- func NewGcServer(targetnamespace string) (*gcServer, error)
- func NewKfctlServer(appsDir string) (*kfctlServer, error)
- func NewRouter(c kubeclientset.Interface, image string, namespace string) (*kfctlRouter, error)
- func NewServer(appsDir string, gkeVersionOverride string, installIstio bool) (*ksServer, error)
- func Pformat(value interface{}) (string, error)
- func PrepareAccount(account string) string
- func PrettyPrint(value interface{}) string
- func Run(opt *options.ServerOption) error
- func SaveAppToRepo(email string, repoPath string) error
- func UpdatePolicy(currentPolicy *cloudresourcemanager.Policy, iamConf *IamConf, ...)
- type AppConfigFile
- type ApplyIamRequest
- type BasicAuth
- type C2DRequest
- type CreateResponse
- type DmConf
- type DmSpec
- type EndpointConfig
- type GcService
- type HealthzRequest
- type HealthzResponse
- type IAP
- type IamBinding
- type IamConf
- type InitProjectRequest
- type KfctlClient
- type KfctlServiceV1Beta1
- type KsService
- type LibrarySpec
- type MultiError
- type ProjectAccessChecker
- type RefreshableTokenSource
- type Resource
- type RouterService
- type SourceRepo
- type TokenRefresher
Constants ¶
const AppNameKey = "app-name"
AppNameKey is the name of the label to use containing the name of the kfctl app.
const ArtifactStoreDiskSuffix = "-artifact-store"
const CachedRegistries = "/opt/versioned_registries"
root dir of local cached VERSIONED REGISTRIES
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.
const DmFolder = "gcp_config"
const GcloudPath = "gcloud"
Assume gcloud is on the path.
const IAM_ADMIN_ROLE = "roles/resourcemanager.projectIamAdmin"
const IstioFolder = "istio"
const JupyterPrototype = "jupyterhub"
The name of the prototype for Jupyter.
const K8sSpecPath = "../bootstrap/k8sSpec/v1.11.7/api/openapi-spec/swagger.json"
default k8s spec to use
const KfctlCreatePath = "/kfctl/apps/v1beta1/create"
KfctlCreatePath is the path on which to serve create requests
const KfctlGetpath = "/kfctl/apps/v1beta1/get"
KfctlGetpath is the path on which to query deployment status
const KubeflowFolder = "ks_app"
const LastRequestTime = "LastRequestTime"
LastRequestTime last deploy request time.
const MetadataStoreDiskSuffix = "-metadata-store"
const RecommendedConfigPathEnvVar = "KUBECONFIG"
RecommendedConfigPathEnvVar is a environment variable for path configuration
const RegistriesRoot = "/opt/registries"
const (
RemoteName = "gcpsourcerepo"
)
const StartTime = "StartTime"
key used for storing start time of a request to deploy in the request contexts
Variables ¶
var ClusterDmSpec = DmSpec{
ConfigFile: "../deployment/gke/deployment_manager_configs/cluster-kubeflow.yaml",
TemplateFile: "../deployment/gke/deployment_manager_configs/cluster.jinja",
DmNameSuffix: "",
}
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 GetRepoName ¶
func GetRepoNameKfctl ¶
func NewGcServer ¶
func NewKfctlServer ¶
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 PrepareAccount ¶
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 SaveAppToRepo ¶
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 ¶
AppConfigFile corresponds to a YAML file specifying information about the app to create.
type ApplyIamRequest ¶
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"` 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 EndpointConfig ¶
type EndpointConfig struct { BasicAuth BasicAuth `json:"basicAuth,omitempty"` IAP IAP `json:"iap,omitempty"` }
For GCP cloud endpoint
type HealthzRequest ¶
type HealthzRequest struct {
Msg string
}
type HealthzResponse ¶
type HealthzResponse struct {
Reply string
}
type IamBinding ¶
type IamConf ¶
type IamConf struct {
IamBindings []IamBinding `json:"bindings"`
}
type InitProjectRequest ¶
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 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.
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.