项目作者: pkbhowmick

项目描述 :
A Kubernetes custom resource with auto code generator and manifest file generator
高级语言: Go
项目地址: git://github.com/pkbhowmick/k8s-crd.git
创建时间: 2021-02-22T11:56:15Z
项目社区:https://github.com/pkbhowmick/k8s-crd

开源协议:Apache License 2.0

下载


KubeApi

KubeApi is a Kubernetes Custom Resource which runs REST API server in Kubernetes.

Go Report Card

Available commands

  1. $ make generate // to build the deepcopy funcs, clientset, informers, listers
  2. $ make manifests // to build the manifest file for kubernetes custom resource definition

Kubernetes Custom Resource Definition Manifest file

Manifest file generated from above command.

  1. ---
  2. apiVersion: apiextensions.k8s.io/v1
  3. kind: CustomResourceDefinition
  4. metadata:
  5. annotations:
  6. controller-gen.kubebuilder.io/version: (devel)
  7. creationTimestamp: null
  8. name: kubeapis.stable.example.com
  9. spec:
  10. group: stable.example.com
  11. names:
  12. kind: KubeApi
  13. listKind: KubeApiList
  14. plural: kubeapis
  15. shortNames:
  16. - kapi
  17. singular: kubeapi
  18. scope: Namespaced
  19. versions:
  20. - additionalPrinterColumns:
  21. - jsonPath: .metadata.creationTimestamp
  22. name: Age
  23. type: date
  24. - jsonPath: .status.deploymentName
  25. name: Deployment
  26. type: string
  27. - jsonPath: .status.serviceName
  28. name: Service
  29. type: string
  30. - jsonPath: .status.replicas
  31. name: Replicas
  32. type: integer
  33. - jsonPath: .status.phase
  34. name: Status
  35. type: string
  36. name: v1alpha1
  37. schema:
  38. openAPIV3Schema:
  39. properties:
  40. apiVersion:
  41. description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
  42. type: string
  43. kind:
  44. description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
  45. type: string
  46. metadata:
  47. type: object
  48. spec:
  49. description: KubeApiSpec Defines KubeApi Object spec
  50. properties:
  51. container:
  52. properties:
  53. containerPort:
  54. description: Container port of Api Server
  55. format: int32
  56. type: integer
  57. image:
  58. description: Container image of the Api Server
  59. type: string
  60. required:
  61. - containerPort
  62. - image
  63. type: object
  64. deploymentName:
  65. type: string
  66. replicas:
  67. default: 1
  68. format: int32
  69. type: integer
  70. serviceName:
  71. type: string
  72. serviceType:
  73. default: ClusterIP
  74. enum:
  75. - ClusterIP
  76. - NodePort
  77. type: string
  78. version:
  79. type: string
  80. required:
  81. - container
  82. - serviceType
  83. type: object
  84. status:
  85. properties:
  86. phase:
  87. type: string
  88. replicas:
  89. description: Conditions []metav1.Condition `json:"conditions"`
  90. format: int32
  91. type: integer
  92. required:
  93. - phase
  94. - replicas
  95. type: object
  96. required:
  97. - spec
  98. type: object
  99. served: true
  100. storage: true
  101. subresources:
  102. status: {}
  103. status:
  104. acceptedNames:
  105. kind: ""
  106. plural: ""
  107. conditions: []
  108. storedVersions: []

Kubebuilder markers

  • // +kubebuilder:object:root=true tells the object generator that this type represents a kind.
  • // +kubebuilder:subresource:status tells the object generator that we want a status subresource.
  • // +kubebuilder:object:generator=true is a package level marker.
  • // +groupName=stable.example.com is a package level marker that represent the API group.

Controller

  • Controllers are the core of kubernetes, and of any operator.
  • It’s controller job to ensure that, for any given object, the actual state of the world matches the desired state in the object.
  • Each controller focuses on one root Kind, but may interact with other Kinds.

References: