1
0
mirror of https://github.com/rancher/types.git synced 2025-09-01 05:09:10 +00:00

API Updates

This commit is contained in:
Darren Shepherd
2017-12-04 16:42:18 -07:00
parent 6106f4926c
commit 68600ed35d
17 changed files with 629 additions and 590 deletions

View File

@@ -1,27 +0,0 @@
package schema
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/mapper"
"github.com/rancher/types/apis/cluster.cattle.io/v1"
"github.com/rancher/types/factory"
)
var (
Version = types.APIVersion{
Version: "v1",
Group: "cluster.cattle.io",
Path: "/v1-cluster",
}
Schemas = factory.Schemas(&Version).
AddMapperForType(&Version, v1.Cluster{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.Machine{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.MachineDriver{}, mapper.DisplayName{}).
AddMapperForType(&Version, v1.MachineTemplate{}, mapper.DisplayName{}).
MustImport(&Version, v1.Cluster{}).
MustImport(&Version, v1.ClusterNode{}).
MustImport(&Version, v1.Machine{}).
MustImport(&Version, v1.MachineDriver{}).
MustImport(&Version, v1.MachineTemplate{})
)

View File

@@ -1,393 +0,0 @@
package v1
import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ClusterConditionType string
const (
// ClusterConditionReady Cluster ready to serve API (healthy when true, unehalthy when false)
ClusterConditionReady = "Ready"
// ClusterConditionProvisioned Cluster is provisioned
ClusterConditionProvisioned = "Provisioned"
// ClusterConditionUpdating Cluster is being updating (upgrading, scaling up)
ClusterConditionUpdating = "Updating"
// ClusterConditionNoDiskPressure true when all cluster nodes have sufficient disk
ClusterConditionNoDiskPressure = "NoDiskPressure"
// ClusterConditionNoMemoryPressure true when all cluster nodes have sufficient memory
ClusterConditionNoMemoryPressure = "NoMemoryPressure"
// More conditions can be added if unredlying controllers request it
)
type Cluster struct {
metav1.TypeMeta `json:",inline"`
// Standard objects 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 ClusterSpec `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 ClusterStatus `json:"status"`
}
type ClusterSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
GoogleKubernetesEngineConfig *GoogleKubernetesEngineConfig `json:"googleKubernetesEngineConfig,omitempty"`
AzureKubernetesServiceConfig *AzureKubernetesServiceConfig `json:"azureKubernetesServiceConfig,omitempty"`
RancherKubernetesEngineConfig *RancherKubernetesEngineConfig `json:"rancherKubernetesEngineConfig,omitempty"`
}
type ClusterStatus struct {
//Conditions represent the latest available observations of an object's current state:
//More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties
Conditions []ClusterCondition `json:"conditions,omitempty"`
//Component statuses will represent cluster's components (etcd/controller/scheduler) health
// https://kubernetes.io/docs/api-reference/v1.8/#componentstatus-v1-core
ComponentStatuses []ClusterComponentStatus `json:"componentStatuses,omitempty"`
APIEndpoint string `json:"apiEndpoint,omitempty"`
ServiceAccountToken string `json:"serviceAccountToken,omitempty"`
CACert string `json:"caCert,omitempty"`
Capacity v1.ResourceList `json:"capacity,omitempty"`
Allocatable v1.ResourceList `json:"allocatable,omitempty"`
AppliedSpec ClusterSpec `json:"appliedSpec,omitempty"`
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
}
type ClusterComponentStatus struct {
Name string `json:"name"`
Conditions []v1.ComponentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"`
}
type ClusterCondition struct {
// Type of cluster condition.
Type ClusterConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type GoogleKubernetesEngineConfig struct {
// ProjectID is the ID of your project to use when creating a cluster
ProjectID string `json:"projectId,omitempty"`
// The zone to launch the cluster
Zone string `json:"zone,omitempty"`
// The IP address range of the container pods
ClusterIpv4Cidr string `json:"clusterIpv4Cidr,omitempty"`
// An optional description of this cluster
Description string `json:"description,omitempty"`
// The number of nodes in this cluster
NodeCount int64 `json:"nodeCount,omitempty"`
// Size of the disk attached to each node
DiskSizeGb int64 `json:"diskSizeGb,omitempty"`
// The name of a Google Compute Engine
MachineType string `json:"machineType,omitempty"`
// Node kubernetes version
NodeVersion string `json:"nodeVersion,omitempty"`
// the master kubernetes version
MasterVersion string `json:"masterVersion,omitempty"`
// The map of Kubernetes labels (key/value pairs) to be applied
// to each node.
Labels map[string]string `json:"labels,omitempty"`
// The content of the credential file(key.json)
Credential string `json:"credential,omitempty"`
// Enable alpha feature
EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty"`
}
type AzureKubernetesServiceConfig struct {
//TBD
}
type RancherKubernetesEngineConfig struct {
// Kubernetes nodes
Nodes []RKEConfigNode `yaml:"nodes" json:"nodes,omitempty"`
// Kubernetes components
Services RKEConfigServices `yaml:"services" json:"services,omitempty"`
// Network configuration used in the kubernetes cluster (flannel, calico)
Network NetworkConfig `yaml:"network" json:"network,omitempty"`
// Authentication configuration used in the cluster (default: x509)
Authentication AuthConfig `yaml:"auth" json:"auth,omitempty"`
// YAML manifest for user provided addons to be deployed on the cluster
Addons string `yaml:"addons" json:"addons,omitempty"`
// List of images used internally for proxy, cert downlaod and kubedns
SystemImages map[string]string `yaml:"system_images" json:"systemImages,omitempty"`
// SSH Private Key Path
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
}
type RKEConfigNode struct {
// 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
InternalAddress string `yaml:"internal_address" json:"internalAddress,omitempty"`
// Node role in kubernetes cluster (controlplane, worker, or etcd)
Role []string `yaml:"role" json:"role,omitempty"`
// Optional - Hostname of the node
HostnameOverride string `yaml:"hostname_override" json:"hostnameOverride,omitempty"`
// SSH usesr that will be used by RKE
User string `yaml:"user" json:"user,omitempty"`
// Optional - Docker socket on the node that will be used in tunneling
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
// SSH Private Key
SSHKey string `yaml:"ssh_key" json:"sshKey,omitempty"`
// SSH Private Key Path
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
}
type RKEConfigServices struct {
// Etcd Service
Etcd ETCDService `yaml:"etcd" json:"etcd,omitempty"`
// KubeAPI Service
KubeAPI KubeAPIService `yaml:"kube-api" json:"kubeApi,omitempty"`
// KubeController Service
KubeController KubeControllerService `yaml:"kube-controller" json:"kubeController,omitempty"`
// Scheduler Service
Scheduler SchedulerService `yaml:"scheduler" json:"scheduler,omitempty"`
// Kubelet Service
Kubelet KubeletService `yaml:"kubelet" json:"kubelet,omitempty"`
// KubeProxy Service
Kubeproxy KubeproxyService `yaml:"kubeproxy" json:"kubeproxy,omitempty"`
}
type ETCDService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
}
type KubeAPIService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
// Virtual IP range that will be used by Kubernetes services
ServiceClusterIPRange string `yaml:"service_cluster_ip_range" json:"serviceClusterIpRange,omitempty"`
}
type KubeControllerService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
// CIDR Range for Pods in cluster
ClusterCIDR string `yaml:"cluster_cidr" json:"clusterCidr,omitempty"`
// Virtual IP range that will be used by Kubernetes services
ServiceClusterIPRange string `yaml:"service_cluster_ip_range" json:"serviceClusterIpRange,omitempty"`
}
type KubeletService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
// Domain of the cluster (default: "cluster.local")
ClusterDomain string `yaml:"cluster_domain" json:"clusterDomain,omitempty"`
// The image whose network/ipc namespaces containers in each pod will use
InfraContainerImage string `yaml:"infra_container_image" json:"infraContainerImage,omitempty"`
// Cluster DNS service ip
ClusterDNSServer string `yaml:"cluster_dns_server" json:"clusterDnsServer,omitempty"`
}
type KubeproxyService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
}
type SchedulerService struct {
// Base service properties
BaseService `yaml:",inline" json:",inline"`
}
type BaseService struct {
// Docker image of the service
Image string `yaml:"image" json:"image,omitempty"`
// Extra arguments that are added to the services
ExtraArgs map[string]string `yaml:"extra_args" json:"extraArgs,omitempty"`
}
type NetworkConfig struct {
// Network Plugin That will be used in kubernetes cluster
Plugin string `yaml:"plugin" json:"plugin,omitempty"`
// Plugin options to configure network properties
Options map[string]string `yaml:"options" json:"options,omitempty"`
}
type AuthConfig struct {
// Authentication strategy that will be used in kubernetes cluster
Strategy string `yaml:"strategy" json:"strategy,omitempty"`
// Authentication options
Options map[string]string `yaml:"options" json:"options,omitempty"`
}
type ClusterNode struct {
metav1.TypeMeta `json:",inline"`
// Standard objects 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 cluster node. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
v1.NodeSpec `json:"spec,omitempty"`
// 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 ClusterNodeStatus `json:"status"`
NodeName string
ClusterName string
}
type ClusterNodeStatus struct {
v1.NodeStatus
Requested v1.ResourceList `json:"requested,omitempty"`
Limits v1.ResourceList `json:"limits,omitempty"`
}
type MachineTemplate struct {
metav1.TypeMeta `json:",inline"`
// Standard objects 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"`
// 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"`
}
type MachineTemplateStatus struct {
Conditions []MachineTemplateCondition `json:"conditions"`
}
type MachineTemplateCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineTemplateSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
FlavorPrefix string `json:"flavorPrefix"`
Driver string `json:"driver"`
SecretValues map[string]string `json:"secretValues"`
SecretName string `norman:"type=reference[/v1-cluster/schemas/globalSecret]"`
PublicValues map[string]string `json:"publicValues"`
}
type Machine struct {
metav1.TypeMeta `json:",inline"`
// Standard objects 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 MachineSpec `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"`
}
type MachineStatus struct {
Conditions []MachineCondition `json:"conditions"`
}
type MachineCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineSpec struct {
ClusterName string `norman:"type=reference[cluster]"`
ExternalID string `json:"externalId"`
MachineTemplateName string `norman:"type=reference[machineTemplate]"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Hostname string `json:"hostname"`
Driver string `json:"driver"`
MachineGeneralParams `json:",inline"`
AmazonEC2Config AmazonEC2Config `json:"amazonEc2Config"`
AzureConfig AzureConfig `json:"azureConfig"`
DigitalOceanConfig DigitalOceanConfig `json:"digitalOceanConfig"`
}
type AmazonEC2Config struct {
}
type AzureConfig struct {
}
type DigitalOceanConfig struct {
}
type MachineGeneralParams struct {
AuthCertificateAuthority string `json:"authCertificateAuthority"`
AuthKey string `json:"authKey"`
EngineInstallURL string `json:"engineInstallURL"`
DockerVersion string `json:"dockerVersion"`
EngineOpt map[string]string `json:"engineOpt"`
EngineInsecureRegistry []string `json:"engineInsecureRegistry"`
EngineRegistryMirror []string `json:"engineRegistryMirror"`
EngineLabel map[string]string `json:"engineLabel"`
EngineStorageDriver string `json:"engineStorageDriver"`
EngineEnv map[string]string `json:"engineEnv"`
}
type MachineDriver struct {
metav1.TypeMeta `json:",inline"`
// Standard objects 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"`
// 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"`
}
type MachineDriverStatus struct {
Conditions []MachineDriverCondition `json:"conditions"`
}
type MachineDriverCondition struct {
// Type of cluster condition.
Type string `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type MachineDriverSpec struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
URL string `json:"url"`
ExternalID string `json:"externalId"`
Builtin bool `json:"builtin"`
DefaultActive bool `json:"defaultActive"`
ActivateOnCreate bool `json:"activateOnCreate"`
Checksum string `json:"checksum"`
UIURL string `json:"uiUrl"`
}

View File

@@ -0,0 +1,43 @@
package schema
import (
"github.com/rancher/norman/types"
m "github.com/rancher/norman/types/mapper"
"github.com/rancher/types/factory"
"github.com/rancher/types/mapper"
"k8s.io/api/core/v1"
)
var (
Version = types.APIVersion{
Version: "v3",
Group: "cluster.cattle.io",
Path: "/v3/clusters",
}
Schemas = factory.Schemas(&Version).
Init(nodeTypes)
)
func nodeTypes(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.SliceToMap{Field: "volumesAttached", Key: "devicePath"},
).
AddMapperForType(&Version, v1.Node{},
&m.Embed{Field: "status"},
&m.Drop{Field: "conditions"},
).
MustImport(&Version, v1.NodeStatus{}, struct {
IPAddress string
Hostname string
Info NodeInfo
}{}).
MustImport(&Version, v1.Node{})
}

View File

@@ -0,0 +1,27 @@
package schema
type NodeInfo struct {
CPU CPUInfo
Memory MemoryInfo
OS OSInfo
Kubernetes KubernetesInfo
}
type CPUInfo struct {
Count int64
}
type MemoryInfo struct {
MemTotalKiB int64
}
type OSInfo struct {
DockerVersion string
KernelVersion string
OperatingSystem string
}
type KubernetesInfo struct {
KubeletVersion string
KubeProxyVersion string
}