Updated on 2025-09-26 GMT+08:00

Binding a Custom Kubernetes Cluster

Before creating a component based on a container in the Kubernetes or VM + Kubernetes environment, bind a cluster to the environment.

The VM + Kubernetes environment and Kubernetes non-HA environment support custom Kubernetes clusters.

Prerequisites

Procedure

  1. Log in to ServiceStage.
  2. Choose Environment Management. The Environment Management page is displayed.
  3. Click the target environment. The Overview page is displayed.
  4. Choose Clusters from Compute.
  5. Click Bind now.
  6. Select Custom Kubernetes cluster for Cluster Source.
  7. Enter a cluster name.

    Enter 2 to 64 case-sensitive characters. Start with a letter and end with a letter or digit. Only use letters, digits, underscores (_), and hyphens (-).

  8. Click Import YAML File to import the kubeconfig file in YAML format.
  9. Click OK.

Follow-up Operations

  • On the Overview page, you can edit the custom Kubernetes cluster bound to a Kubernetes non-HA environment or a VM+Kubernetes environment by referring to Editing a Bound Custom Kubernetes Cluster.
  • If the cluster bound to the environment is no longer used, unbind the cluster by referring to Unbinding a Cluster.

kubeconfig File Description

Only use the kubeconfig file from reliable sources to prevent malicious code execution or file exposure.

It is a common way to manage a native Kubernetes cluster using the kubeconfig file. The kubeconfig file contains the configuration information required for the client to communicate with the Kubernetes cluster, including the cluster information, user authentication information, and context information.

Example kubeconfig file structure:

apiVersion: v1
kind: Config
preferences: {}
current-context: dev-context
clusters:
- name: my-cluster
  cluster:
    server: https://api.example.com:6443
    certificate-authority-data: LS0tLS1CRUd...  # Base64-encoded CA certificate
users:
- name: admin-user
  user:
    client-certificate-data: LS0tLS1CRUd...    # Base64-encoded client certificate
    client-key-data: LS0tLS1CRUd...            # Base64-encoded client private key
contexts:
- name: dev-context
  context:
    cluster: my-cluster
    user: admin-user
    namespace: default

For details, see Table 1.

Table 1 Parameters in the kubeconfig file

Parameter

Mandatory

Type

Description

Example Value

apiVersion

Yes

String

API version of the kubeconfig file.

v1

kind

Yes

String

Resource type of the kubeconfig file. The value is fixed at Config.

Config

preferences

No

Object

User preference settings (such as the output format and color).

{}

current-context

No

String

Name of the current context.

dev-context

clusters

Yes

Array of objects

Cluster list, which defines the cluster address and authentication information. For details, see Table 2.

-

users

Yes

Array of objects

User list, which defines the user authentication mode (such as certificate, token, username and password, and plug-in). For details, see Table 4.

-

contexts

Yes

Array

Context list, which associates clusters, users, and default namespaces. For details, see Table 6.

-

Table 2 clusters

Parameter

Mandatory

Type

Detail

Example Value

name

Yes

String

Unique cluster name.

my-cluster

cluster

Yes

Array

Cluster connection information. For details, see Table 3.

-

Table 3 cluster

Parameter

Mandatory

Type

Detail

Example Value

server

Yes

String

API server address of the cluster, which must contain the protocol and port number and can be accessed from the public network.

https://api.example.com:6443

certificate-authority

No

String

Path of the CA certificate file. Either this parameter or certificate-authority-data must be specified.

etc/kubernetes/pki/ca.crt

certificate-authority-data

No

String

Base64-encoded CA certificate data. Either this parameter or certificate-authority must be specified.

LS0tLS1CRUd...

insecure-skip-tls-verify

No

Boolean

Whether to skip TLS verification. This parameter is used only in the test environment.

false

Table 4 users

Parameter

Mandatory

Type

Detail

Example Value

name

Yes

String

Unique user name (customized).

admin-user

user

No

Array of objects

Defines the credential and mode for user identity authentication. Multiple authentication mechanisms (such as certificates, tokens, and dynamic plug-ins) are supported. For details, see Table 5.

-

Table 5 user

Parameter

Mandatory

Type

Detail

Example Value

client-certificate

No

String

Path of the client certificate file. Either this parameter or client-certificate-data must be specified.

/path/to/client.crt

client-certificate-data

No

String

Base64-encoded client certificate data. Either this parameter or client-certificate must be specified.

LS0tLS1CRUd...

client-key

No

String

Path of the client private key file. Either this parameter or client-key-data must be specified.

/path/to/client.key

client-key-data

No

String

Base64-encoded client private key data. Either this parameter or client-key must be specified.

LS0tLS1CRUd...

token

No

String

Static token (bearer token authentication)

eyJhbGciOiJSUzI1NiIsIm...

username

No

String

Basic authentication username.

admin

password

No

String

Basic authentication password.

secret

Table 6 contexts

Parameter

Mandatory

Type

Detail

Example Value

name

Yes

String

Unique name of the context (customized).

dev-context

context

Yes

Array

Binds a cluster, user, and namespace to define a specific operating environment. You can switch between different contexts to quickly switch between different clusters, users, or namespaces. For details, see Table 7.

-

Table 7 context

Parameter

Mandatory

Type

Detail

Example Value

cluster

Yes

String

Name of the associated cluster. The value must be the same as name in Table 2.

my-cluster

user

Yes

String

Name of the associated user. The value must be the same as name in Table 4.

admin-user

namespace

No

String

Default namespace. If this parameter is not specified, default is used.

default

Editing a Bound Custom Kubernetes Cluster

  1. Log in to ServiceStage.
  2. Choose Environment Management. The Environment Management page is displayed.
  3. Click the target environment. The Overview page is displayed.
  4. Choose Clusters from Compute.
  5. Click Edit Cluster.
  6. Change the Cluster Name.

    Enter 2 to 64 case-sensitive characters. Start with a letter and end with a letter or digit. Only use letters, digits, underscores (_), and hyphens (-).

  7. Click Import YAML File to import the kubeconfig file in YAML format.
  8. Click OK.