Documentation ¶
Index ¶
- Constants
- Variables
- func AppNameForServiceAccount(sa *core.ServiceAccount) (string, error)
- func BaseKubeCloudOpenParams(cloud cloud.Cloud, credential cloud.Credential) (environs.OpenParams, error)
- func CaasServiceToK8s(in caas.ServiceType) (core.ServiceType, error)
- func CloudSpecToK8sRestConfig(cloudSpec environscloudspec.CloudSpec) (*rest.Config, error)
- func ConfigDefaults() schema.Defaults
- func ConfigSchema() environschema.Fields
- func DecideControllerNamespace(controllerName string) string
- func GetOperatorPodName(podAPI typedcorev1.PodInterface, nsAPI typedcorev1.NamespaceInterface, ...) (string, error)
- func IsClusterQueryError(err error) bool
- func IsNoRecommendedStorageError(err error) bool
- func IsUnknownClusterError(err error) bool
- func MaskError(err error) bool
- func RBACLabels(appName, model string, global, legacy bool) map[string]string
- func RequireOperatorStorage(charmMinJujuVersion version.Number) bool
- func UpdateKubeCloudWithStorage(k8sCloud *cloud.Cloud, storageParams KubeCloudStorageParams) (storageMsg string, err error)
- func ValidateStorageProvider(providerType jujustorage.ProviderType, attributes map[string]interface{}) error
- type CRDGetterInterface
- type ClientConfigFuncGetter
- type ClusterQueryError
- type CommandRunner
- type DockerConfig
- type DockerConfigEntry
- type DockerConfigJSON
- type EventGetter
- type GetClusterMetadataFunc
- type KlogMessagePrefixes
- type KubeCloudParams
- type KubeCloudStorageParams
- type ModelOperatorBroker
- type NewK8sClientFunc
- type NoRecommendedStorageError
- type UnknownClusterError
- type UpgradeCAASControllerBroker
- type UpgradeCAASModelOperatorBroker
- type UpgradeCAASOperatorBroker
Constants ¶
const ( // JujuControllerStackName is the juju CAAS controller stack name. JujuControllerStackName = "controller" // ControllerServiceFQDNTemplate is the FQDN of the controller service using the cluster DNS. ControllerServiceFQDNTemplate = "controller-service.controller-%s.svc.cluster.local" )
const ( // Container event reason list CreatedContainer = "Created" StartedContainer = "Started" FailedToCreateContainer = "Failed" FailedToStartContainer = "Failed" KillingContainer = "Killing" PreemptContainer = "Preempting" BackOffStartContainer = "BackOff" ExceededGracePeriod = "ExceededGracePeriod" // Pod event reason list FailedToKillPod = "FailedKillPod" FailedToCreatePodContainer = "FailedCreatePodContainer" FailedToMakePodDataDirectories = "Failed" NetworkNotReady = "NetworkNotReady" // Image event reason list PullingImage = "Pulling" PulledImage = "Pulled" FailedToPullImage = "Failed" FailedToInspectImage = "InspectFailed" ErrImageNeverPullPolicy = "ErrImageNeverPull" BackOffPullImage = "BackOff" )
Constants below are copied from "k8s.io/kubernetes/pkg/kubelet/events" to avoid introducing the huge dependency. Remove them once k8s.io/kubernetes added as a dependency.
const ( EnvModelAgentCAASServiceName = "SERVICE_NAME" EnvModelAgentCAASServiceNamespace = "SERVICE_NAMESPACE" EnvModelAgentHTTPPort = "HTTP_PORT" OperatorModelTarget = "model" )
const ( PodReasonCompleted = "Completed" PodReasonContainerCreating = "ContainerCreating" PodReasonContainersNotInitialized = "ContainersNotInitialized" PodReasonContainersNotReady = "ContainersNotReady" PodReasonCrashLoopBackoff = "CrashLoopBackOff" PodReasonError = "Error" PodReasonImagePull = "ErrImagePull" PodReasonInitializing = "PodInitializing" )
const ( // InformerResyncPeriod is the default resync period set on IndexInformers InformerResyncPeriod = time.Minute * 5 )
const ( // OperatorAppTarget is the constant used to describe the operator's target // in kubernetes. This allows us to differentiate between different // operators that would possible have the same labels otherwise OperatorAppTarget = "application" )
const (
ServiceTypeConfigKey = "kubernetes-service-type"
)
Variables ¶
var NewK8sClients = func(c *rest.Config) ( k8sClient kubernetes.Interface, apiextensionsclient apiextensionsclientset.Interface, dynamicClient dynamic.Interface, err error, ) { k8sClient, err = kubernetes.NewForConfig(c) if err != nil { return nil, nil, nil, err } apiextensionsclient, err = apiextensionsclientset.NewForConfig(c) if err != nil { return nil, nil, nil, err } dynamicClient, err = dynamic.NewForConfig(c) if err != nil { return nil, nil, nil, err } return k8sClient, apiextensionsclient, dynamicClient, nil }
NewK8sClients returns the k8s clients to access a cluster. Override for testing.
var ( // TemplateFileNameServerPEM is the template server.pem file name. TemplateFileNameServerPEM = "template-" + mongo.FileNameDBSSLKey )
Functions ¶
func AppNameForServiceAccount ¶
func AppNameForServiceAccount(sa *core.ServiceAccount) (string, error)
AppNameForServiceAccount returns the juju application name associated with a given ServiceAccount. If app name cannot be obtained from the service account, errors.NotFound is returned.
func BaseKubeCloudOpenParams ¶
func BaseKubeCloudOpenParams(cloud cloud.Cloud, credential cloud.Credential) (environs.OpenParams, error)
BaseKubeCloudOpenParams provides a basic OpenParams for a cluster
func CaasServiceToK8s ¶
func CaasServiceToK8s(in caas.ServiceType) (core.ServiceType, error)
CaasServiceToK8s translates a caas service type to a k8s one.
func CloudSpecToK8sRestConfig ¶
func CloudSpecToK8sRestConfig(cloudSpec environscloudspec.CloudSpec) (*rest.Config, error)
CloudSpecToK8sRestConfig translates cloudspec to k8s rest config.
func ConfigDefaults ¶
ConfigDefaults returns the default values for a kubernetes configuration.
func ConfigSchema ¶
func ConfigSchema() environschema.Fields
ConfigSchema returns the configuration schema for a kubernetes provider config.
func DecideControllerNamespace ¶
DecideControllerNamespace decides the namespace name to use for a new controller.
func GetOperatorPodName ¶
func GetOperatorPodName( podAPI typedcorev1.PodInterface, nsAPI typedcorev1.NamespaceInterface, appName string, namespace string, ) (string, error)
GetOperatorPodName returns operator pod name for an application.
func IsClusterQueryError ¶
IsClusterQueryError returns true if err is a ClusterQueryError.
func IsNoRecommendedStorageError ¶
IsNoRecommendedStorageError returns true if err is a NoRecommendedStorageError
func IsUnknownClusterError ¶
IsUnknownClusterError returns true if err is a UnknownClusterError
func MaskError ¶
MaskError is used to signify that an error should not be reported back to the caller.
func RBACLabels ¶
RBACLabels returns a set of labels that should be present for RBAC objects.
func RequireOperatorStorage ¶
func RequireOperatorStorage(charmMinJujuVersion version.Number) bool
RequireOperatorStorage returns true if the specified min-juju-version defined by a charm is such that the charm requires operator storage.
func UpdateKubeCloudWithStorage ¶
func UpdateKubeCloudWithStorage(k8sCloud *cloud.Cloud, storageParams KubeCloudStorageParams) (storageMsg string, err error)
UpdateKubeCloudWithStorage updates the passed Cloud with storage details retrieved from the clouds' cluster.
func ValidateStorageProvider ¶
func ValidateStorageProvider(providerType jujustorage.ProviderType, attributes map[string]interface{}) error
ValidateStorageProvider returns an error if the storage type and config is not valid for a Kubernetes deployment.
Types ¶
type CRDGetterInterface ¶
type CRDGetterInterface interface {
Get(string) (*apiextensionsv1.CustomResourceDefinition, error)
}
type ClientConfigFuncGetter ¶
type ClientConfigFuncGetter func(string) (clientconfig.ClientConfigFunc, error)
ClientConfigFuncGetter returns a function returning az reader that will read a k8s cluster config for a given cluster type
type ClusterQueryError ¶
type ClusterQueryError struct {
Message string
}
ClusterQueryError represents an issue when querying a cluster.
func (ClusterQueryError) Error ¶
func (e ClusterQueryError) Error() string
type CommandRunner ¶
type CommandRunner interface {
RunCommands(run exec.RunParams) (*exec.ExecResponse, error)
}
CommandRunner allows to run commands on the underlying system
type DockerConfig ¶
type DockerConfig map[string]DockerConfigEntry
DockerConfig represents the config file used by the docker CLI.
type DockerConfigEntry ¶
DockerConfigEntry represents an Auth entry in the dockerconfigjson.
type DockerConfigJSON ¶
type DockerConfigJSON struct {
Auths DockerConfig `json:"auths"`
}
DockerConfigJSON represents ~/.docker/config.json file info.
type EventGetter ¶
type GetClusterMetadataFunc ¶
type GetClusterMetadataFunc func(KubeCloudStorageParams) (*k8s.ClusterMetadata, error)
GetClusterMetadataFunc returns the ClusterMetadata using the provided ClusterMetadataChecker
type KlogMessagePrefixes ¶
type KlogMessagePrefixes []string
func (KlogMessagePrefixes) Matches ¶
func (k KlogMessagePrefixes) Matches(log string) bool
type KubeCloudParams ¶
type KubeCloudParams struct { ClusterName string ContextName string CloudName string // CredentialUID ensures RBAC resources are unique. CredentialUID string HostCloudRegion string CaasType string ClientConfigGetter ClientConfigFuncGetter Clock jujuclock.Clock }
KubeCloudParams defines the parameters used to extract a k8s cluster definition from kubeconfig data.
type KubeCloudStorageParams ¶
type KubeCloudStorageParams struct { WorkloadStorage string HostCloudRegion string MetadataChecker k8s.ClusterMetadataChecker GetClusterMetadataFunc GetClusterMetadataFunc }
KubeCloudStorageParams defines the parameters used to determine storage details for a k8s cluster.
type ModelOperatorBroker ¶
type ModelOperatorBroker interface { // EnsureConfigMap ensures the supplied kubernetes config map exists in the // targeted cluster. Error returned if this action is not able to be // performed. EnsureConfigMap(*core.ConfigMap) ([]func(), error) // EnsureClusterRole ensures that the provided cluster role exists in the // Kubernetes cluster EnsureClusterRole(*rbac.ClusterRole) ([]func(), error) // EnsureClusterRoleBinding ensures that the provided cluster role binding // exists in the Kubernetes cluster EnsureClusterRoleBinding(*rbac.ClusterRoleBinding) ([]func(), error) // EnsureDeployment ensures the supplied kubernetes deployment object exists // in the targeted cluster. Error returned if this action is not able to be // performed. EnsureDeployment(*apps.Deployment) ([]func(), error) // EnsureRole ensures the supplied kubernetes role object exists in the // targeted clusters namespace EnsureRole(*rbac.Role) ([]func(), error) // EnsureRoleBinding ensures the supplied kubernetes role binding object // exists in the targetes clusters namespace EnsureRoleBinding(*rbac.RoleBinding) ([]func(), error) // EnsureService ensures the spplied kubernetes service object exists in the // targeted cluster. Error returned if the action is not able to be // performed. EnsureService(*core.Service) ([]func(), error) // EnsureServiceAccount ensures the supplied the kubernetes service account // exists in the targets cluster. EnsureServiceAccount(*core.ServiceAccount) ([]func(), error) // Namespace returns the current default namespace targeted by this broker. Namespace() string // IsLegacyLabels indicates if this provider is operating on a legacy label schema IsLegacyLabels() bool }
ModelOperatorBroker defines a broker for Executing Kubernetes ensure commands. This interfaces is scoped down to the exact components needed by the ensure model operator routines.
type NewK8sClientFunc ¶
type NewK8sClientFunc func(c *rest.Config) (kubernetes.Interface, apiextensionsclientset.Interface, dynamic.Interface, error)
NewK8sClientFunc defines a function which returns a k8s client based on the supplied config.
type NoRecommendedStorageError ¶
NoRecommendedStorageError represents when Juju is unable to determine which storage a cluster uses (or should use)
func (NoRecommendedStorageError) Error ¶
func (e NoRecommendedStorageError) Error() string
func (NoRecommendedStorageError) StorageProvider ¶
func (e NoRecommendedStorageError) StorageProvider() string
type UnknownClusterError ¶
UnknownClusterError occurs when the provided cluster is not known to Juju.
func (UnknownClusterError) Error ¶
func (e UnknownClusterError) Error() string
type UpgradeCAASControllerBroker ¶
type UpgradeCAASControllerBroker interface { // Client returns a Kubernetes client associated with the current broker's // cluster Client() kubernetes.Interface // IsLegacyLabels indicates if this provider is operating on a legacy label schema IsLegacyLabels() bool // Namespace returns the targeted Kubernetes namespace for this broker Namespace() string }
UpgradeCAASControllerBroker describes the interface needed for upgrading Juju Kubernetes controllers
type UpgradeCAASModelOperatorBroker ¶
type UpgradeCAASModelOperatorBroker interface { // Client returns a Kubernetes client associated with the current broker's // cluster Client() kubernetes.Interface // IsLegacyLabels indicates if this provider is operating on a legacy label schema IsLegacyLabels() bool // Namespace returns the targeted Kubernetes namespace for this broker Namespace() string }
type UpgradeCAASOperatorBroker ¶
type UpgradeCAASOperatorBroker interface { // Clock provides the clock to use with this broker for time operations Clock() clock.Clock // Client returns a Kubernetes client associated with the current broker's // cluster Client() kubernetes.Interface // Returns the deployment name use for the given application name, supports // finding legacy deployment names if set to True. DeploymentName(string, bool) string // IsLegacyLabels indicates if this provider is operating on a legacy label schema IsLegacyLabels() bool Namespace() string // Operator returns an Operator with current status and life details. Operator(string) (*caas.Operator, error) // OperatorName returns the operator name used for the operator deployment // for the supplied application. OperatorName(string) string }
Source Files ¶
- admissionregistration.go
- application.go
- bootstrap.go
- builtin.go
- cloud.go
- config.go
- configmap.go
- connection.go
- constraints.go
- controller_upgrade.go
- credentials.go
- customresourcedefinitions.go
- daemonset.go
- detectcloud.go
- dockerconfig.go
- errors.go
- events.go
- ingress.go
- init.go
- k8s.go
- klog.go
- labels.go
- metadata.go
- modeloperator.go
- modeloperator_upgrade.go
- namespaces.go
- operator.go
- operator_upgrade.go
- pod.go
- precheck.go
- provider.go
- providerconfig.go
- rbac.go
- resources.go
- secrets.go
- services.go
- statefulsets.go
- storage.go
- teardown.go
- template.go
- typehelper.go
- upgrade.go
- volume.go
Directories ¶
Path | Synopsis |
---|---|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |