kubecrud

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

Kubernetes CRUD

A library for running kubernetes CRUD operations.

Example

You can find a working example how to use it with your own cluster here.

go run examples/example.go -kubecontext=<your-kube-context>

Usage

Passing nil in the service will try to build a kubernetes client in cluster.

svc := kubecrud.NewService(nil)

Passing the context you want will try to build a kubernetes client for the provided context.

kcontext := "my-example"
svc := kubecrud.NewService(&kcontext)

Development

The library is currently compatible with golang version from 1.13+.

Use a minikube or microk8 for local development with a Kubernetes cluster.

The library uses Go modules so it can be located outside the Go path.

# Setup with extra tools
make setup

# Run linter for Go
make lint

# Run the example
make example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeService

type KubeService struct {
	ClientSet *kubernetes.Clientset
}

KubeService includes the kube context

func NewService

func NewService(kubecontext *string) (*KubeService, error)

NewService factory method to create a new Kubernete sertvice to interact with crud methods

func (*KubeService) Create

func (k *KubeService) Create(ctx context.Context, name string) error

Create creates a namespace in k8

func (*KubeService) Delete

func (k *KubeService) Delete(ctx context.Context, name string) error

Delete deletes a namespace

func (*KubeService) Exist

func (k *KubeService) Exist(ctx context.Context, name string) (bool, error)

Exist returns true if the namespace exists in k8

func (*KubeService) Get

func (k *KubeService) Get(ctx context.Context, name string) (*v1.Namespace, error)

Get return details of the provided namespace

func (*KubeService) GetEndpoints

func (k *KubeService) GetEndpoints(ctx context.Context, namespace string) (*v1.EndpointsList, error)

GetEndpoints returns an endpoints list

func (*KubeService) GetPods

func (k *KubeService) GetPods(ctx context.Context, namespace string) (*v1.PodList, error)

GetPods returns a pods list

func (*KubeService) Update

func (k *KubeService) Update(ctx context.Context, namespace string, labelsToUpdate map[string]string) error

Update updates the provided namespace

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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