Skip to content

jggoebel/crder

 
 

Repository files navigation

CRDer ("see-are-dee-er')

Helps you create CustomResourceDefinitions and install them into a cluster.

Example

package main

import (
	"github.com/ebauman/crder"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

// usually present in pkg/apis/v1/example.org/types.g

type Foo struct {
	v1.TypeMeta
	Metadata v1.ObjectMeta

	Spec FooSpec
}

type FooSpec struct {
	Bar bool
}

func main() {
	c := NewCRD(Foo{})
	
	c.AddVersion("v1", Foo{}, func(cv *CRDVersion) {
		cv.
			IsServed(true).
			IsStored(true)
	})

	cfg, err := clientcmd.BuildConfigFromFlags("", "/path/to/kube/config/file")
	if err != nil {
		log.Fatal(err)
	}

	installable, err := c.ToV1CustomResourceDefinition()
	if err != nil {
		log.Fatal(err)
	}

	err = InstallUpdateCRDs(cfg, *installable)
	if err != nil {
		log.Fatal(err)
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%