diff --git a/apis/management.cattle.io/v3/cluster_types.go b/apis/management.cattle.io/v3/cluster_types.go index 759d0425..28f3eab1 100644 --- a/apis/management.cattle.io/v3/cluster_types.go +++ b/apis/management.cattle.io/v3/cluster_types.go @@ -25,7 +25,9 @@ const ( ClusterConditionconditionDefautlProjectCreated condition.Cond = "DefaultProjectCreated" // ClusterConditionDefaultNamespaceAssigned true when cluster's default namespace has been initially assigned ClusterConditionDefaultNamespaceAssigned condition.Cond = "DefaultNamespaceAssigned" - // More conditions can be added if unredlying controllers request it + + ClusterDriverImported = "imported" + ClusterDriverRKE = "rancherKubernetesEngine" ) type Cluster struct { @@ -42,7 +44,6 @@ type Cluster struct { } type ClusterSpec struct { - NodePools []NodePool `json:"nodePools"` DisplayName string `json:"displayName"` Description string `json:"description"` Internal bool `json:"internal" norman:"nocreate,noupdate"` @@ -207,8 +208,9 @@ type ClusterRegistrationTokenSpec struct { } type ClusterRegistrationTokenStatus struct { - Command string `json:"command"` - NodeCommand string `json:"nodeCommand"` - ManifestURL string `json:"manifestUrl"` - Token string `json:"token"` + InsecureCommand string `json:"insecureCommand"` + Command string `json:"command"` + NodeCommand string `json:"nodeCommand"` + ManifestURL string `json:"manifestUrl"` + Token string `json:"token"` } diff --git a/apis/management.cattle.io/v3/machine_types.go b/apis/management.cattle.io/v3/machine_types.go index 6375d390..a4c8ee85 100644 --- a/apis/management.cattle.io/v3/machine_types.go +++ b/apis/management.cattle.io/v3/machine_types.go @@ -77,6 +77,8 @@ type NodeStatus struct { var ( NodeConditionInitialized condition.Cond = "Initialized" NodeConditionProvisioned condition.Cond = "Provisioned" + NodeConditionRegistered condition.Cond = "Registered" + NodeConditionRemoved condition.Cond = "Removed" NodeConditionConfigSaved condition.Cond = "Saved" NodeConditionReady condition.Cond = "Ready" ) @@ -96,14 +98,39 @@ type NodeCondition struct { Message string `json:"message,omitempty"` } -type NodePool struct { - CommonNodeSpec +var ( + NodePoolConditionUpdated condition.Cond = "Updated" +) - UUID string `json:"uuid" norman:"nocreate,noupdate"` - HostnamePrefix string `json:"hostnamePrefix" norman:"required"` - Quantity int `json:"quantity" norman:"required,default=1"` - Labels map[string]string `json:"labels"` - Annotations map[string]string `json:"annotations"` +type NodePool struct { + types.Namespaced + + metav1.TypeMeta `json:",inline"` + // Standard object’s metadata. More info: + // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NodePoolSpec `json:"spec"` + Status NodePoolStatus `json:"status"` +} + +type NodePoolSpec struct { + Etcd bool `json:"etcd"` + ControlPlane bool `json:"controlPlane"` + Worker bool `json:"worker"` + NodeTemplateName string `json:"nodeTemplateName,omitempty" norman:"type=reference[nodeTemplate],required,notnullable"` + + HostnamePrefix string `json:"hostnamePrefix" norman:"required,notnullable"` + Quantity int `json:"quantity" norman:"required,default=1"` + NodeLabels map[string]string `json:"nodeLabels"` + NodeAnnotations map[string]string `json:"nodeAnnotations"` + + DisplayName string `json:"displayName"` + ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster],noupdate,required"` +} + +type NodePoolStatus struct { + Conditions []Condition `json:"conditions"` } type CustomConfig struct { @@ -119,16 +146,15 @@ type CustomConfig struct { SSHKey string `yaml:"ssh_key" json:"sshKey,omitempty"` } -type CommonNodeSpec struct { - Etcd bool `json:"etcd"` - ControlPlane bool `json:"controlPlane"` - Worker bool `json:"worker"` - NodeTemplateName string `json:"nodeTemplateName,omitempty" norman:"type=reference[nodeTemplate]"` -} - type NodeSpec struct { - CommonNodeSpec `json:",inline"` - NodePoolUUID string `json:"nodePoolUuid" norman:"nocreate,noupdate"` + // Common fields. They aren't in a shared struct because the annotations are different + + Etcd bool `json:"etcd" norman:"noupdate"` + ControlPlane bool `json:"controlPlane" norman:"noupdate"` + Worker bool `json:"worker" norman:"noupdate"` + NodeTemplateName string `json:"nodeTemplateName,omitempty" norman:"type=reference[nodeTemplate],noupdate"` + + NodePoolName string `json:"nodePoolUuid" norman:"type=reference[nodePool],nocreate,noupdate"` CustomConfig *CustomConfig `json:"customConfig"` Imported bool `json:"imported"` Description string `json:"description,omitempty"` @@ -166,7 +192,7 @@ type NodeDriver struct { } type NodeDriverStatus struct { - Conditions []NodeDriverCondition `json:"conditions"` + Conditions []Condition `json:"conditions"` } var ( @@ -175,7 +201,7 @@ var ( NodeDriverConditionInactive condition.Cond = "Inactive" ) -type NodeDriverCondition struct { +type Condition struct { // Type of cluster condition. Type string `json:"type"` // Status of the condition, one of True, False, Unknown. diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index 80de78c1..b13348f2 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -165,9 +165,14 @@ func nodeTypes(schemas *types.Schemas) *types.Schemas { &m.Move{From: "rkeNode/user", To: "sshUser"}, &m.ReadOnly{Field: "sshUser"}, &m.Drop{Field: "rkeNode"}, + &m.Drop{Field: "labels"}, + &m.Drop{Field: "annotations"}, + &m.Move{From: "nodeLabels", To: "labels"}, + &m.Move{From: "nodeAnnotations", To: "annotations"}, m.DisplayName{}). AddMapperForType(&Version, v3.NodeDriver{}, m.DisplayName{}). AddMapperForType(&Version, v3.NodeTemplate{}, m.DisplayName{}). + MustImport(&Version, v3.NodePool{}). MustImport(&Version, v3.Node{}). MustImportAndCustomize(&Version, v3.NodeDriver{}, func(schema *types.Schema) { schema.ResourceActions["activate"] = types.Action{