k8s-custom-resources

module
v0.0.0-...-8e197b7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0

README

k8s-custom-resources

A project containing all custom resource definitions used by HPE

Requirements for generating new CRDs.

1. Add new types:

Open pkg/apis/hpestorage/v1/types.go and add your new type:

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type NewType struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata"`
	Spec              NewTypeSpec `json:"spec"`
}

By default, it must include the TypeMeta and ObjectMeta. The Spec is where you define properties specific to the new type:

type NewTypeSpec struct {
	Foo     string `json:"foo,omitempty"`
	Bar     string `json:"bar,omitempty"`
}
2. Generate client, informers, and listers:
  • Download https://github.com/kubernetes/code-generator
  • Run ./code-generator/generate-groups.sh all "github.com/hpe-storage/k8s-custom-resources/pkg/client" "github.com/hpe-storage/k8s-custom-resources/pkg/apis" "hpestorage:v1"
3. Add the CRD definition to our yaml deployment file:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  creationTimestamp: null
  name: newtypes.storage.hpe.com
spec:
  group: storage.hpe.com
  names:
    kind: NewType
    plural: newtypes
  scope: Cluster
  validation:
    openAPIV3Schema:
      properties:
        hpeNodes:
          description: List of HPE new types.
          items:
            properties:
              foo:
                description: The foo description.
                type: string
              bar:
                description: The bar description.
                type: string
          type: array
  version: v1
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []

Directories

Path Synopsis
pkg
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/hpestorage/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/hpestorage/v1/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