Code Monkey home page Code Monkey logo

k8s-custom-resources's Introduction

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: []

k8s-custom-resources's People

Contributors

raunakkumar avatar datamattsson avatar shivamerla avatar ckallianpur avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.