thales

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 37 Imported by: 5

README

Thales

Common layer for odysseia-greek it holds the kubernetes interface

Table of contents

Thales - Θαλῆς

Μέγιστον τόπος· ἄπαντα γὰρ χωρεῖ. - he greatest is space, for it holds all things

Thales

Installation

Usage

go get github.com/odysseia-greek/thales

Documentation

Index

Constants

View Source
const (
	EnvNamespace = "NAMESPACE"
	EnvKubePath  = "KUBE_PATH"
)

Variables

This section is empty.

Functions

func CreateAnnotatedDeploymentObject

func CreateAnnotatedDeploymentObject(name, ns string, annotations map[string]string) *appsv1.Deployment

func CreateDeploymentForTest

func CreateDeploymentForTest(name, ns string, client KubeClient) error

func CreateDeploymentObject

func CreateDeploymentObject(name, ns string) *appsv1.Deployment

func CreateJobObject

func CreateJobObject(name, ns string, completed bool) *batchv1.Job

func CreatePodForTest

func CreatePodForTest(name, ns, access, role string, client KubeClient) error

func CreatePodObject

func CreatePodObject(name, ns, access, role string) *corev1.Pod

func CreatePodObjectWithExit

func CreatePodObjectWithExit(name, ns string) *corev1.Pod

func CreatePodSpecVolume

func CreatePodSpecVolume(name, secretName string) []corev1.Volume

Types

type Access

type Access interface {
	GetServiceAccounts() (*corev1.ServiceAccountList, error)
}

type AccessImpl

type AccessImpl struct {
	// contains filtered or unexported fields
}

func NewAccessClient

func NewAccessClient(kube kubernetes.Interface, namespace string) (*AccessImpl, error)

func (*AccessImpl) GetServiceAccounts

func (a *AccessImpl) GetServiceAccounts() (*corev1.ServiceAccountList, error)

type Certificate

type Certificate interface {
	ListCsr() (*v1cert.CertificateSigningRequestList, error)
	DeleteCsr(name string) error
}

type CertificateImpl

type CertificateImpl struct {
	// contains filtered or unexported fields
}

func NewCertificateClient

func NewCertificateClient(kube kubernetes.Interface) (*CertificateImpl, error)

func (*CertificateImpl) DeleteCsr

func (c *CertificateImpl) DeleteCsr(name string) error

func (*CertificateImpl) ListCsr

type Cluster

type Cluster interface {
	GetHostServer() (string, error)
	GetHostCaCert() ([]byte, error)
	GetCurrentContext() (string, error)
}

type ClusterImpl

type ClusterImpl struct {
	// contains filtered or unexported fields
}

func NewClusterClient

func NewClusterClient(config []byte) (*ClusterImpl, error)

func (*ClusterImpl) GetCurrentContext

func (c *ClusterImpl) GetCurrentContext() (string, error)

func (*ClusterImpl) GetHostCaCert

func (c *ClusterImpl) GetHostCaCert() ([]byte, error)

func (*ClusterImpl) GetHostServer

func (c *ClusterImpl) GetHostServer() (string, error)

type Configuration

type Configuration interface {
	GetSecret(namespace, secretName string) (*corev1.Secret, error)
	ListSecrets(namespace string) (*corev1.SecretList, error)
	CreateSecret(namespace, secretName string, data map[string][]byte) error
	UpdateSecret(namespace, secretName string, data map[string][]byte) error
	DeleteSecret(namespace, secretName string) error
	CreateDockerSecret(namespace, secretName string, data map[string]string) error
	CreateTlSSecret(namespace, secretName string, data map[string][]byte, immutable bool) error
	UpdateTLSSecret(namespace, secretName string, data map[string][]byte, annotation map[string]string) error
}

type ConfigurationImpl

type ConfigurationImpl struct {
	// contains filtered or unexported fields
}

func NewConfigurationClient

func NewConfigurationClient(kube kubernetes.Interface) (*ConfigurationImpl, error)

func (*ConfigurationImpl) CreateDockerSecret

func (c *ConfigurationImpl) CreateDockerSecret(namespace, secretName string, data map[string]string) error

func (*ConfigurationImpl) CreateSecret

func (c *ConfigurationImpl) CreateSecret(namespace, secretName string, data map[string][]byte) error

func (*ConfigurationImpl) CreateTlSSecret

func (c *ConfigurationImpl) CreateTlSSecret(namespace, secretName string, data map[string][]byte, immutable bool) error

func (*ConfigurationImpl) DeleteSecret

func (c *ConfigurationImpl) DeleteSecret(namespace, secretName string) error

func (*ConfigurationImpl) GetSecret

func (c *ConfigurationImpl) GetSecret(namespace, secretName string) (*corev1.Secret, error)

GetSecret a secrets in a namespace in your kube cluster

func (*ConfigurationImpl) ListSecrets

func (c *ConfigurationImpl) ListSecrets(namespace string) (*corev1.SecretList, error)

func (*ConfigurationImpl) UpdateSecret

func (c *ConfigurationImpl) UpdateSecret(namespace, secretName string, data map[string][]byte) error

func (*ConfigurationImpl) UpdateTLSSecret

func (c *ConfigurationImpl) UpdateTLSSecret(namespace, secretName string, data map[string][]byte, annotation map[string]string) error

type Kube

type Kube struct {
	// contains filtered or unexported fields
}

func New

func New(clientSet *kubernetes.Clientset, restConfig *rest.Config, config []byte, ns string) (*Kube, error)

func NewConfigBasedKube

func NewConfigBasedKube(config []byte, ns string) (*Kube, error)

func NewInClusterKube

func NewInClusterKube(ns string) (*Kube, error)

func (*Kube) Access

func (k *Kube) Access() Access

func (*Kube) Certificate

func (k *Kube) Certificate() Certificate

func (*Kube) Cluster

func (k *Kube) Cluster() Cluster

func (*Kube) Configuration

func (k *Kube) Configuration() Configuration

func (*Kube) Namespaces

func (k *Kube) Namespaces() Namespace

func (*Kube) Nodes

func (k *Kube) Nodes() Nodes

func (*Kube) Storage

func (k *Kube) Storage() Storage

func (*Kube) Util

func (k *Kube) Util() Util

func (*Kube) V1Alpha1

func (k *Kube) V1Alpha1() V1Alpha1

func (*Kube) Workload

func (k *Kube) Workload() Workload

type KubeClient

type KubeClient interface {
	Access() Access
	Configuration() Configuration
	Cluster() Cluster
	Util() Util
	Workload() Workload
	Nodes() Nodes
	Namespaces() Namespace
	Storage() Storage
	Certificate() Certificate
	V1Alpha1() V1Alpha1
}

func CreateKubeClient added in v0.1.1

func CreateKubeClient(OutOfClusterKube bool) (KubeClient, error)

func FakeKubeClient

func FakeKubeClient(ns string) (KubeClient, error)

func NewKubeClient

func NewKubeClient(cfg []byte, ns string) (KubeClient, error)

type Namespace

type Namespace interface {
	Create(namespace string) error
	Delete(namespace string) error
	List() (*corev1.NamespaceList, error)
}

type NamespaceImpl

type NamespaceImpl struct {
	// contains filtered or unexported fields
}

func NewNamespaceClient

func NewNamespaceClient(kube kubernetes.Interface) (*NamespaceImpl, error)

NewNamespaceClient to interact with Namespace interface

func (*NamespaceImpl) Create

func (n *NamespaceImpl) Create(namespace string) error

Create checks if a namespace exists and creates one if it does not exist yet

func (*NamespaceImpl) Delete

func (n *NamespaceImpl) Delete(namespace string) error

Delete removes a named namespace from your kube cluster

func (*NamespaceImpl) List

func (n *NamespaceImpl) List() (*corev1.NamespaceList, error)

List lists all namespaces within your cluster

type Nodes

type Nodes interface {
	List() (*corev1.NodeList, error)
}

type NodesImpl

type NodesImpl struct {
	// contains filtered or unexported fields
}

func NewNodesClient

func NewNodesClient(kube kubernetes.Interface) (*NodesImpl, error)

func (*NodesImpl) List

func (n *NodesImpl) List() (*corev1.NodeList, error)

type ServiceMapping

type ServiceMapping interface {
	Parse(services []v1alpha.Service, name, ns string) (*v1alpha.Mapping, error)
	List() (*v1alpha.MappingList, error)
	Get(name string) (*v1alpha.Mapping, error)
	Create(mapping *v1alpha.Mapping) (*v1alpha.Mapping, error)
	Update(mapping *v1alpha.Mapping) (*v1alpha.Mapping, error)
	CreateInCluster() (bool, error)
	GetDefinition(name string) (*apiextensionv1.CustomResourceDefinition, error)
}

type ServiceMappingsImpl

type ServiceMappingsImpl struct {
	ExtensionClient clientset.Interface
	Client          rest.Interface
}

func NewFakeServiceMappingImpl

func NewFakeServiceMappingImpl() (*ServiceMappingsImpl, error)

func NewServiceMappingImpl

func NewServiceMappingImpl(restConfig *rest.Config) (*ServiceMappingsImpl, error)

func (*ServiceMappingsImpl) Create

func (s *ServiceMappingsImpl) Create(mapping *v1alpha.Mapping) (*v1alpha.Mapping, error)

func (*ServiceMappingsImpl) CreateInCluster

func (s *ServiceMappingsImpl) CreateInCluster() (bool, error)

CreateInCluster retrieves the CRD and will deploy it to the cluster when it's not installed yet.

func (*ServiceMappingsImpl) Get

func (s *ServiceMappingsImpl) Get(name string) (*v1alpha.Mapping, error)

func (*ServiceMappingsImpl) GetDefinition

func (*ServiceMappingsImpl) List

func (*ServiceMappingsImpl) Parse

func (s *ServiceMappingsImpl) Parse(services []v1alpha.Service, name, ns string) (*v1alpha.Mapping, error)

func (*ServiceMappingsImpl) Update

func (s *ServiceMappingsImpl) Update(mapping *v1alpha.Mapping) (*v1alpha.Mapping, error)

type Storage

type Storage interface {
	ListPvc(namespace string) (*corev1.PersistentVolumeClaimList, error)
	DeletePvc(namespace, name string) error
	ListPv() (*corev1.PersistentVolumeList, error)
	DeletePv(name string) error
}

type StorageImpl

type StorageImpl struct {
	// contains filtered or unexported fields
}

func NewStorageClient

func NewStorageClient(kube kubernetes.Interface) (*StorageImpl, error)

func (*StorageImpl) DeletePv

func (s *StorageImpl) DeletePv(name string) error

func (*StorageImpl) DeletePvc

func (s *StorageImpl) DeletePvc(namespace, name string) error

func (*StorageImpl) ListPv

func (s *StorageImpl) ListPv() (*corev1.PersistentVolumeList, error)

func (*StorageImpl) ListPvc

func (s *StorageImpl) ListPvc(namespace string) (*corev1.PersistentVolumeClaimList, error)

type Util

type Util interface {
	CopyFileToPod(podName, destPath, srcPath string) (string, error)
	CopyFileFromPod(srcPath, destPath, namespace, podName string) error
}

type UtilImpl

type UtilImpl struct {
	// contains filtered or unexported fields
}

func NewUtilClient

func NewUtilClient(kube kubernetes.Interface, namespace string) (*UtilImpl, error)

func (*UtilImpl) CopyFileFromPod

func (c *UtilImpl) CopyFileFromPod(srcPath, destPath, namespace, podName string) error

func (*UtilImpl) CopyFileToPod

func (c *UtilImpl) CopyFileToPod(podName, destPath, srcPath string) (string, error)

type V1Alpha1

type V1Alpha1 interface {
	ServiceMapping() ServiceMapping
}

type V1Alpha1Impl

type V1Alpha1Impl struct {
	// contains filtered or unexported fields
}

func NewV1AlphaClient

func NewV1AlphaClient(restConfig *rest.Config) (*V1Alpha1Impl, error)

func NewV1FakeAlphaClient

func NewV1FakeAlphaClient() (*V1Alpha1Impl, error)

func (*V1Alpha1Impl) ServiceMapping

func (v *V1Alpha1Impl) ServiceMapping() ServiceMapping

type Workload

type Workload interface {
	List(namespace string) (*corev1.PodList, error)
	CreatePodSpec(namespace, name, podImage string, command []string) *corev1.Pod
	DeletePod(namespace, podName string) error
	CreatePod(namespace string, pod *corev1.Pod) (*corev1.Pod, error)
	ExecNamedPod(namespace, podName string, command []string) (string, error)
	GetStatefulSets(namespace string) (*appsv1.StatefulSetList, error)
	GetPodsBySelector(namespace, selector string) (*corev1.PodList, error)
	GetPodByName(namespace, name string) (*corev1.Pod, error)
	CreateDeployment(namespace string, deployment *appsv1.Deployment) (*appsv1.Deployment, error)
	ListDeployments(namespace string) (*appsv1.DeploymentList, error)
	UpdateDeploymentViaAnnotation(namespace, name string, annotation map[string]string) (*appsv1.Deployment, error)
	GetDeployment(namespace, name string) (*appsv1.Deployment, error)
	GetDeploymentStatus(namespace string) (bool, error)
	CreateJob(namespace string, spec *batchv1.Job) (*batchv1.Job, error)
	GetJob(namespace, name string) (*batchv1.Job, error)
	ListJobs(namespace string) (*batchv1.JobList, error)
	GetNewLock(lockName, podName, namespace string) *resourcelock.LeaseLock
}

type WorkloadImpl

type WorkloadImpl struct {
	// contains filtered or unexported fields
}

func NewWorkloadClient

func NewWorkloadClient(kube kubernetes.Interface) (*WorkloadImpl, error)

func (*WorkloadImpl) CreateDeployment

func (w *WorkloadImpl) CreateDeployment(namespace string, deployment *appsv1.Deployment) (*appsv1.Deployment, error)

func (*WorkloadImpl) CreateJob

func (w *WorkloadImpl) CreateJob(namespace string, spec *batchv1.Job) (*batchv1.Job, error)

func (*WorkloadImpl) CreatePod

func (w *WorkloadImpl) CreatePod(namespace string, pod *corev1.Pod) (*corev1.Pod, error)

func (*WorkloadImpl) CreatePodSpec

func (w *WorkloadImpl) CreatePodSpec(namespace, name, podImage string, command []string) *corev1.Pod

func (*WorkloadImpl) DeletePod

func (w *WorkloadImpl) DeletePod(namespace, podName string) error

func (*WorkloadImpl) ExecNamedPod

func (w *WorkloadImpl) ExecNamedPod(namespace, podName string, command []string) (string, error)

func (*WorkloadImpl) GetDeployment

func (w *WorkloadImpl) GetDeployment(namespace, name string) (*appsv1.Deployment, error)

func (*WorkloadImpl) GetDeploymentStatus

func (w *WorkloadImpl) GetDeploymentStatus(namespace string) (bool, error)

func (*WorkloadImpl) GetJob

func (w *WorkloadImpl) GetJob(namespace, name string) (*batchv1.Job, error)

func (*WorkloadImpl) GetNewLock

func (w *WorkloadImpl) GetNewLock(lockName, podName, namespace string) *resourcelock.LeaseLock

func (*WorkloadImpl) GetPodByName

func (w *WorkloadImpl) GetPodByName(namespace, name string) (*corev1.Pod, error)

func (*WorkloadImpl) GetPodsBySelector

func (w *WorkloadImpl) GetPodsBySelector(namespace, selector string) (*corev1.PodList, error)

func (*WorkloadImpl) GetStatefulSets

func (w *WorkloadImpl) GetStatefulSets(namespace string) (*appsv1.StatefulSetList, error)

func (*WorkloadImpl) List

func (w *WorkloadImpl) List(namespace string) (*corev1.PodList, error)

List lists all pods within your cluster

func (*WorkloadImpl) ListDeployments

func (w *WorkloadImpl) ListDeployments(namespace string) (*appsv1.DeploymentList, error)

func (*WorkloadImpl) ListJobs

func (w *WorkloadImpl) ListJobs(namespace string) (*batchv1.JobList, error)

func (*WorkloadImpl) UpdateDeploymentViaAnnotation

func (w *WorkloadImpl) UpdateDeploymentViaAnnotation(namespace, name string, annotation map[string]string) (*appsv1.Deployment, error)

Directories

Path Synopsis
crd

Jump to

Keyboard shortcuts

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