k8s

package
v0.0.0-...-601a7b6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Copyright © 2021 Rasa Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HelmSpec

type HelmSpec struct {
	// Values stores helm values for a given helm release.
	Values map[string]interface{}

	// ReleaseName is a helm release name used by the client.
	ReleaseName string
}

HelmSpec stores data related to helm release.

type Kubernetes

type Kubernetes struct {

	// Namespace is a namepace name used by the client.
	Namespace string

	// Helm defines helm release configuration.
	Helm HelmSpec

	// Log defines logger.
	Log logr.Logger

	// BackendType stores a Kubernetes cluster type.
	BackendType types.KubernetesBackendType

	// CloudProvider defines a detected cloud provider.
	CloudProvider *cloud.Provider

	// Flags stores command flags used during the command execution.
	Flags *types.RasaCtlFlags
	// contains filtered or unexported fields
}

Kubernetes represents Kubernetes client.

func (*Kubernetes) AddNamespaceLabel

func (k *Kubernetes) AddNamespaceLabel() error

AddNamespaceLabels adds an extra label to a given namespace that indicates that the namespace is managed by rasactl.

func (*Kubernetes) CreateNamespace

func (k *Kubernetes) CreateNamespace() error

CreateNamespace creates a namespace.

func (*Kubernetes) CreateVolume

func (k *Kubernetes) CreateVolume(hostPath string) (string, error)

CreateVolume creates a volume that uses a local host path.

func (*Kubernetes) DeleteNamespace

func (k *Kubernetes) DeleteNamespace() error

DeleteNamespace deletes the active namespace.

func (*Kubernetes) DeleteNamespaceLabel

func (k *Kubernetes) DeleteNamespaceLabel() error

DeleteNamespaceLabel deletes a label that indicates if a given namespaces is managed by rasactl.

func (*Kubernetes) DeleteNode

func (k *Kubernetes) DeleteNode(node string) error

DeleteNode deletes a given Kubernetes node.

func (*Kubernetes) DeleteRasaXPods

func (k *Kubernetes) DeleteRasaXPods() error

func (*Kubernetes) DeleteSecretWithState

func (k *Kubernetes) DeleteSecretWithState() error

DeleteSecretWithState deletes the rasactl secret.

func (*Kubernetes) DeleteVolume

func (k *Kubernetes) DeleteVolume() error

DeleteVolumes deletes a volume that uses a local host path.

func (*Kubernetes) GetBackendType

func (k *Kubernetes) GetBackendType() types.KubernetesBackendType

GetBackendType returns the backend type.

func (*Kubernetes) GetCloudProvider

func (k *Kubernetes) GetCloudProvider() *cloud.Provider

GetCloudProvider returns CloudProvider field.

func (*Kubernetes) GetKindControlPlaneNode

func (k *Kubernetes) GetKindControlPlaneNode() (v1.Node, error)

GetKindControlPlaneNode returns v1.Node object that defines a kind control plane node.

func (*Kubernetes) GetLogs

func (k *Kubernetes) GetLogs(pod string) *rest.Request

GetLogs returns the logs stream for a pod.

func (*Kubernetes) GetNamespaces

func (k *Kubernetes) GetNamespaces() ([]string, error)

GetNamespaces returns namespaces that are managed by rasactl.

func (*Kubernetes) GetPod

func (k *Kubernetes) GetPod(pod string) (*v1.Pod, error)

GetPod returns a Pod object for a given pod.

func (*Kubernetes) GetPods

func (k *Kubernetes) GetPods() (*v1.PodList, error)

GetPods returns a list of pods for the active namespace.

func (*Kubernetes) GetPostgreSQLCreds

func (k *Kubernetes) GetPostgreSQLCreds() (string, string, error)

GetPostgreSQLCreds returns credentials for the postgresql deployment.

func (*Kubernetes) GetPostgreSQLSvcNodePort

func (k *Kubernetes) GetPostgreSQLSvcNodePort() (int32, error)

GetPostgreSQLSvcPort returns a node port for the postgresql service.

func (*Kubernetes) GetRabbitMqCreds

func (k *Kubernetes) GetRabbitMqCreds() (string, string, error)

GetRabbitMqCreds returns credentials for the rabbitmq deployment.

func (*Kubernetes) GetRabbitMqSvcNodePort

func (k *Kubernetes) GetRabbitMqSvcNodePort() (int32, error)

GetRabbitMqNodePort returns a node port for the rabbitmq service.

func (*Kubernetes) GetRasaXSvcNodePort

func (k *Kubernetes) GetRasaXSvcNodePort() (int32, error)

GetRasaXSvcNodePort returns a node port for the postgresql service.

func (*Kubernetes) GetRasaXToken

func (k *Kubernetes) GetRasaXToken() (string, error)

GetRasaXToken returns a Rasa X token that is stored in a Kubernetes secret.

func (*Kubernetes) GetRasaXURL

func (k *Kubernetes) GetRasaXURL() (string, error)

GetRasaXURL returns URL for a given deployment.

func (*Kubernetes) GetServiceWithLabels

func (k *Kubernetes) GetServiceWithLabels(opts metav1.ListOptions) (*v1.ServiceList, error)

GetServiceWithLabels returns a list of services with a given labels.

func (*Kubernetes) IsNamespaceExist

func (k *Kubernetes) IsNamespaceExist(namespace string) (bool, error)

IsNamespaceExist checks if a namespace exists.

func (*Kubernetes) IsNamespaceManageable

func (k *Kubernetes) IsNamespaceManageable() bool

IsNamespaceManageable checks if a given namespace is managed by rasactl and returns `true` if it is.

func (*Kubernetes) IsRasaXRunning

func (k *Kubernetes) IsRasaXRunning() (bool, error)

IsRasaXRunning checks if Rasa X deployment is running.

func (*Kubernetes) IsSecretWithStateExist

func (k *Kubernetes) IsSecretWithStateExist() bool

IsSecretWithStateExist checks if a state secret exists. If the secret exists then return 'true'.

func (*Kubernetes) LoadConfig

func (k *Kubernetes) LoadConfig() (*rest.Config, error)

LoadConfig loads the kubeconfig file and returns a complete client config.

func (*Kubernetes) PodStatus

func (k *Kubernetes) PodStatus(conditions []v1.PodCondition) string

PodStatus returns a pod condition.

func (*Kubernetes) ReadSecretWithState

func (k *Kubernetes) ReadSecretWithState() (map[string][]byte, error)

ReadSecretWithState returns data from the rasactl secret.

func (*Kubernetes) SaveSecretWithState

func (k *Kubernetes) SaveSecretWithState(projectPath string) error

SaveSecretWithState saves the rasactl secrets with a deployment state.

func (*Kubernetes) ScaleDown

func (k *Kubernetes) ScaleDown() error

ScaleDown scales down all deployments and statefulsets for a given deployment.

func (*Kubernetes) ScaleUp

func (k *Kubernetes) ScaleUp() error

ScaleDown scales up all deployments and statefulsets for a given deployment.

func (*Kubernetes) SetHelmReleaseName

func (k *Kubernetes) SetHelmReleaseName(release string)

SetHelmReleaseName sets helm release name.

func (*Kubernetes) SetHelmValues

func (k *Kubernetes) SetHelmValues(values map[string]interface{})

SetHelmValues sets helm values.

func (*Kubernetes) SetNamespace

func (k *Kubernetes) SetNamespace(namespace string)

SetNamespace sets Namespace field.

func (*Kubernetes) UpdateRasaXConfig

func (k *Kubernetes) UpdateRasaXConfig(token string) error

UpdateRasaXConfig generates configuration for Rasa X environments and update a Kubernetes secret which stores the configuration.

func (*Kubernetes) UpdateSecretWithState

func (k *Kubernetes) UpdateSecretWithState(data ...interface{}) error

UpdateSecretWithState updates the rasactl secret.

type KubernetesInterface

type KubernetesInterface interface {
	GetRasaXURL() (string, error)
	GetRasaXToken() (string, error)
	CreateNamespace() error
	IsRasaXRunning() (bool, error)
	GetPods() (*v1.PodList, error)
	DeleteRasaXPods() error
	GetPostgreSQLSvcNodePort() (int32, error)
	GetRasaXSvcNodePort() (int32, error)
	GetRabbitMqSvcNodePort() (int32, error)
	SaveSecretWithState(projectPath string) error
	UpdateRasaXConfig(token string) error
	ScaleDown() error
	ScaleUp() error
	UpdateSecretWithState(data ...interface{}) error
	ReadSecretWithState() (map[string][]byte, error)
	DeleteSecretWithState() error
	GetPostgreSQLCreds() (string, string, error)
	GetRabbitMqCreds() (string, string, error)
	IsNamespaceExist(namespace string) (bool, error)
	IsSecretWithStateExist() bool
	GetKindControlPlaneNode() (v1.Node, error)
	IsNamespaceManageable() bool
	AddNamespaceLabel() error
	DeleteNamespaceLabel() error
	DeleteNode(node string) error
	DeleteNamespace() error
	GetNamespaces() ([]string, error)
	PodStatus(conditions []v1.PodCondition) string
	CreateVolume(hostPath string) (string, error)
	DeleteVolume() error
	GetBackendType() types.KubernetesBackendType
	SetNamespace(namespace string)
	SetHelmValues(values map[string]interface{})
	SetHelmReleaseName(release string)
	GetCloudProvider() *cloud.Provider
	LoadConfig() (*rest.Config, error)
	GetLogs(pod string) *rest.Request
	GetPod(pod string) (*v1.Pod, error)
	GetServiceWithLabels(opts metav1.ListOptions) (*v1.ServiceList, error)
}

func New

func New(client *Kubernetes) (KubernetesInterface, error)

New initializes a new Kubernetes client.

Directories

Path Synopsis
Package fake is a generated GoMock package.
Package fake is a generated GoMock package.

Jump to

Keyboard shortcuts

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