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 GetClusterMetadata(ctx context.Context, nominatedStorageClass string, nodeI core.NodeInterface, ...) (*kubernetes.ClusterMetadata, error)
- func GetOperatorPodName(podAPI typedcorev1.PodInterface, nsAPI typedcorev1.NamespaceInterface, ...) (string, error)
- func IsClusterQueryError(err error) bool
- func IsNoRecommendedStorageError(err error) bool
- func MaskError(err error) bool
- func RBACLabels(appName, model string, global, legacy bool) map[string]string
- func RequireOperatorStorage(ch charm.CharmMeta) bool
- func UpdateKubeCloudWithStorage(k8sCloud cloud.Cloud, storageParams KubeCloudStorageParams) (cloud.Cloud, error)
- type CRDGetterInterface
- type ClientConfigFuncGetter
- type ClusterMetadataStorageChecker
- type ClusterQueryError
- type CommandRunner
- type GetClusterMetadataFunc
- type KubeCloudParams
- type KubeCloudStorageParams
- type ModelOperatorBroker
- type NewK8sClientFunc
- type NoRecommendedStorageError
- type UpgradeCAASControllerBroker
- type UpgradeCAASModelOperatorBroker
- type UpgradeCAASOperatorBroker
Constants ¶
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 ( // 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 possibly have the same labels otherwise. OperatorAppTarget = "application" )
const (
ServiceTypeConfigKey = "kubernetes-service-type"
)
Variables ¶
var CheckJujuOfficial = envtools.JujudVersion
For testing.
var (
// ExecRBACResourceName is the model's exec RBAC resource name.
ExecRBACResourceName = "model-exec"
)
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 GetClusterMetadata ¶
func GetClusterMetadata( ctx context.Context, nominatedStorageClass string, nodeI core.NodeInterface, storageClassI storage.StorageClassInterface, ) (*kubernetes.ClusterMetadata, error)
GetClusterMetadata is responsible for gather a Kubernetes cluster metadata for Juju to make decisions. This relates to the cloud the cluster may or may not be running in + storage available. Split out from the main kubernetesClient struct so that it can be tested correctly.
func GetOperatorPodName ¶
func GetOperatorPodName( podAPI typedcorev1.PodInterface, nsAPI typedcorev1.NamespaceInterface, appName, namespace, model 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 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(ch charm.CharmMeta) 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) (cloud.Cloud, error)
UpdateKubeCloudWithStorage updates the passed Cloud with storage details retrieved from the cloud's cluster.
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 ClusterMetadataStorageChecker ¶
type ClusterMetadataStorageChecker interface { k8s.ClusterMetadataChecker ListStorageClasses(selector k8slabels.Selector) ([]storagev1.StorageClass, error) ListPods(namespace string, selector k8slabels.Selector) ([]corev1.Pod, error) }
ClusterMetadataStorageChecker provides functionalities for checking k8s cluster storage and pods details.
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) LookPath(string) (string, error) }
CommandRunner allows to run commands on the underlying system
type GetClusterMetadataFunc ¶
type GetClusterMetadataFunc func(KubeCloudStorageParams) (*k8s.ClusterMetadata, error)
GetClusterMetadataFunc returns the ClusterMetadata using the provided ClusterMetadataChecker
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 { // Client returns the Kubernetes client to use for model operator actions. Client() kubernetes.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) // 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) // Model returns the name of the current model being deployed to for the // broker Model() string // 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 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
- 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
- precheck.go
- provider.go
- providerconfig.go
- rbac.go
- resources.go
- secrets.go
- services.go
- statefulsets.go
- storage.go
- teardown.go
- template.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. |
Package pebble defines constants (probe handlers, health check ports) to be used in Pebble container specs.
|
Package pebble defines constants (probe handlers, health check ports) to be used in Pebble container specs. |
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. |