Skip to content

Commit

Permalink
Add VirtualCluster api
Browse files Browse the repository at this point in the history
Signed-off-by: duanmengkk <[email protected]>
  • Loading branch information
duanmengkk committed Feb 8, 2024
1 parent 640e9a6 commit a677dc2
Show file tree
Hide file tree
Showing 15 changed files with 808 additions and 0 deletions.
77 changes: 77 additions & 0 deletions deploy/crds/kosmos.io_virtualclusters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.0
creationTimestamp: null
name: virtualclusters.kosmos.io
spec:
group: kosmos.io
names:
kind: VirtualCluster
listKind: VirtualClusterList
plural: virtualclusters
singular: virtualcluster
scope: Cluster
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: Spec is the specification for the behaviour of the VirtualCluster.
properties:
kubeconfig:
description: Kubeconfig is the kubeconfig of the virtual kubernetes's
control plane
type: string
promoteResources:
description: PromoteResources definites the resources for promote
to the kubernetes's control plane, the resources can be nodes or
just cpu,memory or gpu resources
properties:
nodes:
description: Nodes is the names of node to promote to the kubernetes's
control plane
items:
type: string
type: array
resources:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources is the resources to promote to the kubernetes's
control plane
type: object
type: object
required:
- promoteResources
type: object
status:
description: Status describes the current status of a VirtualCluster.
properties:
phase:
description: Phase is the phase of kosmos-operator handling the VirtualCluster
type: string
type: object
required:
- spec
type: object
served: true
storage: true
62 changes: 62 additions & 0 deletions pkg/apis/kosmos/v1alpha1/virtualcluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type Phase string

const (
// Preparing means kubernetes control plane is preparing,and kubeconfig is not ready
Preparing Phase = "Preparing"
// Initialized means kubernetes control plane is ready,and kubeconfig is ready for use
Initialized Phase = "Initialized"
// Completed means kubernetes control plane is ready,kosmos is joined, and resource is promoted
Completed Phase = "Completed"
)

// +genclient
// +genclient:nonNamespaced
// +kubebuilder:resource:scope="Cluster"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

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

// Spec is the specification for the behaviour of the VirtualCluster.
// +required
Spec VirtualClusterSpec `json:"spec"`

// Status describes the current status of a VirtualCluster.
// +optional
Status VirtualClusterStatus `json:"status,omitempty"`
}

type VirtualClusterSpec struct {
// Kubeconfig is the kubeconfig of the virtual kubernetes's control plane
// +optional
Kubeconfig string `json:"kubeconfig,omitempty"`

// PromoteResources definites the resources for promote to the kubernetes's control plane,
// the resources can be nodes or just cpu,memory or gpu resources
// +required
PromoteResources PromoteResources `json:"promoteResources"`
}

type PromoteResources struct {
// Nodes is the names of node to promote to the kubernetes's control plane
// +optional
Nodes []string `json:"nodes,omitempty"`

// Resources is the resources to promote to the kubernetes's control plane
// +optional
Resources corev1.ResourceList `json:"resources,omitempty"`
}

type VirtualClusterStatus struct {
// Phase is the phase of kosmos-operator handling the VirtualCluster
// +optional
Phase Phase `json:"phase,omitempty"`
}
89 changes: 89 additions & 0 deletions pkg/apis/kosmos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/kosmos/v1alpha1/zz_generated.register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a677dc2

Please sign in to comment.