Skip to content

Commit

Permalink
Merge pull request kubernetes#5003 from Andrius521/fix/examples-docum…
Browse files Browse the repository at this point in the history
…entation

Fix/examples documentation
  • Loading branch information
k8s-ci-robot authored Jul 13, 2022
2 parents be74395 + 7717cc8 commit 363e39d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
9 changes: 4 additions & 5 deletions cluster-autoscaler/cloudprovider/cherryservers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ In the above file you can modify the following fields:
| cluster-autoscaler-cherry | authtoken | Your Cherry Servers API token. It must be base64 encoded. |
| cluster-autoscaler-cloud-config | Global/project-id | Your Cherry Servers project id |
| cluster-autoscaler-cloud-config | Global/api-server | The ip:port for you cluster's k8s api (e.g. K8S_MASTER_PUBLIC_IP:6443) |
| cluster-autoscaler-cloud-config | Global/region | The Cherry Servers region for the servers in your nodepool (eg: EU-Nord-1) |
| cluster-autoscaler-cloud-config | Global/plan | The Cherry Servers plan ID for new nodes in the nodepool (eg: `103`) |
| cluster-autoscaler-cloud-config | Global/os | The OS image to use for new nodes, e.g. `CentOS 6 64bit`. If you change this also update cloudinit. |
| cluster-autoscaler-cloud-config | Global/region | The Cherry Servers region slug for the servers in your nodepool (eg: `eu_nord_1`) |
| cluster-autoscaler-cloud-config | Global/plan | The Cherry Servers plan slug for new nodes in the nodepool (eg: `e5_1620v4`) |
| cluster-autoscaler-cloud-config | Global/os | The OS image slug to use for new nodes, e.g. `ubuntu_18_04`. If you change this also update cloudinit. |
| cluster-autoscaler-cloud-config | Global/cloudinit | The base64 encoded user data submitted when provisioning servers. In the example file, the default value has been tested with Ubuntu 18.04 to install Docker & kubelet and then to bootstrap the node into the cluster using kubeadm. The kubeadm, kubelet, kubectl are pinned to version 1.17.4. For a different base OS or bootstrap method, this needs to be customized accordingly. It will use go templates to inject runtime information; see below.|
| cluster-autoscaler-cloud-config | Global/reservation | The values "require" or "prefer" will request the next available hardware reservation for new servers in selected region & plan. If no hardware reservations match, "require" will trigger a failure, while "prefer" will launch on-demand servers instead (default: none) |
| cluster-autoscaler-cloud-config | Global/hostname-pattern | The pattern for the names of new Cherry Servers servers (default: "k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}" ) |
| cluster-autoscaler-cloud-config | Global/os-partition-size | The OS partition size in gigabytes for new nodes in the nodepool (eg: `60`, default: `none`) |

Expand Down Expand Up @@ -92,7 +91,7 @@ affinity:
- key: beta.kubernetes.io/instance-type
operator: In
values:
- 103
- e5_1620v4
```

## CCM and Controller node labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type cherryManagerNodePool struct {
projectID int
apiServerEndpoint string
region string
plan int
plan string
os string
cloudinit string
hostnamePattern string
Expand All @@ -80,7 +80,7 @@ type cherryManagerRest struct {
authToken string
baseURL *url.URL
nodePools map[string]*cherryManagerNodePool
plans map[int]*Plan
plans map[string]*Plan
planUpdate time.Time
}

Expand Down Expand Up @@ -215,10 +215,6 @@ func createCherryManagerRest(configReader io.Reader, discoverOpts cloudprovider.
nodepool.ClusterName = opts.ClusterName
}

plan, err := strconv.ParseInt(nodepool.Plan, 10, 32)
if err != nil {
return nil, fmt.Errorf("invalid plan %s for nodepool %s, must be integer: %v", nodepool.Plan, key, err)
}
var sshKeyIDs []int
for i, keyIDString := range nodepool.SSHKeys {
keyID, err := strconv.ParseInt(keyIDString, 10, 32)
Expand All @@ -232,7 +228,7 @@ func createCherryManagerRest(configReader io.Reader, discoverOpts cloudprovider.
apiServerEndpoint: apiServerEndpoint,
clusterName: nodepool.ClusterName,
region: nodepool.Region,
plan: int(plan),
plan: nodepool.Plan,
os: nodepool.OS,
cloudinit: nodepool.CloudInit,
sshKeyIDs: sshKeyIDs,
Expand Down Expand Up @@ -432,7 +428,7 @@ func (mgr *cherryManagerRest) createNode(ctx context.Context, cloudinit, nodegro
cr := &CreateServer{
Hostname: hn,
Region: mgr.getNodePoolDefinition(nodegroup).region,
PlanID: mgr.getNodePoolDefinition(nodegroup).plan,
Plan: mgr.getNodePoolDefinition(nodegroup).plan,
Image: mgr.getNodePoolDefinition(nodegroup).os,
ProjectID: mgr.getNodePoolDefinition(nodegroup).projectID,
UserData: base64.StdEncoding.EncodeToString([]byte(ud)),
Expand Down Expand Up @@ -642,15 +638,15 @@ func (mgr *cherryManagerRest) templateNodeInfo(nodegroup string) (*schedulerfram
if err != nil {
return nil, fmt.Errorf("unable to update cherry plans: %v", err)
}
mgr.plans = map[int]*Plan{}
mgr.plans = map[string]*Plan{}
for _, plan := range plans {
mgr.plans[plan.ID] = &plan
mgr.plans[plan.Slug] = &plan
}
}
planID := mgr.getNodePoolDefinition(nodegroup).plan
cherryPlan, ok := mgr.plans[planID]
planSlug := mgr.getNodePoolDefinition(nodegroup).plan
cherryPlan, ok := mgr.plans[planSlug]
if !ok {
klog.V(5).Infof("no plan found for planID %d", planID)
klog.V(5).Infof("no plan found for planSlug %s", planSlug)
return nil, fmt.Errorf("cherry plan %q not supported", mgr.getNodePoolDefinition(nodegroup).plan)
}
var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func newTestCherryManagerRest(t *testing.T, serverUrl string) *cherryManagerRest
clusterName: "cluster2",
projectID: 10001,
apiServerEndpoint: "147.75.102.15:6443",
region: "EU-Nord-1",
plan: 116,
region: "eu_nord_1",
plan: "e5_1620v4",
os: "ubuntu_18_04",
cloudinit: cloudinitDefault,
hostnamePattern: "k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}",
Expand All @@ -80,8 +80,8 @@ func newTestCherryManagerRest(t *testing.T, serverUrl string) *cherryManagerRest
clusterName: "cluster2",
projectID: 10001,
apiServerEndpoint: "147.75.102.15:6443",
region: "EU-Nord-1",
plan: 116,
region: "eu_nord_1",
plan: "e5_1620v4",
os: "ubuntu_18_04",
cloudinit: cloudinitDefault,
hostnamePattern: "k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ func TestIncreaseDecreaseSize(t *testing.T) {
w.Write([]byte(`{"error": "invalid body"}`))
return
}
planID := createRequest.PlanID
planSlug := createRequest.Plan
if err != nil {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(400)
w.Write([]byte(`{"error": "invalid plan ID"}`))
w.Write([]byte(`{"error": "invalid plan slug"}`))
return
}
if createRequest.ProjectID != m.nodePools["default"].projectID {
Expand All @@ -104,7 +104,7 @@ func TestIncreaseDecreaseSize(t *testing.T) {
ID: rand.Intn(10000),
Name: createRequest.Hostname,
Hostname: createRequest.Hostname,
Plan: Plan{ID: planID},
Plan: Plan{Slug: planSlug},
Project: Project{ID: projectID},
Image: createRequest.Image,
Tags: *createRequest.Tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Project struct {
// Region a CherryServers region
type Region struct {
ID int `json:"id,omitempty"`
Slug string `json:"slug,omitempty"`
Name string `json:"name,omitempty"`
RegionIso2 string `json:"region_iso_2,omitempty"`
BGP RegionBGP `json:"bgp,omitempty"`
Expand All @@ -70,6 +71,7 @@ type ProjectBGP struct {
// Plan a server plan
type Plan struct {
ID int `json:"id,omitempty"`
Slug string `json:"slug,omitempty"`
Name string `json:"name,omitempty"`
Custom bool `json:"custom,omitempty"`
Specs Specs `json:"specs,omitempty"`
Expand Down Expand Up @@ -252,7 +254,7 @@ type IPAddressCreateRequest struct {
// CreateServer represents a request to create a new Cherry Servers server. Used by createNodes
type CreateServer struct {
ProjectID int `json:"project_id,omitempty"`
PlanID int `json:"plan_id,omitempty"`
Plan string `json:"plan,omitempty"`
Hostname string `json:"hostname,omitempty"`
Image string `json:"image,omitempty"`
Region string `json:"region,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ stringData:
[nodegroupdef "default"]
project-id=YOUR_CHERRYSERVERS_PROJECT_ID
api-server-endpoint=YOUR_KUBERNETES_API_IP_ADDRESS:YOUR_KUBERNETES_API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FbmRwb2ludH19Cg==
hostname-pattern=k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}
[nodegroupdef "pool2"]
project-id=YOUR_CHERRYSERVERS_PROJECT_ID
api-server-endpoint=YOUR_KUBERNETES_API_IP_ADDRESS:YOUR_KUBERNETES_API_PORT
region=EU-Nord-1
region=eu_nord_1
os=ubuntu_18_04
plan=113
plan=e5_1620v4
cloudinit=IyEvYmluL2Jhc2gKc2V0IC14CmV4cG9ydCBERUJJQU5fRlJPTlRFTkQ9bm9uaW50ZXJhY3RpdmUKZXhwb3J0IEs4U19WRVJTSU9OPTEuMjMuMQphcHQtZ2V0IHVwZGF0ZSAmJiBhcHQtZ2V0IGluc3RhbGwgLXkgYXB0LXRyYW5zcG9ydC1odHRwcyBjYS1jZXJ0aWZpY2F0ZXMgY3VybCBzb2Z0d2FyZS1wcm9wZXJ0aWVzLWNvbW1vbgpjdXJsIC1mc1NMIGh0dHBzOi8vZG93bmxvYWQuZG9ja2VyLmNvbS9saW51eC91YnVudHUvZ3BnIHwgYXB0LWtleSBhZGQgLQpjdXJsIC1zIGh0dHBzOi8vcGFja2FnZXMuY2xvdWQuZ29vZ2xlLmNvbS9hcHQvZG9jL2FwdC1rZXkuZ3BnIHwgYXB0LWtleSBhZGQgLQpjYXQgPDxFT0YgPi9ldGMvYXB0L3NvdXJjZXMubGlzdC5kL2t1YmVybmV0ZXMubGlzdApkZWIgaHR0cHM6Ly9hcHQua3ViZXJuZXRlcy5pby8ga3ViZXJuZXRlcy14ZW5pYWwgbWFpbgpFT0YKYWRkLWFwdC1yZXBvc2l0b3J5ICAgImRlYiBbYXJjaD1hbWQ2NF0gaHR0cHM6Ly9kb3dubG9hZC5kb2NrZXIuY29tL2xpbnV4L3VidW50dSAgICQobHNiX3JlbGVhc2UgLWNzKSAgIHN0YWJsZSIKYXB0LWdldCB1cGRhdGUKYXB0LWdldCB1cGdyYWRlIC15CmFwdC1nZXQgaW5zdGFsbCAteSBrdWJlbGV0PSR7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0gam9pbiAtLWRpc2NvdmVyeS10b2tlbi11bnNhZmUtc2tpcC1jYS12ZXJpZmljYXRpb24gLS10b2tlbiB7ey5Cb290c3RyYXBUb2tlbklEfX0ue3suQm9vdHN0cmFwVG9rZW5TZWNyZXR9fSB7ey5BUElTZXJ2ZXJFbmRwb2ludH19Cg==
hostname-pattern=k8s-{{.ClusterName}}-{{.NodeGroup}}-{{.RandString8}}
---
Expand Down

0 comments on commit 363e39d

Please sign in to comment.