Documentation ¶
Index ¶
- func CheckClusterVersionSkew(ctx context.Context, userInfoGetter provider.UserInfoGetter, ...) ([]string, error)
- func ConvertInternalEventToExternal(event corev1.Event) apiv1.Event
- func ConvertInternalProjectToExternal(kubermaticProject *kubermaticv1.Project, projectOwners []apiv1.User, ...) *apiv1.Project
- func ConvertInternalSSHKeysToExternal(internalKeys []*kubermaticv1.UserSSHKey) []*apiv1.SSHKey
- func DecodeClusterID(c context.Context, r *http.Request) (string, error)
- func DecodeDcReq(c context.Context, r *http.Request) (interface{}, error)
- func DecodeEmptyReq(c context.Context, r *http.Request) (interface{}, error)
- func DecodeGetClusterReq(c context.Context, r *http.Request) (interface{}, error)
- func DecodeGetProject(c context.Context, r *http.Request) (interface{}, error)
- func DecodeNamespace(c context.Context, r *http.Request) (string, error)
- func DecodeProjectRequest(c context.Context, r *http.Request) (interface{}, error)
- func DecodeSSHKeyID(c context.Context, r *http.Request) (string, error)
- func FilterEventsByType(events []apiv1.Event, eventType string) []apiv1.Event
- func ForwardPort(log *zap.SugaredLogger, forwarder *portforward.PortForwarder) error
- func GetClusterClient(ctx context.Context, userInfoGetter provider.UserInfoGetter, ...) (ctrlruntimeclient.Client, error)
- func GetEvents(ctx context.Context, client ctrlruntimeclient.Client, obj metav1.Object, ...) ([]apiv1.Event, error)
- func GetOwnersForProject(ctx context.Context, userInfo *provider.UserInfo, ...) ([]apiv1.User, error)
- func GetPortForwarder(ctx context.Context, coreClient corev1interface.CoreV1Interface, ...) (*portforward.PortForwarder, chan struct{}, error)
- func GetProject(ctx context.Context, userInfoGetter provider.UserInfoGetter, ...) (*kubermaticv1.Project, error)
- func GetReadyPod(ctx context.Context, client corev1interface.PodInterface, labelSelector string) (*corev1.Pod, error)
- func IsBringYourOwnProvider(spec kubermaticv1.CloudSpec) (bool, error)
- func KubernetesErrorToHTTPError(err error) error
- func WaitForPortForwarder(duration time.Duration, p *portforward.PortForwarder, errChan <-chan error) error
- func WriteHTTPError(log *zap.SugaredLogger, w http.ResponseWriter, err error)
- type CredentialsData
- type DCReq
- type GetClusterReq
- type GetProjectRq
- type OIDCConfiguration
- type ProjectIDGetter
- type ProjectReq
- type ResourceMetricsInfo
- type ServerMetrics
- type SupportManager
- type UpdateManager
- type UserIDGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckClusterVersionSkew ¶
func CheckClusterVersionSkew(ctx context.Context, userInfoGetter provider.UserInfoGetter, clusterProvider provider.ClusterProvider, cluster *kubermaticv1.Cluster, projectID string) ([]string, error)
CheckClusterVersionSkew returns a list of machines and/or machine deployments that are running kubelet at a version incompatible with the cluster's control plane.
func ConvertInternalEventToExternal ¶
ConvertInternalEventToExternal converts Kubernetes Events to Kubermatic ones (used in the API).
func ConvertInternalSSHKeysToExternal ¶
func ConvertInternalSSHKeysToExternal(internalKeys []*kubermaticv1.UserSSHKey) []*apiv1.SSHKey
func DecodeEmptyReq ¶ added in v2.16.3
func DecodeGetClusterReq ¶
func DecodeGetProject ¶
func DecodeNamespace ¶ added in v2.21.0
DecodeNamespace decodes the namespace out of http.Request's path.
func DecodeProjectRequest ¶
func DecodeSSHKeyID ¶ added in v2.16.3
func FilterEventsByType ¶
FilterEventsByType filters Kubernetes Events based on their type. Empty type string will return all of them.
func ForwardPort ¶
func ForwardPort(log *zap.SugaredLogger, forwarder *portforward.PortForwarder) error
func GetClusterClient ¶
func GetClusterClient(ctx context.Context, userInfoGetter provider.UserInfoGetter, clusterProvider provider.ClusterProvider, cluster *kubermaticv1.Cluster, projectID string) (ctrlruntimeclient.Client, error)
func GetEvents ¶
func GetEvents(ctx context.Context, client ctrlruntimeclient.Client, obj metav1.Object, objNamespace string) ([]apiv1.Event, error)
GetEvents returns events related to an object in a given namespace.
func GetOwnersForProject ¶
func GetOwnersForProject(ctx context.Context, userInfo *provider.UserInfo, project *kubermaticv1.Project, memberProvider provider.ProjectMemberProvider, userProvider provider.UserProvider) ([]apiv1.User, error)
func GetPortForwarder ¶
func GetPortForwarder( ctx context.Context, coreClient corev1interface.CoreV1Interface, cfg *rest.Config, namespace string, labelSelector string, containerPort int, ) (*portforward.PortForwarder, chan struct{}, error)
While it is tempting to write our own roundTripper to do all the reading/writing in memory instead of opening a TCP port it has some drawbacks:
- net/http.ReadResponse does not work with websockets, because its body is hardcoded to be an io.ReadCloster and not an io.ReadWriteCloser:
- https://github.com/golang/go/blob/361ab73305788c4bf35359a02d8873c36d654f1b/src/net/http/transfer.go#L550
- https://github.com/golang/go/blob/361ab73305788c4bf35359a02d8873c36d654f1b/src/net/http/httputil/reverseproxy.go#L518
- RoundTripping is a bit more complicated than just read and write, mimicking that badly is likely to be more expensive than doing the extra round via the TCP socket: https://github.com/golang/go/blob/361ab73305788c4bf35359a02d8873c36d654f1b/src/net/http/transport.go#L454
func GetProject ¶
func GetProject(ctx context.Context, userInfoGetter provider.UserInfoGetter, projectProvider provider.ProjectProvider, privilegedProjectProvider provider.PrivilegedProjectProvider, projectID string, options *provider.ProjectGetOptions) (*kubermaticv1.Project, error)
func GetReadyPod ¶
func GetReadyPod(ctx context.Context, client corev1interface.PodInterface, labelSelector string) (*corev1.Pod, error)
GetReadyPod returns a pod matching provided label selector if it is posting ready status, error otherwise. Namespace can be ensured by creating proper PodInterface client.
func IsBringYourOwnProvider ¶
func IsBringYourOwnProvider(spec kubermaticv1.CloudSpec) (bool, error)
IsBringYourOwnProvider determines whether the spec holds BringYourOwn provider.
func KubernetesErrorToHTTPError ¶
kubernetesErrorToHTTPError constructs HTTPError only if the given err is of type *StatusError. Otherwise unmodified err will be returned to the caller.
func WaitForPortForwarder ¶
func WaitForPortForwarder(duration time.Duration, p *portforward.PortForwarder, errChan <-chan error) error
WaitForPortForwarder waits until started port forwarder is ready, or emits an error to provided errChan.
func WriteHTTPError ¶
func WriteHTTPError(log *zap.SugaredLogger, w http.ResponseWriter, err error)
WriteHTTPError writes an http error out. If debug is enabled, it also gets logged.
Types ¶
type CredentialsData ¶
type CredentialsData struct { Ctx context.Context KubermaticCluster *kubermaticv1.Cluster Client ctrlruntimeclient.Client }
func (CredentialsData) Cluster ¶
func (d CredentialsData) Cluster() *kubermaticv1.Cluster
func (CredentialsData) GetGlobalSecretKeySelectorValue ¶
func (d CredentialsData) GetGlobalSecretKeySelectorValue(configVar *providerconfig.GlobalSecretKeySelector, key string) (string, error)
type DCReq ¶
type DCReq struct { ProjectReq // in: path // required: true DC string `json:"dc"` }
DCReq represent a request for datacenter specific data in a given project.
func (DCReq) GetSeedCluster ¶
func (req DCReq) GetSeedCluster() apiv1.SeedCluster
GetSeedCluster returns the SeedCluster object.
type GetClusterReq ¶
type GetClusterReq struct { DCReq // in: path // required: true ClusterID string `json:"cluster_id"` }
GetClusterReq defines HTTP request for deleteCluster and getClusterKubeconfig endpoints swagger:parameters getCluster getClusterKubeconfig getOidcClusterKubeconfig listAWSSizesNoCredentials getClusterHealth getClusterUpgrades getClusterMetrics getClusterNodeUpgrades listGCPZonesNoCredentials listGCPNetworksNoCredentials listAWSZonesNoCredentials listAWSSubnetsNoCredentials listAlibabaInstanceTypesNoCredentials listNamespace
type GetProjectRq ¶
type GetProjectRq struct {
ProjectReq
}
GetProjectRq defines HTTP request for getProject endpoint swagger:parameters getProject getUsersForProject listClustersForProject listServiceAccounts getProjectQuota listGroupProjectBinding
type OIDCConfiguration ¶
type OIDCConfiguration struct { // URL holds OIDC Issuer URL address URL string // ClientID holds OIDC ClientID ClientID string // ClientSecret holds OIDC ClientSecret ClientSecret string // CookieHashKey is required, used to authenticate the cookie value using HMAC // It is recommended to use a key with 32 or 64 bytes. CookieHashKey string // CookieSecureMode if true then cookie received only with HTTPS otherwise with HTTP. CookieSecureMode bool // OfflineAccessAsScope if true then "offline_access" scope will be used // otherwise 'access_type=offline" query param will be passed OfflineAccessAsScope bool }
OIDCConfiguration is a struct that holds OIDC provider configuration data, read from command line arguments.
type ProjectIDGetter ¶
type ProjectIDGetter interface {
GetProjectID() string
}
ProjectIDGetter knows how to get project ID from the request.
type ProjectReq ¶
type ProjectReq struct { // in: path // required: true ProjectID string `json:"project_id"` }
ProjectReq represents a request for project-specific data.
func (ProjectReq) GetProjectID ¶
func (pr ProjectReq) GetProjectID() string
GetProjectID returns the ID of a requested project.
type ResourceMetricsInfo ¶
type ResourceMetricsInfo struct { Name string Metrics corev1.ResourceList Available corev1.ResourceList }
ResourceMetricsInfo is a struct that holds the node metrics.
type ServerMetrics ¶
type ServerMetrics struct { HTTPRequestsTotal *prometheus.CounterVec HTTPRequestsDuration *prometheus.HistogramVec InitNodeDeploymentFailures *prometheus.CounterVec }
ServerMetrics defines metrics used by the API.
type SupportManager ¶ added in v2.18.0
type SupportManager interface {
GetIncompatibilities() []*version.ProviderIncompatibility
}
type UpdateManager ¶
type UpdateManager interface { GetVersions() ([]*version.Version, error) GetVersionsForProvider(kubermaticv1.ProviderType, ...kubermaticv1.ConditionType) ([]*version.Version, error) GetDefault() (*version.Version, error) GetPossibleUpdates(from string, provider kubermaticv1.ProviderType, condition ...kubermaticv1.ConditionType) ([]*version.Version, error) }
UpdateManager specifies a set of methods to handle cluster versions & updates.
type UserIDGetter ¶
type UserIDGetter interface {
GetUserID() string
}
UserIDGetter knows how to get user ID from the request.