bulutzincirkit

package
v1.0.0-GAS.0...-9628651 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

README

Build


microk8s.enable registry

go mod init bulutzincir

go mod tidy

go mod vendor

cd bulutzincir && ./codegen.sh

# build the ethereum operator binary
CGO_ENABLED=0 GOOS=linux go build

# build the docker container
docker build -t localhost:32000/bulutzincir-operator:0.1 .

docker push localhost:32000/bulutzincir-operator:0.1

Start the Operator

# Create the ethereum operator
$ kubectl create -f bulutzincir-operator.yaml

# Wait for the pod status to be Running
$ kubectl get pod -l app=bulutzincir-operator
NAME                              READY     STATUS    RESTARTS   AGE
bulutzincir-operator-821691060-m5vqp   1/1       Running   0          3m

# View the ethereums CRD
$ kubectl get crd ethereums.bulutzincir.io
NAME                   KIND
ethereums.bulutzincir.io   CustomResourceDefinition.v1beta1.apiextensions.k8s.io

Create the Sample Resource

# Create the ethereum
$ kubectl create -f bulutzincir-resource.yaml

# See the ethereum resource
$ kubectl get ethereums.bulutzincir.io
NAME       KIND
myethereum   Sample.v1alpha1.bulutzincir.io

Modify the Sample Resource

Change the value of the Hello property in bulutzincir-resource.yaml, then apply the new yaml.

kubectl apply -f ethereum-resource.yaml

Logs

Notice the added and modified Hello= text in the log below

$ kubectl logs -l app=ethereum-operator
Getting kubernetes context
Creating the ethereum resource
Managing the ethereum resource
Added Sample 'myethereum' with Hello=world!
Updated ethereum 'myethereum' from world to goodbye!

Cleanup

kubectl delete -f bulutzincir-resource.yaml
kubectl delete -f bulutzincir-operator.yaml
kubectl delete crd ethereums.bulutzincir.io

Documentation

Overview

Package kit for Kubernetes operators

Package kit for Kubernetes operators

Package kit for Kubernetes operators

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVersionOutdated indicates that the custom resource is outdated and needs to be refreshed
	ErrVersionOutdated = errors.New("requested version is outdated in apiserver")
)

Functions

func CreateCustomResources

func CreateCustomResources(context Context, resources []CustomResource) error

CreateCustomResources creates the given custom resources and waits for them to initialize The resource is of kind CRD if the Kubernetes server is 1.7.0 and above. The resource is of kind TPR if the Kubernetes server is below 1.7.0.

func NewHTTPClient

func NewHTTPClient(group, version string, schemeBuilder runtime.SchemeBuilder) (rest.Interface, *runtime.Scheme, error)

NewHTTPClient creates a Kubernetes client to interact with API extensions for Custom Resources

func NewHTTPClientFromConfig

func NewHTTPClientFromConfig(group, version string, schemeBuilder runtime.SchemeBuilder, config *rest.Config) (rest.Interface, *runtime.Scheme, error)

NewHTTPClient creates a Kubernetes client from a given Kubernetes *rest.Config to interact with API extensions for Custom Resources

Types

type Context

type Context struct {
	Clientset             kubernetes.Interface
	APIExtensionClientset apiextensionsclient.Interface
	Interval              time.Duration
	Timeout               time.Duration
}

Context hold the clientsets used for creating and watching custom resources

type CustomResource

type CustomResource struct {
	// Name of the custom resource
	Name string

	// Plural of the custom resource in plural
	Plural string

	// Group the custom resource belongs to
	Group string

	// Version which should be defined in a const above
	Version string

	// Scope of the CRD. Namespaced or cluster
	Scope apiextensionsv1beta1.ResourceScope

	// Kind is the serialized interface of the resource.
	Kind string

	// ShortNames is the shortened version of the resource
	ShortNames []string
}

CustomResource is for creating a Kubernetes TPR/CRD

type ResourceWatcher

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

ResourceWatcher watches a custom resource for desired state

func NewWatcher

func NewWatcher(resource CustomResource, namespace string, handlers cache.ResourceEventHandlerFuncs, client rest.Interface) *ResourceWatcher

NewWatcher creates an instance of a custom resource watcher for the given resource

func (*ResourceWatcher) Watch

func (w *ResourceWatcher) Watch(objType runtime.Object, done <-chan struct{}) error

Watch begins watching the custom resource (TPR/CRD). The call will block until a Done signal is raised during in the context. When the watch has detected a create, update, or delete event, it will handled by the functions in the resourceEventHandlers. After the callback returns, the watch loop will continue for the next event. If the callback returns an error, the error will be logged.

Directories

Path Synopsis
Package main for a ethereum operator
Package main for a ethereum operator
pkg/apis/bulutzincir/ethereum/v1alpha1
Package v1 is the v1 version of the API.
Package v1 is the v1 version of the API.
pkg/client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
pkg/client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
pkg/client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
pkg/client/clientset/versioned/typed/ethereum/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
pkg/client/clientset/versioned/typed/ethereum/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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