-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move rke types from rancher/types to ./types
- Loading branch information
1 parent
e2b5828
commit 6220341
Showing
10 changed files
with
1,207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build vendor | ||
|
||
package main | ||
|
||
import ( | ||
_ "k8s.io/gengo/examples/deepcopy-gen" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Copyright YEAR Rancher Labs, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/rancher/norman/condition" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
const ( | ||
BackupConditionCreated condition.Cond = "Created" | ||
BackupConditionCompleted condition.Cond = "Completed" | ||
) | ||
|
||
type BackupConfig struct { | ||
// Enable or disable recurring backups in rancher | ||
Enabled *bool `yaml:"enabled" json:"enabled,omitempty" norman:"default=true"` | ||
// Backup interval in hours | ||
IntervalHours int `yaml:"interval_hours" json:"intervalHours,omitempty" norman:"default=12"` | ||
// Number of backups to keep | ||
Retention int `yaml:"retention" json:"retention,omitempty" norman:"default=6"` | ||
// s3 target | ||
S3BackupConfig *S3BackupConfig `yaml:",omitempty" json:"s3BackupConfig"` | ||
// replace special characters in snapshot names | ||
SafeTimestamp bool `yaml:"safe_timestamp" json:"safeTimestamp,omitempty"` | ||
} | ||
|
||
type S3BackupConfig struct { | ||
// Access key ID | ||
AccessKey string `yaml:"access_key" json:"accessKey,omitempty"` | ||
// Secret access key | ||
SecretKey string `yaml:"secret_key" json:"secretKey,omitempty" norman:"type=password" ` | ||
// name of the bucket to use for backup | ||
BucketName string `yaml:"bucket_name" json:"bucketName,omitempty"` | ||
// AWS Region, AWS spcific | ||
Region string `yaml:"region" json:"region,omitempty"` | ||
// Endpoint is used if this is not an AWS API | ||
Endpoint string `yaml:"endpoint" json:"endpoint"` | ||
// CustomCA is used to connect to custom s3 endpoints | ||
CustomCA string `yaml:"custom_ca" json:"customCa,omitempty"` | ||
// Folder to place the files | ||
Folder string `yaml:"folder" json:"folder,omitempty"` | ||
} | ||
|
||
type EtcdBackupSpec struct { | ||
// cluster ID | ||
ClusterID string `json:"clusterId,omitempty" norman:"required,type=reference[cluster],noupdate"` | ||
// manual backup flag | ||
Manual bool `yaml:"manual" json:"manual,omitempty"` | ||
// actual file name on the target | ||
Filename string `yaml:"filename" json:"filename,omitempty" norman:"noupdate"` | ||
// backupConfig | ||
BackupConfig BackupConfig `yaml:",omitempty" json:"backupConfig,omitempty" norman:"noupdate"` | ||
} | ||
|
||
type EtcdBackupStatus struct { | ||
Conditions []EtcdBackupCondition `json:"conditions"` | ||
// version of k8s in the backup pulled from rke config | ||
KubernetesVersion string `yaml:"kubernetesVersion" json:"kubernetesVersion,omitempty" norman:"noupdate"` | ||
// json + gzipped + base64 backup of the cluster object when the backup was created | ||
ClusterObject string `yaml:"clusterObject" json:"clusterObject,omitempty" norman:"type=password,noupdate"` | ||
} | ||
|
||
type EtcdBackupCondition struct { | ||
// Type of 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"` | ||
// Human-readable message indicating details about last transition | ||
Message string `json:"message,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// +k8s:deepcopy-gen=package | ||
|
||
package types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package types | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// LimitType is the type of the limit (e.g., per-namespace) | ||
type LimitType string | ||
|
||
const ( | ||
// ServerLimitType is a type of limit where there is one bucket shared by | ||
// all of the event queries received by the API Server. | ||
ServerLimitType LimitType = "Server" | ||
// NamespaceLimitType is a type of limit where there is one bucket used by | ||
// each namespace | ||
NamespaceLimitType LimitType = "Namespace" | ||
// UserLimitType is a type of limit where there is one bucket used by each | ||
// user | ||
UserLimitType LimitType = "User" | ||
// SourceAndObjectLimitType is a type of limit where there is one bucket used | ||
// by each combination of source and involved object of the event. | ||
SourceAndObjectLimitType LimitType = "SourceAndObject" | ||
) | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Configuration provides configuration for the EventRateLimit admission | ||
// controller. | ||
type Configuration struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// limits are the limits to place on event queries received. | ||
// Limits can be placed on events received server-wide, per namespace, | ||
// per user, and per source+object. | ||
// At least one limit is required. | ||
Limits []Limit `json:"limits"` | ||
} | ||
|
||
// Limit is the configuration for a particular limit type | ||
type Limit struct { | ||
// type is the type of limit to which this configuration applies | ||
Type LimitType `json:"type"` | ||
|
||
// qps is the number of event queries per second that are allowed for this | ||
// type of limit. The qps and burst fields are used together to determine if | ||
// a particular event query is accepted. The qps determines how many queries | ||
// are accepted once the burst amount of queries has been exhausted. | ||
QPS int32 `json:"qps"` | ||
|
||
// burst is the burst number of event queries that are allowed for this type | ||
// of limit. The qps and burst fields are used together to determine if a | ||
// particular event query is accepted. The burst determines the maximum size | ||
// of the allowance granted for a particular bucket. For example, if the burst | ||
// is 10 and the qps is 3, then the admission control will accept 10 queries | ||
// before blocking any queries. Every second, 3 more queries will be allowed. | ||
// If some of that allowance is not used, then it will roll over to the next | ||
// second, until the maximum allowance of 10 is reached. | ||
Burst int32 `json:"burst"` | ||
|
||
// cacheSize is the size of the LRU cache for this type of limit. If a bucket | ||
// is evicted from the cache, then the allowance for that bucket is reset. If | ||
// more queries are later received for an evicted bucket, then that bucket | ||
// will re-enter the cache with a clean slate, giving that bucket a full | ||
// allowance of burst queries. | ||
// | ||
// The default cache size is 4096. | ||
// | ||
// If limitType is 'server', then cacheSize is ignored. | ||
// +optional | ||
CacheSize int32 `json:"cacheSize,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package image | ||
|
||
import "strings" | ||
|
||
var Mirrors = map[string]string{} | ||
|
||
func Mirror(image string) string { | ||
orig := image | ||
if strings.HasPrefix(image, "weaveworks") { | ||
return image | ||
} | ||
|
||
image = strings.Replace(image, "gcr.io/google_containers", "rancher", 1) | ||
image = strings.Replace(image, "quay.io/coreos/", "rancher/coreos-", 1) | ||
image = strings.Replace(image, "quay.io/calico/", "rancher/calico-", 1) | ||
image = strings.Replace(image, "plugins/docker", "rancher/plugins-docker", 1) | ||
image = strings.Replace(image, "k8s.gcr.io/defaultbackend", "rancher/nginx-ingress-controller-defaultbackend", 1) | ||
image = strings.Replace(image, "k8s.gcr.io/k8s-dns-node-cache", "rancher/k8s-dns-node-cache", 1) | ||
image = strings.Replace(image, "plugins/docker", "rancher/plugins-docker", 1) | ||
image = strings.Replace(image, "kibana", "rancher/kibana", 1) | ||
image = strings.Replace(image, "jenkins/", "rancher/jenkins-", 1) | ||
image = strings.Replace(image, "alpine/git", "rancher/alpine-git", 1) | ||
image = strings.Replace(image, "prom/", "rancher/prom-", 1) | ||
image = strings.Replace(image, "quay.io/pires", "rancher", 1) | ||
image = strings.Replace(image, "coredns/", "rancher/coredns-", 1) | ||
image = strings.Replace(image, "minio/", "rancher/minio-", 1) | ||
|
||
Mirrors[image] = orig | ||
return image | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// +k8s:deepcopy-gen=package | ||
|
||
package kdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package kdm | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
v3 "github.com/rancher/rke/types" | ||
) | ||
|
||
const ( | ||
Calico = "calico" | ||
Canal = "canal" | ||
Flannel = "flannel" | ||
Weave = "weave" | ||
CoreDNS = "coreDNS" | ||
KubeDNS = "kubeDNS" | ||
MetricsServer = "metricsServer" | ||
NginxIngress = "nginxIngress" | ||
Nodelocal = "nodelocal" | ||
TemplateKeys = "templateKeys" | ||
) | ||
|
||
// +k8s:deepcopy-gen=false | ||
|
||
type Data struct { | ||
// K8sVersionServiceOptions - service options per k8s version | ||
K8sVersionServiceOptions map[string]v3.KubernetesServicesOptions | ||
K8sVersionRKESystemImages map[string]v3.RKESystemImages | ||
|
||
// Addon Templates per K8s version ("default" where nothing changes for k8s version) | ||
K8sVersionedTemplates map[string]map[string]string | ||
|
||
// K8sVersionInfo - min/max RKE+Rancher versions per k8s version | ||
K8sVersionInfo map[string]v3.K8sVersionInfo | ||
|
||
//Default K8s version for every rancher version | ||
RancherDefaultK8sVersions map[string]string | ||
|
||
//Default K8s version for every rke version | ||
RKEDefaultK8sVersions map[string]string | ||
|
||
K8sVersionDockerInfo map[string][]string | ||
|
||
// K8sVersionWindowsServiceOptions - service options per windows k8s version | ||
K8sVersionWindowsServiceOptions map[string]v3.KubernetesServicesOptions | ||
|
||
CisConfigParams map[string]CisConfigParams | ||
CisBenchmarkVersionInfo map[string]CisBenchmarkVersionInfo | ||
|
||
// K3S specific data, opaque and defined by the config file in kdm | ||
K3S map[string]interface{} `json:"k3s,omitempty"` | ||
} | ||
|
||
func FromData(b []byte) (Data, error) { | ||
d := &Data{} | ||
|
||
if err := json.Unmarshal(b, d); err != nil { | ||
return Data{}, err | ||
} | ||
return *d, nil | ||
} | ||
|
||
type CisBenchmarkVersionInfo struct { | ||
Managed bool `yaml:"managed" json:"managed"` | ||
MinKubernetesVersion string `yaml:"min_kubernetes_version" json:"minKubernetesVersion"` | ||
SkippedChecks map[string]string `yaml:"skipped_checks" json:"skippedChecks"` | ||
NotApplicableChecks map[string]string `yaml:"not_applicable_checks" json:"notApplicableChecks"` | ||
} | ||
|
||
type CisConfigParams struct { | ||
BenchmarkVersion string `yaml:"benchmark_version" json:"benchmarkVersion"` | ||
} |
Oops, something went wrong.