Skip to content

CLI

For purposes of automation, it is strongly recommended that users create version controlled "cluster specs" to provision and manage the lifecycle of clusters.


Create Cluster

Declarative

You can create an Upstream k8s cluster based on a version controlled cluster spec that you can manage in a Git repository. This enables users to develop automation for reproducible infrastructure.

./rctl create cluster mks -f <cluster file name.yaml>

An illustrative example of the cluster spec YAML file for MKS is shown below

apiVersion: infra.k8smgmt.io/v3
kind: Cluster
metadata:
  # cluster labels
  labels:
    env: prod
    type: mks
  name: demo-mkscluster
  project: defaultproject
spec:
  type: mks
  blueprint: default
  config:
    location: "sanjose-us"
    k8sVersion: "v1.21.5"
    operating_system: "Ubuntu18.04"
    autoApproveNodes: true
    defaultStorageClass: "GlusterFs"
    highAvailability: false
    dedicatedMastersEnabled: false
    storageClasses:
    - name: Local
      storagePath: "/var/openebs/local/"
    - name: GlusterFs
      storagePath: ""
    nodes:
    - hostname: rctl-mks-0
      ipAddress: 10.109.23.6
      sshPrivateKeyPath: "ssh-key-2020-11-11.key"
      sshPort: 22
      sshUserName: ubuntu
      storageDeviceLocation: /dev/sdb
      roles:
        - Master
        - Worker
    - hostname: rctl-mks-1
          ipAddress: 10.187.21.4
          sshPrivateKeyPath: "ssh-key-2020-11-11.key"
          sshPort: 22
          sshUserName: ubuntu
          storageDeviceLocation: /dev/sdb
          roles:
            - Worker
            - Storage
    - hostname: rctl-mks-2
      ipAddress: 10.109.32.182
      sshPrivateKeyPath: "ssh-key-2020-11-11.key"
      sshPort: 22
      sshUserName: ubuntu
      storageDeviceLocation: /dev/sdb
      roles:
        - Worker

Once the rctl create command is executed succesfully, following actions will be done:

  • Create cluster on the controller
  • Download conjurer & credentials
  • SCP conjurer & credentials to node
  • Run conjurer
  • Configure role, interface
  • Start provision

Note

At this time only SSH key based authentication is supportted to scp into the nodes


Cluster Provision Status

Once the cluster is created, Provision will trigger and provision status can be monitored as shown below.

rctl get cluster <cluster-name> -o json | jq .status

The above command will return READY when the provision is complete.

Add Nodes

Users can add nodes on the cluster and update the config yaml file with the below command

./rctl update cluster mks -f <cluster file name.yaml>

Example:

Add the below node details in the yaml file under the nodes key

- hostname: rctl-mks-3
      ipAddress: 10.182.31.6
      sshPrivateKeyPath: "ssh-key-2020-11-11.key"
      sshPort: 22
      sshUserName: ubuntu
      storageDeviceLocation: /dev/sdb
      roles:
        - Worker
        - Storage

Use the below command to update the yaml file and add the nodes to the cluster

./rctl update cluster mks -f demo-mkscluster

Once the rctl update command is executed succesfully, following actions will be done:

  • Download conjurer & credentials
  • SCP conjurer & credentials to node
  • Run conjurer
  • Configure role, interface
  • Start provision

Node Provision Status

Once the node is added, Provision will trigger and provision status can be monitored as shown below.

rctl get cluster <cluster-name> -o json |  jq -r -c '.nodes[] | select(.hostname=="<hostname of the node>") | .status'

The above command will return READY when the provision is complete.