kube_operator

package
v0.0.0-...-1a4049b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ANAX_NAMESPACE = "openhorizon-agent"
	// Name for the env var config map. Only characters allowed: [a-z] "." and "-"
	HZN_ENV_VARS = "hzn-env-vars"
	// Variable that contains the name of the config map
	HZN_ENV_KEY = "HZN_ENV_VARS"
	// Name for the k8s secrets that contains service secrets. Only characters allowed: [a-z] "." and "-"
	HZN_SERVICE_SECRETS = "hzn-service-secrets"

	SECRETS_VOLUME_NAME = "service-secrets-vol"

	MMS_VOLUME_NAME = "mms-shared-storage"

	K8S_CLUSTER_ROLE_TYPE          = "ClusterRole"
	K8S_CLUSTER_ROLEBINDING_TYPE   = "ClusterRoleBinding"
	K8S_ROLE_TYPE                  = "Role"
	K8S_ROLEBINDING_TYPE           = "RoleBinding"
	K8S_DEPLOYMENT_TYPE            = "Deployment"
	K8S_SERVICEACCOUNT_TYPE        = "ServiceAccount"
	K8S_CRD_TYPE                   = "CustomResourceDefinition"
	K8S_NAMESPACE_TYPE             = "Namespace"
	K8S_UNSTRUCTURED_TYPE          = "Unstructured"
	K8S_OLM_OPERATOR_GROUP_TYPE    = "OperatorGroup"
	K8S_MMS_SHARED_PVC_NAME        = "mms-shared-storage-pvc"
	STORAGE_CLASS_USERINPUT_NAME   = "MMS_K8S_STORAGE_CLASS"
	PVC_SIZE_USERINPUT_NAME        = "MMS_K8S_STORAGE_SIZE"
	PVC_ACCESS_MODE_USERINPUT_NAME = "MMS_K8S_PVC_ACCESS_MODE"
	DEFAULT_PVC_SIZE_IN_STRING     = "10"
)

Variables

This section is empty.

Functions

func IsBaseK8sType

func IsBaseK8sType(kind string) bool

func IsDangerType

func IsDangerType(kind string) bool

func NewCRDV1Client

func NewCRDV1Client() (*apiv1client.ApiextensionsV1Client, error)

--------Version v1-------- NewCRDV1Client returns a client that can be used to interact with custom resource definitions in the cluster

func NewCRDV1beta1Client

func NewCRDV1beta1Client() (*apiv1beta1client.ApiextensionsV1beta1Client, error)

--------Version v1beta1-------- NewCRDV1beta1Client returns the client needed to create a CRD in the cluster

func NewDynamicKubeClient

func NewDynamicKubeClient() (dynamic.Interface, error)

NewDynamicKubeClient returns a kube client that interacts with unstructured.Unstructured type objects

func ProcessDeployment

func ProcessDeployment(tar string, metadata map[string]interface{}, envVars map[string]string, fssAuthFilePath string, fssCertFilePath string, secretsMap map[string]string, agId string, crInstallTimeout int64) (map[string][]APIObjectInterface, string, error)

processDeployment takes the deployment string and converts it to a map with the k8s objects, the namespace to be used, and an error if one occurs

Types

type APIObjectInterface

type APIObjectInterface interface {
	Install(c KubeClient, namespace string) error
	Uninstall(c KubeClient, namespace string)
	Status(c KubeClient, namespace string) (interface{}, error)
	Update(c KubeClient, namespace string) error
	Name() string
	Namespace() string
}

type APIObjects

type APIObjects struct {
	Type   *schema.GroupVersionKind
	Object interface{}
}

Intermediate state for the objects used for k8s api objects that haven't had their exact type asserted yet

type ClusterRoleRbacV1

type ClusterRoleRbacV1 struct {
	ClusterRoleObject *rbacv1.ClusterRole
}

func (ClusterRoleRbacV1) Install

func (cr ClusterRoleRbacV1) Install(c KubeClient, namespace string) error

func (ClusterRoleRbacV1) Name

func (cr ClusterRoleRbacV1) Name() string

func (ClusterRoleRbacV1) Namespace

func (cr ClusterRoleRbacV1) Namespace() string

func (ClusterRoleRbacV1) Status

func (cr ClusterRoleRbacV1) Status(c KubeClient, namespace string) (interface{}, error)

func (ClusterRoleRbacV1) Uninstall

func (cr ClusterRoleRbacV1) Uninstall(c KubeClient, namespace string)

func (ClusterRoleRbacV1) Update

func (cr ClusterRoleRbacV1) Update(c KubeClient, namespace string) error

type ClusterRolebindingRbacV1

type ClusterRolebindingRbacV1 struct {
	ClusterRolebindingObject *rbacv1.ClusterRoleBinding
}

----------------ClusterRolebinding----------------

func (ClusterRolebindingRbacV1) Install

func (crb ClusterRolebindingRbacV1) Install(c KubeClient, namespace string) error

func (ClusterRolebindingRbacV1) Name

func (crb ClusterRolebindingRbacV1) Name() string

func (ClusterRolebindingRbacV1) Namespace

func (crb ClusterRolebindingRbacV1) Namespace() string

func (ClusterRolebindingRbacV1) Status

func (crb ClusterRolebindingRbacV1) Status(c KubeClient, namespace string) (interface{}, error)

func (ClusterRolebindingRbacV1) Uninstall

func (crb ClusterRolebindingRbacV1) Uninstall(c KubeClient, namespace string)

func (ClusterRolebindingRbacV1) Update

func (crb ClusterRolebindingRbacV1) Update(c KubeClient, namespace string) error

type ContainerStatus

type ContainerStatus struct {
	Name        string
	Image       string
	CreatedTime int64
	State       string
}

type CustomResourceV1

type CustomResourceV1 struct {
	CustomResourceDefinitionObject *crdv1.CustomResourceDefinition
	CustomResourceObjectList       []*unstructured.Unstructured
	InstallTimeout                 int64
}

func (CustomResourceV1) Install

func (cr CustomResourceV1) Install(c KubeClient, namespace string) error

func (CustomResourceV1) Name

func (cr CustomResourceV1) Name() string

func (CustomResourceV1) Namespace

func (cr CustomResourceV1) Namespace() string

func (CustomResourceV1) Status

func (cr CustomResourceV1) Status(c KubeClient, namespace string) (interface{}, error)

Status returns the status of the operator's service pod. This is a user-defined object

func (CustomResourceV1) Uninstall

func (cr CustomResourceV1) Uninstall(c KubeClient, namespace string)

func (CustomResourceV1) Update

func (cr CustomResourceV1) Update(c KubeClient, namespace string) error

type CustomResourceV1Beta1

type CustomResourceV1Beta1 struct {
	CustomResourceDefinitionObject *crdv1beta1.CustomResourceDefinition
	CustomResourceObjectList       []*unstructured.Unstructured
	InstallTimeout                 int64
}

func (CustomResourceV1Beta1) Install

func (cr CustomResourceV1Beta1) Install(c KubeClient, namespace string) error

func (CustomResourceV1Beta1) Name

func (cr CustomResourceV1Beta1) Name() string

func (CustomResourceV1Beta1) Namespace

func (cr CustomResourceV1Beta1) Namespace() string

func (CustomResourceV1Beta1) Status

func (cr CustomResourceV1Beta1) Status(c KubeClient, namespace string) (interface{}, error)

Status returns the status of the operator's service pod. This is a user-defined object

func (CustomResourceV1Beta1) Uninstall

func (cr CustomResourceV1Beta1) Uninstall(c KubeClient, namespace string)

func (CustomResourceV1Beta1) Update

func (cr CustomResourceV1Beta1) Update(c KubeClient, namespace string) error

type DeploymentAppsV1

type DeploymentAppsV1 struct {
	DeploymentObject *appsv1.Deployment
	EnvVarMap        map[string]string
	FssAuthFilePath  string
	FssCertFilePath  string
	ServiceSecrets   map[string]string
	AgreementId      string
}

func (DeploymentAppsV1) Install

func (d DeploymentAppsV1) Install(c KubeClient, namespace string) error

func (DeploymentAppsV1) Name

func (d DeploymentAppsV1) Name() string

func (DeploymentAppsV1) Namespace

func (d DeploymentAppsV1) Namespace() string

func (DeploymentAppsV1) Status

func (d DeploymentAppsV1) Status(c KubeClient, namespace string) (interface{}, error)

Status will be the status of the operator pod

func (DeploymentAppsV1) Uninstall

func (d DeploymentAppsV1) Uninstall(c KubeClient, namespace string)

func (DeploymentAppsV1) Update

func (d DeploymentAppsV1) Update(c KubeClient, namespace string) error

type InstallCommand

type InstallCommand struct {
	LaunchContext interface{}
}

func NewInstallCommand

func NewInstallCommand(launchContext interface{}) *InstallCommand

func (InstallCommand) ShortString

func (i InstallCommand) ShortString() string

type KubeClient

type KubeClient struct {
	Client            *kubernetes.Clientset
	DynClient         dynamic.Interface
	OLMV1Alpha1Client olmv1alpha1client.OperatorsV1alpha1Client
	OLMV1Client       olmv1client.OperatorsV1Client
}

Client to interact with all standard k8s objects

func NewKubeClient

func NewKubeClient() (*KubeClient, error)

func (KubeClient) CreateConfigMap

func (c KubeClient) CreateConfigMap(envVars map[string]string, agId string, namespace string) (string, error)

CreateConfigMap will create a config map with the provided environment variable map

func (KubeClient) CreateESSAuthSecrets

func (c KubeClient) CreateESSAuthSecrets(fssAuthFilePath string, agId string, namespace string) (string, error)

CreateESSSecret will create a k8s secrets object from the ess auth file

func (KubeClient) CreateESSCertSecrets

func (c KubeClient) CreateESSCertSecrets(fssCertFilePath string, agId string, namespace string) (string, error)

func (KubeClient) CreateK8SSecrets

func (c KubeClient) CreateK8SSecrets(serviceSecretsMap map[string]string, agId string, namespace string) (string, error)

CreateK8SSecrets will create a k8s secrets object which contains the service secret name and value

func (KubeClient) CreateMMSPVC

func (c KubeClient) CreateMMSPVC(envVars map[string]string, agId string, namespace string) (string, error)

func (KubeClient) DeleteConfigMap

func (c KubeClient) DeleteConfigMap(agId string, namespace string) error

CreateConfigMap will create a config map with the provided environment variable map

func (KubeClient) DeleteESSAuthSecrets

func (c KubeClient) DeleteESSAuthSecrets(agId string, namespace string) error

func (KubeClient) DeleteESSCertSecrets

func (c KubeClient) DeleteESSCertSecrets(agId string, namespace string) error

func (KubeClient) DeleteK8SSecrets

func (c KubeClient) DeleteK8SSecrets(agId string, namespace string) error

DeleteK8SSecrets will delete k8s secrets object which contains the service secret name and value

func (KubeClient) DeleteMMSPVC

func (c KubeClient) DeleteMMSPVC(agId string, namespace string) error

func (KubeClient) Install

func (c KubeClient) Install(tar string, metadata map[string]interface{}, envVars map[string]string, fssAuthFilePath string, fssCertFilePath string, secretsMap map[string]string, agId string, reqNamespace string, crInstallTimeout int64) error

Install creates the objects specified in the operator deployment in the cluster and creates the custom resource to start the operator

func (KubeClient) OperatorStatus

func (c KubeClient) OperatorStatus(tar string, metadata map[string]interface{}, agId string, reqNamespace string) (interface{}, error)

func (KubeClient) Status

func (c KubeClient) Status(tar string, metadata map[string]interface{}, agId string, reqNamespace string) ([]ContainerStatus, error)

func (KubeClient) Uninstall

func (c KubeClient) Uninstall(tar string, metadata map[string]interface{}, agId string, reqNamespace string) error

Install creates the objects specified in the operator deployment in the cluster and creates the custom resource to start the operator

func (KubeClient) Update

func (c KubeClient) Update(tar string, metadata map[string]interface{}, agId string, reqNamespace string, updatedEnv map[string]string, updatedSecrets []persistence.PersistedServiceSecret) error

Currently we only support service/vault secret update, this k8s secret is create with service secret value in agreement. It is not the secret.yml from operator file

type KubeStatus

type KubeStatus struct {
	ContainerStatuses []ContainerStatus
	OperatorStatus    interface{}
}

KubeStatus contains the status of operator pods and a user-defined status object

type KubeWorker

type KubeWorker struct {
	worker.BaseWorker
	// contains filtered or unexported fields
}

func (*KubeWorker) CommandHandler

func (w *KubeWorker) CommandHandler(command worker.Command) bool

func (*KubeWorker) GetAuthenticationManager

func (kw *KubeWorker) GetAuthenticationManager() *resource.AuthenticationManager

func (*KubeWorker) GetSecretManager

func (w *KubeWorker) GetSecretManager() *resource.SecretsManager

func (*KubeWorker) Messages

func (w *KubeWorker) Messages() chan events.Message

func (*KubeWorker) NewEvent

func (w *KubeWorker) NewEvent(incoming events.Message)

type MaintenanceCommand

type MaintenanceCommand struct {
	AgreementProtocol string
	AgreementId       string
	ClusterNamespace  string
	Deployment        persistence.DeploymentConfig
}

func NewMaintenanceCommand

func NewMaintenanceCommand(protocol string, agreementId string, clusterNamespace string, deployment persistence.DeploymentConfig) *MaintenanceCommand

func (MaintenanceCommand) ShortString

func (c MaintenanceCommand) ShortString() string

func (MaintenanceCommand) String

func (c MaintenanceCommand) String() string

type NamespaceCoreV1

type NamespaceCoreV1 struct {
	NamespaceObject *corev1.Namespace
}

func (NamespaceCoreV1) Install

func (n NamespaceCoreV1) Install(c KubeClient, namespace string) error

func (NamespaceCoreV1) Name

func (n NamespaceCoreV1) Name() string

func (NamespaceCoreV1) Namespace

func (n NamespaceCoreV1) Namespace() string

func (NamespaceCoreV1) Status

func (n NamespaceCoreV1) Status(c KubeClient, namespace string) (interface{}, error)

func (NamespaceCoreV1) Uninstall

func (n NamespaceCoreV1) Uninstall(c KubeClient, namespace string)

func (NamespaceCoreV1) Update

func (o NamespaceCoreV1) Update(c KubeClient, namespace string) error

type OtherObject

type OtherObject struct {
	Object *unstructured.Unstructured
	GVK    *schema.GroupVersionKind
}

----------------OtherObjectType---------------- this will only work if the resource name is the kind but lowercase with an "s" on the end

func (OtherObject) Install

func (o OtherObject) Install(c KubeClient, namespace string) error

func (OtherObject) Name

func (o OtherObject) Name() string

func (OtherObject) Namespace

func (o OtherObject) Namespace() string

func (OtherObject) Status

func (o OtherObject) Status(c KubeClient, namespace string) (interface{}, error)

func (OtherObject) Uninstall

func (o OtherObject) Uninstall(c KubeClient, namespace string)

func (OtherObject) Update

func (o OtherObject) Update(c KubeClient, namespace string) error

type RoleRbacV1

type RoleRbacV1 struct {
	RoleObject *rbacv1.Role
}

func (RoleRbacV1) Install

func (r RoleRbacV1) Install(c KubeClient, namespace string) error

func (RoleRbacV1) Name

func (r RoleRbacV1) Name() string

func (RoleRbacV1) Namespace

func (r RoleRbacV1) Namespace() string

func (RoleRbacV1) Status

func (r RoleRbacV1) Status(c KubeClient, namespace string) (interface{}, error)

func (RoleRbacV1) Uninstall

func (r RoleRbacV1) Uninstall(c KubeClient, namespace string)

func (RoleRbacV1) Update

func (r RoleRbacV1) Update(c KubeClient, namespace string) error

type RolebindingRbacV1

type RolebindingRbacV1 struct {
	RolebindingObject *rbacv1.RoleBinding
}

func (RolebindingRbacV1) Install

func (rb RolebindingRbacV1) Install(c KubeClient, namespace string) error

func (RolebindingRbacV1) Name

func (rb RolebindingRbacV1) Name() string

func (RolebindingRbacV1) Namespace

func (rb RolebindingRbacV1) Namespace() string

func (RolebindingRbacV1) Status

func (rb RolebindingRbacV1) Status(c KubeClient, namespace string) (interface{}, error)

func (RolebindingRbacV1) Uninstall

func (rb RolebindingRbacV1) Uninstall(c KubeClient, namespace string)

func (RolebindingRbacV1) Update

func (rb RolebindingRbacV1) Update(c KubeClient, namespace string) error

type ServiceAccountCoreV1

type ServiceAccountCoreV1 struct {
	ServiceAccountObject *corev1.ServiceAccount
}

----------------ServiceAccount----------------

func (ServiceAccountCoreV1) Install

func (sa ServiceAccountCoreV1) Install(c KubeClient, namespace string) error

func (ServiceAccountCoreV1) Name

func (sa ServiceAccountCoreV1) Name() string

func (ServiceAccountCoreV1) Namespace

func (sa ServiceAccountCoreV1) Namespace() string

func (ServiceAccountCoreV1) Status

func (sa ServiceAccountCoreV1) Status(c KubeClient, namespace string) (interface{}, error)

func (ServiceAccountCoreV1) Uninstall

func (sa ServiceAccountCoreV1) Uninstall(c KubeClient, namespace string)

func (ServiceAccountCoreV1) Update

func (sa ServiceAccountCoreV1) Update(c KubeClient, namespace string) error

type UnInstallCommand

type UnInstallCommand struct {
	AgreementProtocol  string
	CurrentAgreementId string
	ClusterNamespace   string
	Deployment         persistence.DeploymentConfig
}

func NewUnInstallCommand

func NewUnInstallCommand(agp string, agId string, clusterNamespace string, dc persistence.DeploymentConfig) *UnInstallCommand

func (UnInstallCommand) ShortString

func (u UnInstallCommand) ShortString() string

type UpdateSecretCommand

type UpdateSecretCommand struct {
	AgreementProtocol string
	AgreementId       string
	ClusterNamespace  string
	Deployment        persistence.DeploymentConfig
	UpdatedSecrets    []persistence.PersistedServiceSecret
}

func NewUpdateSecretCommand

func NewUpdateSecretCommand(protocol string, agreementId string, clusterNamespace string, deployment persistence.DeploymentConfig, updatedSecrets []persistence.PersistedServiceSecret) *UpdateSecretCommand

func (UpdateSecretCommand) ShortString

func (u UpdateSecretCommand) ShortString() string

func (UpdateSecretCommand) String

func (u UpdateSecretCommand) String() string

type YamlFile

type YamlFile struct {
	Header tar.Header
	Body   string
}

Intermediate state used for after the objects have been read from the deployment but not converted to k8s objects yet

Jump to

Keyboard shortcuts

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