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 ¶
- type KubeService
- func (k *KubeService) Create(ctx context.Context, name string) error
- func (k *KubeService) Delete(ctx context.Context, name string) error
- func (k *KubeService) Exist(ctx context.Context, name string) (bool, error)
- func (k *KubeService) Get(ctx context.Context, name string) (*v1.Namespace, error)
- func (k *KubeService) GetEndpoints(ctx context.Context, namespace string) (*v1.EndpointsList, error)
- func (k *KubeService) GetPods(ctx context.Context, namespace string) (*v1.PodList, error)
- func (k *KubeService) Update(ctx context.Context, namespace string, labelsToUpdate map[string]string) error
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