Skip to content

Learning Path Digital Ocean Kubernetes , Course Scale Automatically #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: "learning-path"
title: "DigitalOcean Kubernetes (DOKS)"
description: "Thousands of ISVs, startups, and digital businesses run on DigitalOcean today, achieving top performance and unmatched scalability at significant cost savings. With DigitalOcean Kubernetes, you can easily spin up GPU-powered environments, scale workloads, optimize performance with a developer-friendly approach, and automate infrastructure and software delivery."
id: "ba2e362b-9f92-4a24-9039-0e886e710de4"
banner: "digitalocean.svg"
weight: 2
level: "beginner"
---
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
type: "course"
id: "launch-reliably"
title: "How to Enable High Availability"
description: "Increase the reliability of your clusters and prevent scaling issues from fault tolerance, load balancing, and traffic management."
weight: 2
banner: "digitalocean.svg"
tags: ["Kubernetes"]
categories: "Digital-Ocean"
level: "intermediate"
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
type: "page"
id: "enable-high-availability-using-automation"
description: ""
title: "Enable High Availability Using Automation "
weight: 1
---

You can enable high availability using the DigitalOcean Kubernetes `doctl` update command or API endpoint by setting the `ha` value to `true`.


## How to Update a Kubernetes Cluster Using the DigitalOcean CLI

1. Install doctl, the official DigitalOcean CLI.
2. Create a personal access token and save it for use with doctl.
3. Use the token to grant doctl access to your DigitalOcean account.
doctl auth init
Finally, run doctl kubernetes cluster update. Basic usage looks like this, but you can read the usage docs for more details:
doctl kubernetes cluster update <id|name> [flags]
The following example updates a cluster named example-cluster to enable automatic upgrades and sets the maintenance window to saturday=02:00:
doctl kubernetes cluster update example-cluster --auto-upgrade --maintenance-window saturday=02:00

## How to Update a Kubernetes Cluster Using the DigitalOcean API

1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/) and save it for use with the API.
2. Send a PUT request to [`https://api.digitalocean.com/v2/kubernetes/clusters/{cluster_id}`](https://docs.digitalocean.com/reference/api/digitalocean//#operation/kubernetes_update_cluster).

### cURL
Using cURL:
```bash
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name": "stage-cluster-01", "tags":["staging", "web-team"]}' \
"https://api.digitalocean.com/v2/kubernetes/clusters/bd5f5959-5e1e-4205-a714-a914373942af"
```

### Go

Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go:

```bash
import (
"context"
"os"

"github.com/digitalocean/godo"
)

func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")

client := godo.NewFromToken(token)
ctx := context.TODO()

updateRequest := &godo.KubernetesClusterUpdateRequest{
Name: "stage-cluster-01",
Tags: []string{"staging", "web-team"},
}

cluster, _, err := client.Kubernetes.Update(ctx, "bd5f5959-5e1e-4205-a714-a914373942af", updateRequest)
}
```

### Ruby

Using [DropletKit](https://github.com/digitalocean/droplet_kit), the official DigitalOcean API client for Ruby:

```bash
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)

cluster = DropletKit::KubernetesCluster.new(
name: 'foo',
tags: ['staging', 'web-team']
)

client.kubernetes_clusters.update(cluster, id: 'bd5f5959-5e1e-4205-a714-a914373942af')
```

### Python
Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python:

```bash
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
"name": "prod-cluster-01",
"tags": [
"k8s",
"k8s:bd5f5959-5e1e-4205-a714-a914373942af",
"production",
"web-team"
],
"maintenance_policy": {
"start_time": "12:00",
"day": "any"
},
"auto_upgrade": True,
"surge_upgrade": True,
"ha": True
}

resp = client.kubernetes.update_cluster(cluster_id="1fd32a", body=req)
```

# Enable High Availability Using the Control Panel

To enable high availability on an existing cluster, go to the [control panel](https://cloud.digitalocean.com/kubernetes/clusters) and click the cluster you want to enable high availability on. Then, in the Overview tab, scroll down and find the following card.

![Add high availability](add-high-availability.png)

## I can't find this card

DigitalOcean Kubernetes clusters originally created with version 1.20 or older have a version of the control plane which does not allow you to enable [high availability](https://docs.digitalocean.com/products/kubernetes/details/managed/#new-control-plane). If you cannot find this card, upgrade your control plane.

To check whether you can upgrade your cluster to the new control plane, see [Upgrading to New Control Plane](https://docs.digitalocean.com/products/kubernetes/how-to/upgrade-cluster/#new-control-plane).

In the card, click Add high availability. This opens a pop-up window where you can confirm your change. Once enabled, you cannot disable high availability in the future.



Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
type: "course"
id: "scale-automatically"
title: "How to Enable Cluster Autoscaler for a DigitalOcean Kubernetes Cluster"
description: "Automatically scale node pools to zero when idle to save on compute costs with Nodepool Scale-to-Zero. Seamlessly scale clusters up to 1,000 nodes with Cluster Autoscaler."
weight: 1
banner: "digitalocean.svg"
tags: ["Kubernetes"]
categories: "Digital-Ocean"
level: "intermediate"
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
type: "page"
id: "autoscaling-in-response-to-heavy-resource-use"
description: ""
title: "Autoscaling in Response to Heavy Resource Use "
weight: 4
---

Pod creation and destruction can be automated by a Horizontal Pod Autoscaler (HPA), which monitors the resource use of nodes and generates pods when certain events occur, such as sustained CPU spikes, or memory use surpassing a certain threshold. This, combined with a CA, gives you powerful tools to configure your cluster’s responsiveness to resource demands — an HPA that ensures synchronicity between resource use and the number of pods, and a CA that ensures synchronicity between the number of pods and the cluster’s size.

For a walk-through that builds an autoscaling cluster and demonstrates the interplay between an HPA and a CA, see [Example of Kubernetes Cluster Autoscaling Working With Horizontal Pod Autoscaling](https://docs.digitalocean.com/products/kubernetes/how-to/set-up-autoscaling/).

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
type: "page"
id: "disabling-autoscaling"
description: ""
title: "Disabling Autoscaling "
weight: 2
---

# Using the DigitalOcean Control Panel

To disable autoscaling on an existing node pool, navigate to your cluster in [the Kubernetes section of the control panel](https://cloud.digitalocean.com/kubernetes/clusters), then click the Resources tab. Click the three dots to reveal the option to resize the node pool manually or enable autoscaling.


![DOKS node pool screen](doks-node-pool-screen.png)

Select Resize or Autoscale, and a window opens prompting for configuration details. Select Fixed size and configure the number of nodes you want to assign to the pool.

![DOKS node pool configuration window](doks-node-pool-configuration-window.png)

# Using doctl
To disable autoscaling, run an update command that specifies the node pool and cluster:

```bash
doctl kubernetes cluster node-pool update mycluster mypool --auto-scale=false
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading