mirror of
https://github.com/rancher/types.git
synced 2025-05-06 22:26:18 +00:00
API Updates
This commit is contained in:
parent
6106f4926c
commit
68600ed35d
apis
authorization.cattle.io/v1/schema
cluster.cattle.io
management.cattle.io/v3
project.cattle.io/v3
config
main.gomapper
status
@ -1,42 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
"github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/authorization.cattle.io/v1"
|
||||
"github.com/rancher/types/factory"
|
||||
)
|
||||
|
||||
var (
|
||||
Version = types.APIVersion{
|
||||
Version: "v1",
|
||||
Group: "authorization.cattle.io",
|
||||
Path: "/v1-authz",
|
||||
}
|
||||
|
||||
Schemas = factory.Schemas(&Version).
|
||||
AddMapperForType(&Version, v1.Project{},
|
||||
mapper.DisplayName{},
|
||||
).
|
||||
AddMapperForType(&Version, v1.ProjectRoleTemplateBinding{},
|
||||
&mapper.Move{From: "subject/name", To: "subjectName"},
|
||||
&mapper.Move{From: "subject/kind", To: "subjectKind"},
|
||||
&mapper.Move{From: "subject/namespace", To: "subjectNamespace"},
|
||||
&mapper.Drop{Field: "subject"},
|
||||
).
|
||||
MustImportAndCustomize(&Version, v1.Project{}, func(schema *types.Schema) {
|
||||
schema.SubContext = "projects"
|
||||
}).
|
||||
MustImport(&Version, v1.ProjectRoleTemplate{}).
|
||||
MustImport(&Version, v1.PodSecurityPolicyTemplate{}).
|
||||
MustImport(&Version, v1.ClusterRoleTemplate{}).
|
||||
MustImport(&Version, v1.ClusterRoleTemplateBinding{}).
|
||||
MustImportAndCustomize(&Version, v1.ProjectRoleTemplateBinding{}, func(schema *types.Schema) {
|
||||
schema.MustCustomizeField("subjectKind", func(field types.Field) types.Field {
|
||||
field.Type = "enum"
|
||||
field.Options = []string{"User", "Group", "ServiceAccount"}
|
||||
field.Nullable = false
|
||||
return field
|
||||
})
|
||||
})
|
||||
)
|
@ -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{})
|
||||
)
|
@ -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 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 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 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 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 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"`
|
||||
// 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 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 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 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"`
|
||||
// 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"`
|
||||
}
|
43
apis/cluster.cattle.io/v3/schema/schema.go
Normal file
43
apis/cluster.cattle.io/v3/schema/schema.go
Normal 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{})
|
||||
}
|
27
apis/cluster.cattle.io/v3/schema/types.go
Normal file
27
apis/cluster.cattle.io/v3/schema/types.go
Normal 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
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package v3
|
||||
|
||||
import (
|
||||
extv1 "k8s.io/api/extensions/v1beta1"
|
||||
@ -15,7 +15,7 @@ type Project struct {
|
||||
|
||||
type ProjectSpec struct {
|
||||
DisplayName string `json:"displayName,omitempty" norman:"required"`
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[/v1-cluster/schemas/cluster]"`
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"`
|
||||
}
|
||||
|
||||
type ProjectRoleTemplate struct {
|
||||
@ -61,6 +61,6 @@ type ClusterRoleTemplateBinding struct {
|
||||
|
||||
Subject rbacv1.Subject `json:"subject,omitempty"`
|
||||
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[/v1-cluster/schemas/cluster]"`
|
||||
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster]"`
|
||||
ClusterRoleTemplateName string `json:"clusterRoleTemplateName,omitempty" norman:"type=reference[clusterRoleTemplate]"`
|
||||
}
|
110
apis/management.cattle.io/v3/cluster_types.go
Normal file
110
apis/management.cattle.io/v3/cluster_types.go
Normal file
@ -0,0 +1,110 @@
|
||||
package v3
|
||||
|
||||
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 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 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
|
||||
}
|
160
apis/management.cattle.io/v3/machine_types.go
Normal file
160
apis/management.cattle.io/v3/machine_types.go
Normal file
@ -0,0 +1,160 @@
|
||||
package v3
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type MachineTemplate 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"`
|
||||
// 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 `json:"secretName"`
|
||||
PublicValues map[string]string `json:"publicValues"`
|
||||
}
|
||||
|
||||
type Machine 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 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"`
|
||||
Node v1.Node `json:"node"`
|
||||
NodeName string `json:"nodeName"`
|
||||
ClusterName string `json:"clusterName" norman:"reference[cluster]"`
|
||||
Requested v1.ResourceList `json:"requested,omitempty"`
|
||||
Limits v1.ResourceList `json:"limits,omitempty"`
|
||||
}
|
||||
|
||||
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"`
|
||||
|
||||
MachineCommonParams `json:",inline"`
|
||||
AmazonEC2Config AmazonEC2Config `json:"amazonEc2Config"`
|
||||
AzureConfig AzureConfig `json:"azureConfig"`
|
||||
DigitalOceanConfig DigitalOceanConfig `json:"digitalOceanConfig"`
|
||||
}
|
||||
|
||||
type AmazonEC2Config struct {
|
||||
}
|
||||
|
||||
type AzureConfig struct {
|
||||
}
|
||||
|
||||
type DigitalOceanConfig struct {
|
||||
}
|
||||
|
||||
type MachineCommonParams 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 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"`
|
||||
// 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"`
|
||||
}
|
115
apis/management.cattle.io/v3/rke_types.go
Normal file
115
apis/management.cattle.io/v3/rke_types.go
Normal file
@ -0,0 +1,115 @@
|
||||
package v3
|
||||
|
||||
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"`
|
||||
}
|
71
apis/management.cattle.io/v3/schema/schema.go
Normal file
71
apis/management.cattle.io/v3/schema/schema.go
Normal file
@ -0,0 +1,71 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
"github.com/rancher/types/factory"
|
||||
)
|
||||
|
||||
var (
|
||||
Version = types.APIVersion{
|
||||
Version: "v3",
|
||||
Group: "management.cattle.io",
|
||||
Path: "/v3",
|
||||
}
|
||||
|
||||
Schemas = factory.Schemas(&Version).
|
||||
Init(machineTypes).
|
||||
Init(authTypes).
|
||||
Init(clusterTypes)
|
||||
)
|
||||
|
||||
func clusterTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v3.Cluster{},
|
||||
m.DisplayName{},
|
||||
&m.Embed{Field: "status"},
|
||||
).
|
||||
AddMapperForType(&Version, v3.ClusterStatus{},
|
||||
m.Drop{"appliedSpec"},
|
||||
).
|
||||
MustImport(&Version, v3.Cluster{})
|
||||
}
|
||||
|
||||
func authTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v3.Project{},
|
||||
m.DisplayName{},
|
||||
).
|
||||
AddMapperForType(&Version, v3.ProjectRoleTemplateBinding{},
|
||||
&m.Move{From: "subject/name", To: "subjectName"},
|
||||
&m.Move{From: "subject/kind", To: "subjectKind"},
|
||||
&m.Move{From: "subject/namespace", To: "subjectNamespace"},
|
||||
&m.Drop{Field: "subject"},
|
||||
).
|
||||
MustImportAndCustomize(&Version, v3.Project{}, func(schema *types.Schema) {
|
||||
schema.SubContext = "projects"
|
||||
}).
|
||||
MustImport(&Version, v3.ProjectRoleTemplate{}).
|
||||
MustImport(&Version, v3.PodSecurityPolicyTemplate{}).
|
||||
MustImport(&Version, v3.ClusterRoleTemplate{}).
|
||||
MustImport(&Version, v3.ClusterRoleTemplateBinding{}).
|
||||
MustImportAndCustomize(&Version, v3.ProjectRoleTemplateBinding{}, func(schema *types.Schema) {
|
||||
schema.MustCustomizeField("subjectKind", func(field types.Field) types.Field {
|
||||
field.Type = "enum"
|
||||
field.Options = []string{"User", "Group", "ServiceAccount"}
|
||||
field.Nullable = false
|
||||
return field
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func machineTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v3.Machine{}, m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.MachineDriver{}, m.DisplayName{}).
|
||||
AddMapperForType(&Version, v3.MachineTemplate{}, m.DisplayName{}).
|
||||
MustImport(&Version, v3.Machine{}).
|
||||
MustImport(&Version, v3.MachineDriver{}).
|
||||
MustImport(&Version, v3.MachineTemplate{})
|
||||
}
|
@ -3,7 +3,7 @@ package schema
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
workloadv1 "github.com/rancher/types/apis/workload.cattle.io/v1"
|
||||
"github.com/rancher/types/apis/project.cattle.io/v3"
|
||||
"github.com/rancher/types/factory"
|
||||
"github.com/rancher/types/mapper"
|
||||
"k8s.io/api/core/v1"
|
||||
@ -12,9 +12,9 @@ import (
|
||||
|
||||
var (
|
||||
Version = types.APIVersion{
|
||||
Version: "v1",
|
||||
Group: "workload.cattle.io",
|
||||
Path: "/v1-workload",
|
||||
Version: "v3",
|
||||
Group: "project.cattle.io",
|
||||
Path: "/v3/projects",
|
||||
SubContexts: map[string]bool{
|
||||
"projects": true,
|
||||
},
|
||||
@ -24,7 +24,6 @@ var (
|
||||
// Namespace must be first
|
||||
Init(namespaceTypes).
|
||||
Init(podTypes).
|
||||
Init(nodeTypes).
|
||||
Init(deploymentTypes).
|
||||
Init(statefulSetTypes).
|
||||
Init(replicaSet).
|
||||
@ -33,14 +32,35 @@ var (
|
||||
Init(workloadTypes)
|
||||
)
|
||||
|
||||
func namespaceTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v1.NamespaceStatus{},
|
||||
&m.Drop{Field: "phase"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.NamespaceSpec{},
|
||||
&m.Drop{Field: "finalizers"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.Namespace{},
|
||||
&m.LabelField{Field: "projectId"},
|
||||
).
|
||||
MustImport(&Version, v1.Namespace{}, struct {
|
||||
ProjectID string `norman:"type=reference[/v3/schemas/project]"`
|
||||
Templates map[string]string
|
||||
Answers map[string]interface{}
|
||||
Prune bool
|
||||
ExternalID string
|
||||
Tags []string
|
||||
}{})
|
||||
}
|
||||
|
||||
func workloadTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, workloadv1.WorkloadSpec{},
|
||||
AddMapperForType(&Version, v3.WorkloadSpec{},
|
||||
&m.Embed{Field: "deployConfig"},
|
||||
&m.Embed{Field: "template"},
|
||||
).
|
||||
AddMapperForType(&Version, workloadv1.Workload{}, mapper.NewWorkloadTypeMapper()).
|
||||
MustImport(&Version, workloadv1.Workload{}, projectOverride{})
|
||||
AddMapperForType(&Version, v3.Workload{}, mapper.NewWorkloadTypeMapper()).
|
||||
MustImport(&Version, v3.Workload{}, projectOverride{})
|
||||
}
|
||||
|
||||
func statefulSetTypes(schemas *types.Schemas) *types.Schemas {
|
||||
@ -176,49 +196,6 @@ func deploymentTypes(schemas *types.Schemas) *types.Schemas {
|
||||
}, projectOverride{})
|
||||
}
|
||||
|
||||
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{})
|
||||
}
|
||||
|
||||
func namespaceTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v1.NamespaceStatus{},
|
||||
&m.Drop{Field: "phase"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.NamespaceSpec{},
|
||||
&m.Drop{Field: "finalizers"},
|
||||
).
|
||||
AddMapperForType(&Version, v1.Namespace{},
|
||||
&m.LabelField{Field: "projectId"},
|
||||
).
|
||||
MustImport(&Version, v1.Namespace{}, projectOverride{}, struct {
|
||||
Templates map[string]string
|
||||
Answers map[string]interface{}
|
||||
Prune bool
|
||||
ExternalID string
|
||||
Tags []string
|
||||
}{})
|
||||
}
|
||||
|
||||
func podTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
AddMapperForType(&Version, v1.PodTemplateSpec{},
|
@ -3,7 +3,7 @@ package schema
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
m "github.com/rancher/norman/types/mapper"
|
||||
"github.com/rancher/types/apis/workload.cattle.io/v1"
|
||||
"github.com/rancher/types/apis/project.cattle.io/v3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@ -73,37 +73,11 @@ type NodeScheduling struct {
|
||||
Preferred []string
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
type deployOverride struct {
|
||||
v1.DeployConfig
|
||||
v3.DeployConfig
|
||||
}
|
||||
|
||||
type projectOverride struct {
|
||||
types.Namespaced
|
||||
ProjectID string `norman:"type=reference[/v1-authz/schemas/project]"`
|
||||
ProjectID string `norman:"type=reference[/v3/schemas/project]"`
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package v1
|
||||
package v3
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
@ -6,64 +6,56 @@ import (
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/signal"
|
||||
appsv1beta2 "github.com/rancher/types/apis/apps/v1beta2"
|
||||
authzv1 "github.com/rancher/types/apis/authorization.cattle.io/v1"
|
||||
clusterv1 "github.com/rancher/types/apis/cluster.cattle.io/v1"
|
||||
corev1 "github.com/rancher/types/apis/core/v1"
|
||||
workloadv1 "github.com/rancher/types/apis/workload.cattle.io/v1"
|
||||
managementv3 "github.com/rancher/types/apis/management.cattle.io/v3"
|
||||
projectv3 "github.com/rancher/types/apis/project.cattle.io/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type ClusterContext struct {
|
||||
type ManagementContext struct {
|
||||
RESTConfig rest.Config
|
||||
UnversionedClient rest.Interface
|
||||
|
||||
Cluster clusterv1.Interface
|
||||
Authorization authzv1.Interface
|
||||
Management managementv3.Interface
|
||||
}
|
||||
|
||||
func (c *ClusterContext) controllers() []controller.Starter {
|
||||
func (c *ManagementContext) controllers() []controller.Starter {
|
||||
return []controller.Starter{
|
||||
c.Cluster,
|
||||
c.Authorization,
|
||||
c.Management,
|
||||
}
|
||||
}
|
||||
|
||||
type WorkloadContext struct {
|
||||
Cluster *ClusterContext
|
||||
type ClusterContext struct {
|
||||
Management *ManagementContext
|
||||
ClusterName string
|
||||
RESTConfig rest.Config
|
||||
UnversionedClient rest.Interface
|
||||
K8sClient kubernetes.Interface
|
||||
|
||||
Apps appsv1beta2.Interface
|
||||
Workload workloadv1.Interface
|
||||
Core corev1.Interface
|
||||
Apps appsv1beta2.Interface
|
||||
Project projectv3.Interface
|
||||
Core corev1.Interface
|
||||
}
|
||||
|
||||
func (w *WorkloadContext) controllers() []controller.Starter {
|
||||
func (w *ClusterContext) controllers() []controller.Starter {
|
||||
return []controller.Starter{
|
||||
w.Apps,
|
||||
w.Workload,
|
||||
w.Project,
|
||||
w.Core,
|
||||
}
|
||||
}
|
||||
|
||||
func NewClusterContext(config rest.Config) (*ClusterContext, error) {
|
||||
func NewManagementContext(config rest.Config) (*ManagementContext, error) {
|
||||
var err error
|
||||
|
||||
context := &ClusterContext{
|
||||
context := &ManagementContext{
|
||||
RESTConfig: config,
|
||||
}
|
||||
|
||||
context.Cluster, err = clusterv1.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.Authorization, err = authzv1.NewForConfig(config)
|
||||
context.Management, err = managementv3.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -82,26 +74,26 @@ func NewClusterContext(config rest.Config) (*ClusterContext, error) {
|
||||
return context, err
|
||||
}
|
||||
|
||||
func (c *ClusterContext) Start(ctx context.Context) error {
|
||||
logrus.Info("Starting cluster controllers")
|
||||
func (c *ManagementContext) Start(ctx context.Context) error {
|
||||
logrus.Info("Starting management controllers")
|
||||
return controller.SyncThenSync(ctx, 5, c.controllers()...)
|
||||
}
|
||||
|
||||
func (c *ClusterContext) StartAndWait() error {
|
||||
func (c *ManagementContext) StartAndWait() error {
|
||||
ctx := signal.SigTermCancelContext(context.Background())
|
||||
c.Start(ctx)
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func NewWorkloadContext(clusterConfig, config rest.Config, clusterName string) (*WorkloadContext, error) {
|
||||
func NewClusterContext(clusterConfig, config rest.Config, clusterName string) (*ClusterContext, error) {
|
||||
var err error
|
||||
context := &WorkloadContext{
|
||||
context := &ClusterContext{
|
||||
RESTConfig: config,
|
||||
ClusterName: clusterName,
|
||||
}
|
||||
|
||||
context.Cluster, err = NewClusterContext(clusterConfig)
|
||||
context.Management, err = NewManagementContext(clusterConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -116,12 +108,12 @@ func NewWorkloadContext(clusterConfig, config rest.Config, clusterName string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.Workload, err = workloadv1.NewForConfig(config)
|
||||
context.Core, err = corev1.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
context.Core, err = corev1.NewForConfig(config)
|
||||
context.Project, err = projectv3.NewForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -140,14 +132,14 @@ func NewWorkloadContext(clusterConfig, config rest.Config, clusterName string) (
|
||||
return context, err
|
||||
}
|
||||
|
||||
func (w *WorkloadContext) Start(ctx context.Context) error {
|
||||
logrus.Info("Starting workload controllers")
|
||||
controllers := w.Cluster.controllers()
|
||||
func (w *ClusterContext) Start(ctx context.Context) error {
|
||||
logrus.Info("Starting cluster controllers")
|
||||
controllers := w.Management.controllers()
|
||||
controllers = append(controllers, w.controllers()...)
|
||||
return controller.SyncThenSync(ctx, 5, controllers...)
|
||||
}
|
||||
|
||||
func (w *WorkloadContext) StartAndWait() error {
|
||||
func (w *ClusterContext) StartAndWait() error {
|
||||
ctx := signal.SigTermCancelContext(context.Background())
|
||||
w.Start(ctx)
|
||||
<-ctx.Done()
|
||||
|
10
main.go
10
main.go
@ -4,18 +4,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
authzSchema "github.com/rancher/types/apis/authorization.cattle.io/v1/schema"
|
||||
clusterSchema "github.com/rancher/types/apis/cluster.cattle.io/v1/schema"
|
||||
workloadSchema "github.com/rancher/types/apis/workload.cattle.io/v1/schema"
|
||||
clusterSchema "github.com/rancher/types/apis/cluster.cattle.io/v3/schema"
|
||||
managementSchema "github.com/rancher/types/apis/management.cattle.io/v3/schema"
|
||||
projectSchema "github.com/rancher/types/apis/project.cattle.io/v3/schema"
|
||||
"github.com/rancher/types/generator"
|
||||
"k8s.io/api/apps/v1beta2"
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func main() {
|
||||
generator.Generate(managementSchema.Schemas)
|
||||
generator.Generate(clusterSchema.Schemas)
|
||||
generator.Generate(workloadSchema.Schemas)
|
||||
generator.Generate(authzSchema.Schemas)
|
||||
generator.Generate(projectSchema.Schemas)
|
||||
// Group by API group
|
||||
generator.GenerateNativeTypes(v1.Pod{}, v1.Node{}, v1.ComponentStatus{})
|
||||
generator.GenerateNativeTypes(v1beta2.Deployment{})
|
||||
|
@ -16,6 +16,13 @@ func (s Status) ToInternal(data map[string]interface{}) {
|
||||
}
|
||||
|
||||
func (s Status) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
|
||||
_, hasSpec := schema.ResourceFields["spec"]
|
||||
_, hasStatus := schema.ResourceFields["status"]
|
||||
|
||||
if !hasSpec || !hasStatus {
|
||||
return nil
|
||||
}
|
||||
|
||||
schema.ResourceFields["state"] = types.Field{
|
||||
CodeName: "State",
|
||||
Type: "string",
|
||||
|
@ -3,6 +3,8 @@ package status
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/rancher/norman/types/convert"
|
||||
"github.com/rancher/norman/types/values"
|
||||
)
|
||||
@ -37,6 +39,11 @@ var conditionMappings = []conditionMapping{
|
||||
Transition: true,
|
||||
State: "activating",
|
||||
},
|
||||
{
|
||||
Name: "Updating",
|
||||
Transition: true,
|
||||
FalseIsGood: true,
|
||||
},
|
||||
{
|
||||
Name: "Progressing",
|
||||
Transition: true,
|
||||
@ -93,10 +100,28 @@ var conditionMappings = []conditionMapping{
|
||||
}
|
||||
|
||||
func Set(data map[string]interface{}) {
|
||||
val, ok := values.GetValue(data, "status", "conditions")
|
||||
val, ok := values.GetValue(data, "metadata", "removed")
|
||||
if ok && val != "" && val != nil {
|
||||
data["state"] = "removing"
|
||||
data["transitioning"] = "yes"
|
||||
|
||||
finalizers, ok := values.GetStringSlice(data, "metadata", "finalizers")
|
||||
if ok && len(finalizers) > 0 {
|
||||
data["transitioningMessage"] = "Waiting on " + finalizers[0]
|
||||
if i, err := convert.ToTimestamp(val); err == nil {
|
||||
if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now()) {
|
||||
data["transitioning"] = "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
val, ok = values.GetValue(data, "status", "conditions")
|
||||
if !ok || val == nil {
|
||||
// TODO: remove
|
||||
data["state"] = "active"
|
||||
data["state"] = "initializing"
|
||||
data["transitioning"] = "yes"
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user