Skip to content

Commit

Permalink
Merge pull request kosmos-io#535 from duanmengkk/reactor_code
Browse files Browse the repository at this point in the history
add api for virtualcluster plugin
  • Loading branch information
duanmengkk authored May 16, 2024
2 parents 075040c + ab96ec2 commit d24a73a
Show file tree
Hide file tree
Showing 18 changed files with 1,292 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deploy/crds/kosmos.io_clusterpodconvertpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
shortNames:
- cpcp
singular: clusterpodconvertpolicy
scope: Cluster
scope: Namespaced
versions:
- name: v1alpha1
schema:
Expand Down
114 changes: 114 additions & 0 deletions deploy/crds/kosmos.io_virtualclusterplugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.0
creationTimestamp: null
name: virtualclusterplugins.kosmos.io
spec:
group: kosmos.io
names:
kind: VirtualClusterPlugin
listKind: VirtualClusterPluginList
plural: virtualclusterplugins
shortNames:
- vp
singular: virtualclusterplugin
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
properties:
apiVersion:
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'
type: string
kind:
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'
type: string
metadata:
type: object
spec:
description: VirtualClusterPluginSpec is the specification for a VirtualClusterPlugin
resource
properties:
pluginSources:
properties:
chart:
properties:
name:
type: string
repo:
type: string
storage:
properties:
hostPath:
properties:
nodeName:
type: string
path:
type: string
type: object
pvPath:
type: string
uri:
type: string
type: object
values:
items:
type: string
type: array
valuesFile:
properties:
hostPath:
properties:
nodeName:
type: string
path:
type: string
type: object
pvPath:
type: string
uri:
type: string
type: object
version:
type: string
wait:
type: boolean
type: object
yaml:
properties:
path:
properties:
hostPath:
properties:
nodeName:
type: string
path:
type: string
type: object
pvPath:
type: string
uri:
type: string
type: object
required:
- path
type: object
type: object
successStateCommand:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
32 changes: 32 additions & 0 deletions deploy/crds/kosmos.io_virtualclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ spec:
description: Kubeconfig is the kubeconfig of the virtual kubernetes's
control plane
type: string
pluginSet:
description: PluginSet is the list of plugins that will be used by
the virtual kubernetes's control plane If plugins is nil or empty,
all default plugins will be used
properties:
disabled:
description: Disabled specifies default plugins that should be
disabled.
items:
description: Plugin specifies a plugin name
properties:
name:
description: Name defines the name of plugin
type: string
required:
- name
type: object
type: array
enabled:
description: Enabled specifies plugins that should be enabled
.
items:
description: Plugin specifies a plugin name
properties:
name:
description: Name defines the name of plugin
type: string
required:
- name
type: object
type: array
type: object
promotePolicies:
description: PromotePolicies definites the policies for promote to
the kubernetes's control plane
Expand Down
24 changes: 24 additions & 0 deletions pkg/apis/kosmos/v1alpha1/virtualcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ type VirtualClusterSpec struct {
// the resources can be nodes or just cpu,memory or gpu resources
// +optional
PromoteResources PromoteResources `json:"promoteResources,omitempty"`

// PluginSet is the list of plugins that will be used by the virtual kubernetes's control plane
// If plugins is nil or empty, all default plugins will be used
// +optional
PluginSet PluginSet `json:"pluginSet,omitempty"`
}

// PluginSet specifies enabled and disabled plugins .
// If an array is empty, missing, or nil, all plugins of VirtualClusterPlugin will be used.
type PluginSet struct {
// Enabled specifies plugins that should be enabled .
// +optional
Enabled []Plugin `json:"enabled,omitempty"`

// Disabled specifies default plugins that should be disabled.
// +optional
Disabled []Plugin `json:"disabled,omitempty"`
}

// Plugin specifies a plugin name
type Plugin struct {
// Name defines the name of plugin
// +required
Name string `json:"name"`
}

type PromotePolicy struct {
Expand Down
81 changes: 81 additions & 0 deletions pkg/apis/kosmos/v1alpha1/virtualclusterplugin_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +genclient
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=vp
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type VirtualClusterPlugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// VirtualClusterPluginSpec is the specification for a VirtualClusterPlugin resource
// +required
Spec VirtualClusterPluginSpec `json:"spec"`
}

type VirtualClusterPluginSpec struct {
// +optional
PluginSources PluginSources `json:"pluginSources,omitempty"`

// +optional
SuccessStateCommand string `json:"successStateCommand,omitempty"`
}

type PluginSources struct {
// +optional
Chart Chart `json:"chart,omitempty"`
// +optional
Yaml Yaml `json:"yaml,omitempty"`
}

type Chart struct {
// +optional
Name string `json:"name,omitempty"`
// +optional
Repo string `json:"repo,omitempty"`
// +optional
Storage Storage `json:"storage,omitempty"`
// +optional
Version string `json:"version,omitempty"`
// +optional
ValuesFile Storage `json:"valuesFile,omitempty"`
// +optional
Values []string `json:"values,omitempty"`
// +optional
Wait bool `json:"wait,omitempty"`
}

type Yaml struct {
// +required
Path Storage `json:"path"`
}

type Storage struct {
// +optional
HostPath HostPath `json:"hostPath,omitempty"`

// +optional
PVPath string `json:"pvPath,omitempty"`

// +optional
URI string `json:"uri,omitempty"`
}

type HostPath struct {
// +optional
Path string `json:"path,omitempty"`

// +optional
NodeName string `json:"nodeName,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type VirtualClusterPluginList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []VirtualClusterPlugin `json:"items"`
}
Loading

0 comments on commit d24a73a

Please sign in to comment.