NavigationContentFooter
Jump toSuggest an edit

Creating and managing a Kubernetes Kapsule with CLI (v2)

Reviewed on 12 March 2024Published on 05 August 2021

Scaleway’s Kubernetes (K8s) Kapsule provides you with a managed environment to create, configure and run a cluster of pre-configured machines for containerized applications. You will be able to create clusters without the complexity of managing the infrastructure.

You can create and manage your Kapsule clusters from the console, via the API or via the Scaleway Command Line Interface.

Scaleway command line interface overview

The Scaleway command line interface (CLI) allows you to pilot your Scaleway infrastructure directly from your terminal, providing a faster way to administer and monitor your resources. Scaleway CLI is easy to set up and is an essential tool for operating efficiently in your cloud environment. The CLI provides many functionalities, including the ability to create and manage Kubernetes clusters.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • A valid API key
  • Downloaded and installed the Scaleway CLI

Configuring the CLI

  1. Run the following command into your terminal to configure the Scaleway CLI on your machine:

    scw init

    If you have already configured the CLI, you will see a message like the following:

    Current config is located at /path/to/config.yaml
    access_key: <YOUR ACCESS KEY>
    secret_key: <YOUR SECRET KEY>
    default_organization_id: <YOUR ORGANIZATION ID>
    default_project_id: <YOUR PROJECT ID>
    default_region: <YOUR DEFAULT REGION, eg fr-par>
    default_zone: <YOUR DEFAULT ZONE, eg fr-par-1>
    Do you want to override the current config? (Y/n):
  2. Type n and go directly to the Creating a Kubernetes Kapsule cluster step of this tutorial, if you do not want to edit your configuration.

    If you have not yet configured the CLI, you will be guided through the configuration process via a series of questions:

    Enter a valid secret-key or an email
  3. Enter either the email address for your account (you will then be asked for your password), or your API secret key:

    To improve this tool we rely on diagnostic and usage data.
    Sending such data is optional and can be disabled at any time by running "scw config set send-telemetry=false".
    Do you want to send usage statistics and diagnostics? (Y/n):

    Type y or n and hit enter.

    To fully enjoy Scaleway CLI we recommend you install autocomplete support in your shell.
    Do you want to install autocomplete? (Y/n):

    Type y or n and hit enter.

    To enable autocomplete, scw needs to update your shell configuration.
    What type of shell are you using (default: zsh):

    Hit enter if the default shell type is already correct for you. Otherwise, enter your shell type and hit enter.

    To enable autocomplete we need to append to /Users/yourusername/.zshrc the following lines:
    # Scaleway CLI autocomplete initialization.
    eval "$(scw autocomplete script shell=zsh)"
    Do you want to proceed with these changes? (Y/n):
  4. Type y or n and hit enter. This should complete the configuration process:

    Initialization completed with success.

Creating a Kubernetes Kapsule cluster

  1. Type the following command in your terminal to create a Kubernetes Kapsule cluster:

    scw k8s cluster create name=name-of-your-cluster

    Tip

    You can add the type argument to specify the cluster type. For an extensive list of the available cluster types, run the list cluster types CLI command. If you do not specify a cluster type, a cluster of Kapsule type is created by default.

    It is possible to change the cluster type anytime. Depending on your current cluster type, the types you can change to vary. Refer to the Changing the control plane offer documentation page for more information.

    For more information about cluster types, refer to the Kubernetes FAQ page.

    You will see an output similar to this:

    The argument 'enable-dashboard' is deprecated, more info with: scw k8s cluster create --help
    ID 12345678-1234-1234-4321-123456789123
    Type kapsule
    Name name-of-your-cluster
    Status creating
    Version 1.29.1
    Region fr-par
    OrganizationID 12345678-1234-1234-4321-123456789123
    ProjectID 12345678-1234-1234-4321-123456789123
    Cni cilium
    Description -
    ClusterURL https://12345678-1234-1234-4321-123456789123.api.k8s.fr-par.scw.cloud:6443
    DNSWildcard *.12345678-1234-1234-4321-123456789123.nodes.k8s.fr-par.scw.cloud
    CreatedAt now
    UpdatedAt now
    DashboardEnabled false
    Ingress none
    UpgradeAvailable false
    Autoscaler configuration:
    ScaleDownDisabled false
    ScaleDownDelayAfterAdd 10m
    Estimator binpacking
    Expander random
    IgnoreDaemonsetsUtilization false
    BalanceSimilarNodeGroups false
    ExpendablePodsPriorityCutoff -10
    ScaleDownUnneededTime 10m
    ScaleDownUtilizationThreshold 0.5
    MaxGracefulTerminationSec 600
    Auto-upgrade settings:
    Enabled false
    MaintenanceWindow.StartHour 0
    MaintenanceWindow.Day any
    Open ID Connect configuration:
    IssuerURL -
    ClientID -
    UsernameClaim -
    UsernamePrefix -
    GroupsPrefix -
    Note

    For more information about the creation of a Kubernetes cluster, type scw k8s cluster create --help in your terminal.

  2. Write down the ID of your cluster, as you will need it in the next steps.

Installing a KubeConfig configuration file

Type the following command in your terminal and replace your-cluster-ID with the ID of your previously generated cluster:

scw k8s kubeconfig install your-cluster-ID

You will see the following output:

Kubeconfig for cluster your-cluster-ID successfully written at /Users/yourusername/.kube/config

Adding a pool to a Kubernetes cluster

A pool is a set of identical nodes. A pool has a name, a size (its current number of nodes), nodes number limits (min and max), and a Scaleway Instance type.

Note

Instance type with insufficient memory are not eligible to become nodes (DEV1-S, PLAY2-PICO, STARDUST)

Changing these limits increases/decreases the size of a pool. Thus, when autoscaling is enabled, the pool will grow or shrink inside those limits, depending on its load.

Note

For more information about pools, refer to the Scaleway CLI documentation.

Type the following command in your terminal:

scw k8s pool create cluster-id=id-of-your-cluster name=name-of-your-pool node-type=GP1_XS size=number-of-nodes-wanted

You will see an output similar to this:

ID 12345678-1234-1234-4321-123456789123
ClusterID 12345678-1234-1234-4321-123456789123
CreatedAt now
UpdatedAt now
Name my-node-pool
Status scaling
Version 1.29.1
NodeType gp1_xs
Autoscaling false
Size 1
MinSize 0
MaxSize 1
ContainerRuntime containerd
Autohealing false
UpgradePolicy.MaxUnavailable 1
UpgradePolicy.MaxSurge 0
Zone fr-par-1
RootVolumeType l_ssd
RootVolumeSize 150 GB
PublicIPDisabled false
Region fr-par

Deleting a Kubernetes pool

Important

This will permanently destroy your pool. All pool data stored on local volume will be destroyed.

Type the following command in your terminal and replace your-pool-ID with the pool ID you want to delete:

scw k8s pool delete your-pool-ID

You will see an output similar to this:

ID 12345678-1234-1234-4321-123456789123
ClusterID 12345678-1234-1234-4321-123456789123
CreatedAt 1 minute ago
UpdatedAt now
Name my-node-pool
Status deleting
Version 1.29.1
NodeType gp1_xs
Autoscaling false
Size 1
MinSize 0
MaxSize 1
ContainerRuntime containerd
Autohealing false
UpgradePolicy.MaxUnavailable 1
UpgradePolicy.MaxSurge 0
Zone fr-par-1
RootVolumeType l_ssd
RootVolumeSize 150 GB
PublicIPDisabled false
Region fr-par

Your pool has been deleted.

Uninstalling a Kubeconfig from a specific cluster

Type the following command in your terminal and replace your-cluster-ID with the cluster ID you want to delete the Kubeconfig from:

scw k8s kubeconfig uninstall your-cluster-ID

You will get an output similar to this:

Cluster your-cluster-ID successfully deleted from /Users/yourusername/.kube/config

Deleting a Kubernetes cluster

Important

This will permanently destroy your cluster and all associated pools and Instances.

Type the following command in your terminal and replace your-cluster-ID with the ID of the cluster you want to delete:

scw k8s cluster delete "your-cluster-ID"

You will see an output similar to this:

ID 12345678-1234-1234-4321-123456789123
Type kapsule
Name name-of-your-cluster
Status deleting
Version 1.29.1
Region fr-par
OrganizationID 12345678-1234-1234-4321-123456789123
ProjectID 12345678-1234-1234-4321-123456789123
Cni cilium
Description -
ClusterURL https://12345678-1234-1234-4321-123456789123.api.k8s.fr-par.scw.cloud:6443
DNSWildcard *.12345678-1234-1234-4321-123456789123.nodes.k8s.fr-par.scw.cloud
CreatedAt 6 minutes ago
UpdatedAt now
UpgradeAvailable false
PrivateNetworkID 12345678-1234-1234-4321-123456789123
CommitmentEndsAt 6 minutes ago
Autoscaler configuration:
ScaleDownDisabled false
ScaleDownDelayAfterAdd 10m
Estimator binpacking
Expander random
IgnoreDaemonsetsUtilization false
BalanceSimilarNodeGroups false
ExpendablePodsPriorityCutoff -10
ScaleDownUnneededTime 10m
ScaleDownUtilizationThreshold 0.5
MaxGracefulTerminationSec 600
Auto-upgrade settings:
Enabled false
MaintenanceWindow.StartHour 0
MaintenanceWindow.Day any
Open ID Connect configuration:
IssuerURL -
ClientID -
UsernameClaim -
UsernamePrefix -
GroupsPrefix -
Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway