Skip to content

Guide for autogeneratng client codes for Kubernetes Custom Resource Definitions (CRD)

License

Notifications You must be signed in to change notification settings

afarid/kubernetes-crd-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

kubernetes-crd-example

Guide for autogeneratng client codes for Kubernetes Custom Resource Definitions (CRD)

Steps:

  • take the configuration in directory in pkg/apis/foo.com/ as template to define the new crd"

  • Disable go modules

export GO111MODULE=off
  • Download the generator repository
 go get k8s.io/code-generator
  • Download this repository
go get github.com/afarid/kubernetes-crd-example/pkg/apis/foo.com/v1
  • Run this command inside this project directory:
cd $GOPATH/src/github.com/afarid/kubernetes-crd-example
../../../k8s.io/code-generator/generate-groups.sh all "github.com/afarid/kubernetes-crd-example/pkg/clients" "github.com/afarid/kubernetes-crd-example/pkg/apis" "foo.com:v1" -h ../../../k8s.io/code-generator/hack/boilerplate.go.txt

After running the above command, you will see a new directory pkg/clients/.

  • use generated package in your code, this is an example of how to use the generated package
package main

import (
	clientset "github.com/afarid/kubernetes-crd-example/pkg/clients/clientset/versioned"
)

func main() {
	_, _ = clientset.NewForConfig(nil)
}

About

Guide for autogeneratng client codes for Kubernetes Custom Resource Definitions (CRD)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages