mirror of
https://github.com/rancher/types.git
synced 2025-08-01 13:07:05 +00:00
Rename machine to node
This commit is contained in:
parent
d7732e9117
commit
c494fd1585
@ -3,9 +3,7 @@ package schema
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/project.cattle.io/v3"
|
||||
"github.com/rancher/types/factory"
|
||||
"github.com/rancher/types/mapper"
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
@ -20,7 +18,6 @@ var (
|
||||
|
||||
Schemas = factory.Schemas(&Version).
|
||||
Init(namespaceTypes).
|
||||
Init(nodeTypes).
|
||||
Init(volumeTypes)
|
||||
)
|
||||
|
||||
@ -40,51 +37,6 @@ func namespaceTypes(schemas *types.Schemas) *types.Schemas {
|
||||
}{})
|
||||
}
|
||||
|
||||
func nodeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return NodeTypes(&Version, schemas)
|
||||
}
|
||||
|
||||
func NodeTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(version, v1.NodeStatus{},
|
||||
&mapper.NodeAddressMapper{},
|
||||
&mapper.OSInfo{},
|
||||
&m.Drop{Field: "addresses"},
|
||||
&m.Drop{Field: "daemonEndpoints"},
|
||||
&m.Drop{Field: "images"},
|
||||
&m.Drop{Field: "nodeInfo"},
|
||||
&m.Move{From: "conditions", To: "nodeConditions"},
|
||||
&m.Drop{Field: "phase"},
|
||||
&m.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
|
||||
).
|
||||
AddMapperForType(version, v1.NodeSpec{},
|
||||
&m.Drop{Field: "externalID"},
|
||||
&m.Drop{Field: "configSource"},
|
||||
&m.Move{From: "providerID", To: "providerId"},
|
||||
&m.Move{From: "podCIDR", To: "podCidr"},
|
||||
m.Access{Fields: map[string]string{
|
||||
"podCidr": "r",
|
||||
"providerId": "r",
|
||||
"taints": "ru",
|
||||
"unschedulable": "ru",
|
||||
}}).
|
||||
AddMapperForType(version, v1.Node{},
|
||||
&m.AnnotationField{Field: "description"},
|
||||
&m.AnnotationField{Field: "publicEndpoints", List: true},
|
||||
&m.Embed{Field: "status"},
|
||||
).
|
||||
MustImport(version, v1.NodeStatus{}, struct {
|
||||
IPAddress string
|
||||
Hostname string
|
||||
Info NodeInfo
|
||||
}{}).
|
||||
MustImport(version, v3.PublicEndpoint{}).
|
||||
MustImport(version, v1.Node{}, struct {
|
||||
Description string `json:"description"`
|
||||
PublicEndpoints string `json:"publicEndpoints" norman:"type=array[publicEndpoint],nocreate,noupdate"`
|
||||
}{})
|
||||
}
|
||||
|
||||
func volumeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
MustImport(&Version, v1.PersistentVolume{})
|
||||
|
@ -16,6 +16,7 @@ var (
|
||||
|
||||
type Project struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
|
@ -11,8 +11,8 @@ type ClusterConditionType string
|
||||
|
||||
const (
|
||||
// ClusterConditionReady Cluster ready to serve API (healthy when true, unhealthy when false)
|
||||
ClusterConditionReady condition.Cond = "Ready"
|
||||
ClusterConditionMachinesCreated condition.Cond = "MachinesCreated"
|
||||
ClusterConditionReady condition.Cond = "Ready"
|
||||
ClusterConditionNodesCreated condition.Cond = "NodesCreated"
|
||||
// ClusterConditionProvisioned Cluster is provisioned
|
||||
ClusterConditionProvisioned condition.Cond = "Provisioned"
|
||||
ClusterConditionUpdated condition.Cond = "Updated"
|
||||
@ -43,7 +43,7 @@ type Cluster struct {
|
||||
}
|
||||
|
||||
type ClusterSpec struct {
|
||||
Nodes []MachineConfig `json:"nodes"`
|
||||
Nodes []NodeConfig `json:"nodes"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Description string `json:"description"`
|
||||
Internal bool `json:"internal" norman:"nocreate,noupdate"`
|
||||
|
@ -7,24 +7,24 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type MachineTemplate struct {
|
||||
type NodeTemplate struct {
|
||||
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"`
|
||||
// Specification of the desired behavior of the the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Spec MachineTemplateSpec `json:"spec"`
|
||||
Spec NodeTemplateSpec `json:"spec"`
|
||||
// Most recent observed status of the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Status MachineTemplateStatus `json:"status"`
|
||||
Status NodeTemplateStatus `json:"status"`
|
||||
}
|
||||
|
||||
type MachineTemplateStatus struct {
|
||||
Conditions []MachineTemplateCondition `json:"conditions"`
|
||||
type NodeTemplateStatus struct {
|
||||
Conditions []NodeTemplateCondition `json:"conditions"`
|
||||
}
|
||||
|
||||
type MachineTemplateCondition struct {
|
||||
type NodeTemplateCondition struct {
|
||||
// Type of cluster condition.
|
||||
Type string `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
@ -37,14 +37,14 @@ type MachineTemplateCondition struct {
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
type MachineTemplateSpec struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
Description string `json:"description"`
|
||||
Driver string `json:"driver"`
|
||||
MachineCommonParams `json:",inline"`
|
||||
type NodeTemplateSpec struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
Description string `json:"description"`
|
||||
Driver string `json:"driver"`
|
||||
NodeCommonParams `json:",inline"`
|
||||
}
|
||||
|
||||
type Machine struct {
|
||||
type Node struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
@ -53,35 +53,35 @@ type Machine struct {
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of the desired behavior of the the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Spec MachineSpec `json:"spec"`
|
||||
Spec NodeSpec `json:"spec"`
|
||||
// Most recent observed status of the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Status MachineStatus `json:"status"`
|
||||
Status NodeStatus `json:"status"`
|
||||
}
|
||||
|
||||
type MachineStatus struct {
|
||||
Conditions []MachineCondition `json:"conditions,omitempty"`
|
||||
NodeStatus v1.NodeStatus `json:"nodeStatus,omitempty"`
|
||||
NodeName string `json:"nodeName,omitempty"`
|
||||
Requested v1.ResourceList `json:"requested,omitempty"`
|
||||
Limits v1.ResourceList `json:"limits,omitempty"`
|
||||
MachineTemplateSpec *MachineTemplateSpec `json:"machineTemplateSpec,omitempty"`
|
||||
NodeConfig *RKEConfigNode `json:"rkeNode,omitempty"`
|
||||
SSHUser string `json:"sshUser,omitempty"`
|
||||
MachineDriverConfig string `json:"machineDriverConfig,omitempty"`
|
||||
NodeAnnotations map[string]string `json:"nodeAnnotations,omitempty"`
|
||||
NodeLabels map[string]string `json:"nodeLabels,omitempty"`
|
||||
NodeTaints []v1.Taint `json:"nodeTaints,omitempty"`
|
||||
type NodeStatus struct {
|
||||
Conditions []NodeCondition `json:"conditions,omitempty"`
|
||||
NodeStatus v1.NodeStatus `json:"nodeStatus,omitempty"`
|
||||
NodeName string `json:"nodeName,omitempty"`
|
||||
Requested v1.ResourceList `json:"requested,omitempty"`
|
||||
Limits v1.ResourceList `json:"limits,omitempty"`
|
||||
NodeTemplateSpec *NodeTemplateSpec `json:"nodeTemplateSpec,omitempty"`
|
||||
NodeConfig *RKEConfigNode `json:"rkeNode,omitempty"`
|
||||
SSHUser string `json:"sshUser,omitempty"`
|
||||
NodeDriverConfig string `json:"nodeDriverConfig,omitempty"`
|
||||
NodeAnnotations map[string]string `json:"nodeAnnotations,omitempty"`
|
||||
NodeLabels map[string]string `json:"nodeLabels,omitempty"`
|
||||
NodeTaints []v1.Taint `json:"nodeTaints,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
MachineConditionInitialized condition.Cond = "Initialized"
|
||||
MachineConditionProvisioned condition.Cond = "Provisioned"
|
||||
MachineConditionConfigSaved condition.Cond = "Saved"
|
||||
MachineConditionReady condition.Cond = "Ready"
|
||||
NodeConditionInitialized condition.Cond = "Initialized"
|
||||
NodeConditionProvisioned condition.Cond = "Provisioned"
|
||||
NodeConditionConfigSaved condition.Cond = "Saved"
|
||||
NodeConditionReady condition.Cond = "Ready"
|
||||
)
|
||||
|
||||
type MachineCondition struct {
|
||||
type NodeCondition struct {
|
||||
// Type of cluster condition.
|
||||
Type condition.Cond `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
@ -96,8 +96,8 @@ type MachineCondition struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type MachineConfig struct {
|
||||
MachineSpec
|
||||
type NodeConfig struct {
|
||||
NodeSpec
|
||||
Labels map[string]string `json:"labels"`
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
}
|
||||
@ -115,7 +115,7 @@ type CustomConfig struct {
|
||||
SSHKey string `yaml:"ssh_key" json:"sshKey,omitempty"`
|
||||
}
|
||||
|
||||
type MachineSpec struct {
|
||||
type NodeSpec struct {
|
||||
NodeSpec v1.NodeSpec `json:"nodeSpec"`
|
||||
CustomConfig *CustomConfig `json:"customConfig"`
|
||||
Imported bool `json:"imported"`
|
||||
@ -124,11 +124,11 @@ type MachineSpec struct {
|
||||
RequestedHostname string `json:"requestedHostname,omitempty" norman:"type=dnsLabel,nullable,noupdate,required"`
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster],noupdate,required"`
|
||||
Role []string `json:"role,omitempty" norman:"noupdate,type=array[enum],options=etcd|worker|controlplane"`
|
||||
MachineTemplateName string `json:"machineTemplateName,omitempty" norman:"type=reference[machineTemplate],noupdate"`
|
||||
NodeTemplateName string `json:"nodeTemplateName,omitempty" norman:"type=reference[nodeTemplate],noupdate"`
|
||||
UseInternalIPAddress bool `json:"useInternalIpAddress,omitempty" norman:"default=true,noupdate"`
|
||||
}
|
||||
|
||||
type MachineCommonParams struct {
|
||||
type NodeCommonParams struct {
|
||||
AuthCertificateAuthority string `json:"authCertificateAuthority,omitempty"`
|
||||
AuthKey string `json:"authKey,omitempty"`
|
||||
EngineInstallURL string `json:"engineInstallURL,omitempty"`
|
||||
@ -141,30 +141,30 @@ type MachineCommonParams struct {
|
||||
EngineEnv map[string]string `json:"engineEnv,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriver struct {
|
||||
type NodeDriver struct {
|
||||
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"`
|
||||
// Specification of the desired behavior of the the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Spec MachineDriverSpec `json:"spec"`
|
||||
Spec NodeDriverSpec `json:"spec"`
|
||||
// Most recent observed status of the cluster. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
|
||||
Status MachineDriverStatus `json:"status"`
|
||||
Status NodeDriverStatus `json:"status"`
|
||||
}
|
||||
|
||||
type MachineDriverStatus struct {
|
||||
Conditions []MachineDriverCondition `json:"conditions"`
|
||||
type NodeDriverStatus struct {
|
||||
Conditions []NodeDriverCondition `json:"conditions"`
|
||||
}
|
||||
|
||||
var (
|
||||
MachineDriverConditionDownloaded condition.Cond = "Downloaded"
|
||||
MachineDriverConditionActive condition.Cond = "Active"
|
||||
MachineDriverConditionInactive condition.Cond = "Inactive"
|
||||
NodeDriverConditionDownloaded condition.Cond = "Downloaded"
|
||||
NodeDriverConditionActive condition.Cond = "Active"
|
||||
NodeDriverConditionInactive condition.Cond = "Inactive"
|
||||
)
|
||||
|
||||
type MachineDriverCondition struct {
|
||||
type NodeDriverCondition struct {
|
||||
// Type of cluster condition.
|
||||
Type string `json:"type"`
|
||||
// Status of the condition, one of True, False, Unknown.
|
||||
@ -179,7 +179,7 @@ type MachineDriverCondition struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriverSpec struct {
|
||||
type NodeDriverSpec struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
Description string `json:"description"`
|
||||
URL string `json:"url" norman:"required"`
|
||||
|
@ -85,7 +85,7 @@ type RKESystemImages struct {
|
||||
|
||||
type RKEConfigNode struct {
|
||||
// Name of the host provisioned via docker machine
|
||||
MachineName string `yaml:"machine_name,omitempty" json:"machineName,omitempty" norman:"type=reference[machine]"`
|
||||
NodeName string `yaml:"-" json:"-" norman:"type=reference[node]"`
|
||||
// IP or FQDN that is fully resolvable and used for SSH communication
|
||||
Address string `yaml:"address" json:"address,omitempty"`
|
||||
// Optional - Internal address that will be used for components communication
|
||||
|
@ -3,9 +3,10 @@ package schema
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/cluster.cattle.io/v3/schema"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
"github.com/rancher/types/factory"
|
||||
"github.com/rancher/types/mapper"
|
||||
@ -19,8 +20,8 @@ var (
|
||||
}
|
||||
|
||||
Schemas = factory.Schemas(&Version).
|
||||
Init(nativeNodeTypes).
|
||||
Init(nodeTypes).
|
||||
Init(machineTypes).
|
||||
Init(authzTypes).
|
||||
Init(clusterTypes).
|
||||
Init(catalogTypes).
|
||||
@ -56,8 +57,44 @@ func catalogTypes(schemas *types.Schemas) *types.Schemas {
|
||||
MustImport(&Version, v3.TemplateVersion{})
|
||||
}
|
||||
|
||||
func nodeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schema.NodeTypes(&Version, schemas)
|
||||
func nativeNodeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
TypeName("internalNodeStatus", v1.NodeStatus{}).
|
||||
TypeName("internalNodeSpec", v1.NodeSpec{}).
|
||||
AddMapperForType(&Version, v1.NodeStatus{},
|
||||
&mapper.NodeAddressMapper{},
|
||||
&mapper.OSInfo{},
|
||||
&m.Drop{Field: "addresses"},
|
||||
&m.Drop{Field: "daemonEndpoints"},
|
||||
&m.Drop{Field: "images"},
|
||||
&m.Drop{Field: "nodeInfo"},
|
||||
&m.Move{From: "conditions", To: "nodeConditions"},
|
||||
&m.Drop{Field: "phase"},
|
||||
&m.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.NodeSpec{},
|
||||
&m.Drop{Field: "externalID"},
|
||||
&m.Drop{Field: "configSource"},
|
||||
&m.Move{From: "providerID", To: "providerId"},
|
||||
&m.Move{From: "podCIDR", To: "podCidr"},
|
||||
m.Access{Fields: map[string]string{
|
||||
"podCidr": "r",
|
||||
"providerId": "r",
|
||||
"taints": "ru",
|
||||
"unschedulable": "ru",
|
||||
}}).
|
||||
MustImportAndCustomize(&Version, v1.NodeSpec{}, func(schema *types.Schema) {
|
||||
schema.CodeName = "InternalNodeSpec"
|
||||
schema.CodeNamePlural = "InternalNodeSpecs"
|
||||
}).
|
||||
MustImportAndCustomize(&Version, v1.NodeStatus{}, func(schema *types.Schema) {
|
||||
schema.CodeName = "InternalNodeStatus"
|
||||
schema.CodeNamePlural = "InternalNodeStatuses"
|
||||
}, struct {
|
||||
IPAddress string
|
||||
Hostname string
|
||||
Info NodeInfo
|
||||
}{})
|
||||
}
|
||||
|
||||
func clusterTypes(schemas *types.Schemas) *types.Schemas {
|
||||
@ -114,32 +151,32 @@ func authzTypes(schemas *types.Schemas) *types.Schemas {
|
||||
MustImport(&Version, v3.GlobalRoleBinding{})
|
||||
}
|
||||
|
||||
func machineTypes(schemas *types.Schemas) *types.Schemas {
|
||||
func nodeTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v3.MachineSpec{}, &m.Embed{Field: "nodeSpec"}).
|
||||
AddMapperForType(&Version, v3.MachineStatus{},
|
||||
AddMapperForType(&Version, v3.NodeSpec{}, &m.Embed{Field: "nodeSpec"}).
|
||||
AddMapperForType(&Version, v3.NodeStatus{},
|
||||
&m.Drop{Field: "rkeNode"},
|
||||
&m.Drop{Field: "machineTemplateSpec"},
|
||||
&m.Drop{Field: "machineDriverConfig"},
|
||||
&m.Drop{Field: "nodeTemplateSpec"},
|
||||
&m.Drop{Field: "nodeDriverConfig"},
|
||||
&m.Embed{Field: "nodeStatus"},
|
||||
&m.SliceMerge{From: []string{"conditions", "nodeConditions"}, To: "conditions"}).
|
||||
AddMapperForType(&Version, v3.MachineConfig{},
|
||||
AddMapperForType(&Version, v3.NodeConfig{},
|
||||
&m.Drop{Field: "clusterName"}).
|
||||
AddMapperForType(&Version, v3.Machine{},
|
||||
AddMapperForType(&Version, v3.Node{},
|
||||
&m.Embed{Field: "status"},
|
||||
m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.MachineDriver{}, m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.MachineTemplate{}, m.DisplayName{}).
|
||||
MustImport(&Version, v3.Machine{}).
|
||||
MustImportAndCustomize(&Version, v3.MachineDriver{}, func(schema *types.Schema) {
|
||||
AddMapperForType(&Version, v3.NodeDriver{}, m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.NodeTemplate{}, m.DisplayName{}).
|
||||
MustImport(&Version, v3.Node{}).
|
||||
MustImportAndCustomize(&Version, v3.NodeDriver{}, func(schema *types.Schema) {
|
||||
schema.ResourceActions["activate"] = types.Action{
|
||||
Output: "machineDriver",
|
||||
Output: "nodeDriver",
|
||||
}
|
||||
schema.ResourceActions["deactivate"] = types.Action{
|
||||
Output: "machineDriver",
|
||||
Output: "nodeDriver",
|
||||
}
|
||||
}).
|
||||
MustImport(&Version, v3.MachineTemplate{})
|
||||
MustImport(&Version, v3.NodeTemplate{})
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ var transitioningMap = map[string]string{
|
||||
"Downloaded": "downloading",
|
||||
"Inactive": "deactivating",
|
||||
"Initialized": "initializing",
|
||||
"MachinesCreated": "provisioning",
|
||||
"NodesCreated": "provisioning",
|
||||
"PodScheduled": "scheduling",
|
||||
"Progressing": "updating",
|
||||
"Provisioned": "provisioning",
|
||||
|
Loading…
Reference in New Issue
Block a user