Nutanix Kubernetes Engine(NKE)の Kubernetes クラスタを、karbonctl で作成してみます。
今回の内容です。
karbonctl でのログイン
karbonctl は、Prism Central VM に SSH ログインして実行します。
karbonctl のバージョンです。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl version { "version": "2.9.0", "build_date": "2023-11-07T11:34:08+0000", "githash": "ed0f5b2" }
「karbonctl login」で Prism Central にログインします。今回は admin ユーザでログインしています。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl login --pc-username admin Please enter the password for the PC user: admin ★パスワードを入力してEnterキー Login successful
Kubernetes クラスタの作成(デフォルト設定)
karbonctl cluster create の Help です。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl cluster create --help Create a k8s cluster from a user provided JSON file or use auto generated configuration. You can create both NKE Classic and CAPI Management cluster. If JSON file is provided, other flags won't be considered for generation of cluster configuration. For usage, please check 'Examples' and 'Help' section Usage: karbonctl cluster create [flags] Examples: Create NKE Classic cluster - $ karbonctl cluster create Create NKE CAPI Management cluster - $ karbonctl cluster create -m Create NKE Dev cluster - $ karbonctl cluster create --type Dev Create NKE Production cluster - $ karbonctl cluster create --type Production Create NKE cluster while merging additional params from JSON file - $ karbonctl cluster create -f cluster.json Create NKE cluster while overrding default params from JSON file - $ karbonctl cluster create -f cluster.json --override Create NKE CAPI Management cluster while skipping default configuration generation - $ karbonctl cluster create -f cluster.json --skip-default-config Flags: --clusterapi-enabled If true, it will deploy cluster using cluster api. --control-plane-vip stringArray Virtual IPs to be used in control-plane config of cluster create request. If not provided and '--load-balancer-ip' flag is disabled, first discovered static IP from provided subnet on PC will be used. --disable-monitoring If false, it will enable deployment of monitoring stack(prometheus). (default true) -f, --file-path string File path of the json file containing the cluster create configuration. -h, --help help for create -m, --is-management If true, it will enable Cluster API management plane on cluster and mark it as management cluster --load-balancer-ip string Enable LoadBalancer to be used in control-plane config of cluster create request. --master-nodes int Number of master nodes to be used in control-plane config of cluster create request. (default 1) --override Overide default cluster config with file path provided via '--file-path' flag for cluster create configuration. If '--skip-default-config' flag is set, no need to set this flag. --pe-name string PE cluster name to be used in cluster create configuration. If not provided, '--pe-uuid' flag value will be used. --pe-uuid string PE cluster UUID to be used in cluster create configuration. If not provided, first registered PE cluster with PC will be selected. --pod-cidr string Pod CIDR range to be used in cluster create CNI configuration. (default "172.20.0.0/16") --service-cidr string Service CIDR range to be used in cluster create CNI configuration. (default "172.19.0.0/16") --skip-default-config Skip default configuration generation for create cluster request. --storage-class string Storage Class name to be used in create cluster storage configuration. (default "default-storageclass") --storage-container string Storage Container name to be used in create cluster storage configuration. If not provided, first discovered Storage Container on PC will be selected. --storage-enable-flash Enable flash mode storage to be used in create cluster storage configuration. --storage-file-system string Storage FileSystem to be used in create cluster storage configuration. Allowed values 'ext4', 'xfs'. (default "ext4") --storage-reclaim-policy string Storage Reclaim Policy to be used in create cluster storage configuration. Allowed values 'Delete', 'Retain'. (default "Delete") --subnet-name string Subnet name to be used in cluster create CNI configuration. If not provided, '--subnet-uuid' flag value will be used. --subnet-uuid string Subnet UUID to be used in cluster create CNI configuration. If not provided, first discovered subnet on PC will be selected. --type string Type of cluster to use for create cluster request. Allowed values 'Dev' and 'Production'. If '--is-management' is specified, 'Production' type will be used. (default "Dev") Global Flags: --config string Karbonctl configuration file path (default "/home/nutanix/.karbon/config/karbonctl.yaml") --output string Supported output formats: ['default', 'json'] (default "default") --pc-ip string Prism Central IP (default "127.0.0.1") --pc-password string Password of the user in Prism Central --pc-port int Prism port on the Prism Central VM (default 9440) --pc-username string Username of the user in Prism Central --timeout duration Request timeout for command execution (default 2m0s)
「karbonctl cluster create」を実行すると、デフォルト設定でクラスタが作成できます。デフォルト設定の JSON が表示されます。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl cluster create Please confirm the following configuration before cluster create operation: { "metadata": { "api_version": "v1.0.0" }, "name": "nke-cluster", "version": "1.26.8-0", "apiserver_sni": null, "categories": null, "disable_monitoring": true, "masters_config": { "single_master_config": {}, "node_pools": [ { "name": "nke-cluster628e66-master-pool", "node_os_version": "ntnx-1.6.1", "num_instances": 1, "ahv_config": { "prism_element_cluster_uuid": "00060971-8f36-098a-5537-005056815bb1", "cpu": 8, "memory_mib": 8192, "disk_mib": 122880, "network_uuid": "216dbb28-2509-41fe-b91b-9a2375f67767" }, "gpu_config_list": null } ] }, "etcd_config": { "node_pools": [ { "name": "nke-cluster4c2e18-etcd-pool", "node_os_version": "ntnx-1.6.1", "num_instances": 1, "ahv_config": { "prism_element_cluster_uuid": "00060971-8f36-098a-5537-005056815bb1", "cpu": 4, "memory_mib": 8192, "disk_mib": 40960, "network_uuid": "216dbb28-2509-41fe-b91b-9a2375f67767" }, "gpu_config_list": null } ] }, "workers_config": { "node_pools": [ { "name": "nke-cluster9fb646-worker-pool", "node_os_version": "ntnx-1.6.1", "num_instances": 1, "ahv_config": { "prism_element_cluster_uuid": "00060971-8f36-098a-5537-005056815bb1", "cpu": 8, "memory_mib": 8192, "disk_mib": 122880, "network_uuid": "216dbb28-2509-41fe-b91b-9a2375f67767" }, "gpu_config_list": null } ] }, "storage_class_config": { "name": "default-storageclass", "default_storage_class": true, "reclaim_policy": "Delete", "volumes_config": { "prism_element_cluster_uuid": "00060971-8f36-098a-5537-005056815bb1", "storage_container": "default-container-99354647953117", "file_system": "ext4" } }, "cni_config": { "service_ipv4_cidr": "172.19.0.0/16", "pod_ipv4_cidr": "172.20.0.0/16", "node_cidr_mask_size": 24, "calico_config": { "ip_pool_configs": [ { "cidr": "172.20.0.0/16" } ] } } }
そして、下記のような確認メッセージが表示されるので、「Y」を入力して Enter キーを押すとクラスタの作成が開始されます。
Do you want to create cluster? Y/[N]:Y Successfully submitted create k8s cluster request
クラスタが作成される様子は、「karbonctl cluster list」で確認できます。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl cluster list Name UUID IsManagement Control Plane IPs (VIP) Version OS Version Status Worker IPs nke-cluster 3e8461c5-e62b-4d97-759c-ccfd9b677da4 false 1.26.8-0 kInProgress
しばらく待つと、クラスタが作成されます。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl cluster list Name UUID IsManagement Control Plane IPs (VIP) Version OS Version Status Worker IPs nke-cluster 3e8461c5-e62b-4d97-759c-ccfd9b677da4 false 192.168.12.103 1.26.8-0 ntnx-1.6.1 kSuccess 192.168.12.149
ちなみに karbonctl では、JSON ファイルで作成する Kubernetes クラスタのパラメータを指定できます。
Kubernetes クラスタの削除
クラスタの削除は「karbonctl cluster delete」です。コマンドを実行すると確認メッセージが表示されるので、「Y」を入力して Enter キーを押すと削除処理が開始されます。
nutanix@NTNX-192-168-20-15-A-PCVM:~$ ./karbon/karbonctl cluster delete --cluster-name nke-cluster Do you want to delete the kubernetes cluster? Y/[N]:Y Successfully submitted cluster=nke-cluster delete request
以上。