{"id":23009131,"url":"https://github.com/belgaied2/harvester-cli","last_synced_at":"2025-08-14T04:32:26.215Z","repository":{"id":42674884,"uuid":"384211708","full_name":"belgaied2/harvester-cli","owner":"belgaied2","description":"Harvester CLI is a project that aims to provide an opinionated CLI tool to easily manage VMs on Harvester, the promising HCI solution created by Rancher Labs/SUSE","archived":false,"fork":false,"pushed_at":"2023-05-09T21:30:49.000Z","size":723,"stargazers_count":26,"open_issues_count":9,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-19T04:22:55.483Z","etag":null,"topics":["cli","golang","harvester","hyperconverged","rancher","urfave-cli"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/belgaied2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-08T18:11:34.000Z","updated_at":"2024-06-01T05:34:20.000Z","dependencies_parsed_at":"2024-06-19T04:09:32.192Z","dependency_job_id":"333554e3-1f6f-4a79-913e-8dd42dbacf1a","html_url":"https://github.com/belgaied2/harvester-cli","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belgaied2%2Fharvester-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belgaied2%2Fharvester-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belgaied2%2Fharvester-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belgaied2%2Fharvester-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/belgaied2","download_url":"https://codeload.github.com/belgaied2/harvester-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229800428,"owners_count":18126028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","golang","harvester","hyperconverged","rancher","urfave-cli"],"created_at":"2024-12-15T09:12:39.372Z","updated_at":"2024-12-15T09:12:39.944Z","avatar_url":"https://github.com/belgaied2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/belgaied2/harvester-cli)](https://goreportcard.com/report/github.com/belgaied2/harvester-cli)\n[![Lint Go Code](https://github.com/belgaied2/harvester-cli/actions/workflows/lint.yml/badge.svg)](https://github.com/belgaied2/harvester-cli/actions/workflows/lint.yml)\n\n# CLI Tool for [Harvester HCI](https://harvesterhci.io)\nHarvester CLI is a command line tool that can manage some aspects of Virtual Machine management on a remote Harvester Cluster, using simplicity principles similar to [multipass](https://multipass.run/) or [k3d](https://k3d.io).\n\n[![asciicast](Harvester-CLI-Demo-asciinema.png)](https://asciinema.org/a/470600)\n\n# Quick setup\nHarvester CLI needs a KUBECONFIG to access remotely the Harvester Cluster. There are two ways to achieve that:\n\n## Inline configuration path\nHarvester KUBECONFIG files can be manually given to Harvester using a CLI flag or a by setting an environment variable:\n- CLI Flag: `--config`\n- Environment variable : `HARVESTER_CONFIG`\n\n## Automatic download from Rancher Server\nSince a Harvester Cluster can be imported into Rancher like any other Kubernetes cluster, it is possible to use the Rancher API to automatically download the KUBECONFIG file for Harvester. This approach is particularly useful if multiple Harvester Clusters are managed by a single Rancher instances.\n\nTwo commands are needed for this.\n- First login to Rancher Server: `harvester login https://\u003cRANCHER_URL\u003e` -t \u003cRANCHER_API_TOKEN\u003e\n- Then, get the KUBECONFIG for the target Harvester Cluster: `harvester get-config \u003cHARVESTER_CLUSTER_NAME\u003e`, this will download the KUBECONFIG file for target Harvester cluster to `$HOME/.harvester/config`, which is the default location used by the CLI.\n\nNext, a check can be done by listing the available VMs:\n```bash\nharvester vm list\n```\n\n# Default behavior when creating VMs\nPlease be aware that Harvester CLI offers an opinionated approach to creating VMs, it is supposed to be a way to easily create and destroy test VMs for the purpose of conducting tests.\nFor instance, *if no VM image is provided* to the `harvester vm create` command, `harvester` CLI will go ahead and use the *first image it finds in Harvester*. If Harvester has no image, it will go ahead and download Ubuntu Focal `20.04` in its minimal version.\n\nSimilarly, if no Cloud-Init template is provided, it will go ahead and create a standard Cloud-Init template for Ubuntu.\n\nIf you consider the behavior to be problematic, please suggest a detailed proposal in a GitHub Issue.\n\n# Features implemented\nAt the moment, features implemented in Harvester CLI are:\n- Automatic Harvester Configuration Download from Rancher API\n- VM Lifecycle Management: List, Create, Delete, Start, Stop, Restart\n- Direct Shell access to VMs -- *requires presence of the SSH utility on the system, usually the case in most OSes out of the box*\n\nMany aspects might be implemented in the future, like Network Management or VM Image Management, please feel free to contribute or suggest features by creating issues.\n\n# VM Management\n\n\n### harvester virtualmachine (alias vm)\n\nThe `harvester vm` command has a number of possible sub-commands for VM Lifecycle management including `list`, `create`, `delete`, `start`, `stop` and `restart`. The default behavior if no sub-command is given is the `list` sub-command. \n\n\u003e Manage Virtual Machines on Harvester\n\u003e\n\u003e name: harvester vm\n\n```\nNAME:\n   harvester vm - Manage Virtual Machines on Harvester\n\nUSAGE:\n   harvester vm command [command options] [arguments...]\n\nCOMMANDS:\n   list, ls         List VMs\n   delete, del, rm  Delete a VM\n   create, c        Create a VM\n   stop             Stop a VM\n   start            Start a VM\n   restart          Restart a VM\n\nOPTIONS:\n   --help, -h  show help\n\n\n```\n\n### harvester vm list (alias l)\nThe `list` sub-command lists all VMs available in the Harvester cluster. At the moment, no filtering feature is implemented.\n\n\u003e List VMs\n\u003e\n\u003e name: harvester vm list\n\nList all VMs in the current Harvester Cluster\n\n```\nNAME:\n   harvester vm list - List VMs\n\nUSAGE:\n   harvester vm list [command options] None\n\nDESCRIPTION:\n\nList all VMs in the current Harvester Cluster\n\nOPTIONS:\n   --namespace value, -n value  Namespace of the VM (default: \"default\") [$HARVESTER_VM_NAMESPACE]\n\n\n```\n\n### harvester vm create\nThe `create` sub-command creates a VM based on some input preferences, the most important of which are: \n- `cpus` flag: Number of CPUs\n- `memory` flag: Memory size using a notation such as : 4G ( 4 x 10^9 Bytes ) or 8Gi ( 8 x 1024^3 Bytes)\n- `disk-size` flag: Disk size using the same notation as above\n- `vm-image-id` flag: references the VM image (should be a Cloud Image type of image) that already exists on Harvester. *NOTE: At this time, it is necessary to give the VM ID and not the image name. The ID can be found in the Harvester UI in the YAML description of the VM Image*\n- `template` flag: existing Harveste VM Template to be used for creating the VM, takes the format `\u003ctemplate_name\u003e:\u003cversion\u003e` or `\u003ctemplate_name\u003e`  \n\n**!!IMPORTANT NOTE: At the moment, the `create` sub-command supposes a Network `vlan1` already exists!!** \n\n\u003e Create a VM\n\u003e\n\u003e name: harvester vm create\n\n```\nNAME:\n   harvester vm create - Create a VM\n\nUSAGE:\n   harvester vm create [command options] [VM_NAME]\n\nOPTIONS:\n   --namespace value, -n value               Namespace of the VM (default: \"default\") [HARVESTER_VM_NAMESPACE]\n   --vm-description value                    Optional description of your VM [HARVESTER_VM_DESCRIPTION]\n   --vm-image-id value                       Harvester Image ID of the VM to create [HARVESTER_VM_IMAGE_ID]\n   --disk-size value                         Size of the primary VM disk (default: \"10Gi\") [HARVESTER_VM_DISKSIZE]\n   --ssh-keyname value                       KeyName of the SSH Key to use with this VM [HARVESTER_VM_KEY]\n   --cpus value                              Number of CPUs to dedicate to the VM (default: 1) [HARVESTER_VM_CPUS]\n   --memory value                            Amount of memory in the format XXGi (default: \"1Gi\") [HARVESTER_VM_MEMORY]\n   --cloud-init-user-data value              Cloud Init User Data in yaml format [HARVESTER_USER_DATA]\n   --cloud-init-network-data value           Cloud Init Network Data in yaml format [HARVESTER_NETWORK_DATA]\n   --template value, --from-template value   Harvester VM Template to use for creating the VM in the format \u003ctemplate_name\u003e:\u003cversion\u003e or \u003ctemplate\u003e in which case the latest version will be used\n\n```\n\n### harvester vm delete\nThe `delete` sub-command deletes the VM which name corresponds to the first argument that follows. For the moment, if multiple arguments are given, only the first one will be used.\n\n\u003e Delete a VM\n\u003e\n\u003e name: harvester vm delete\n\n```\nNAME:\n   harvester vm delete - Delete a VM\n\nUSAGE:\n   harvester vm delete [command options] [VM_NAME/VM_ID]\n\nOPTIONS:\n   --namespace value, -n value  Namespace of the VM (default: \"default\") [HARVESTER_VM_NAMESPACE]\n\n\n```\n\n### harvester vm stop\nThe `stop` sub-command stops the VM which name corresponds to the first argument that follows. For the moment, if multiple arguments are given, only the first one will be used.\n\n\u003e Stop a VM\n\u003e\n\u003e name: harvester vm stop\n\n```\nNAME:\n   harvester vm stop - Stop a VM\n\nUSAGE:\n   harvester vm stop [VM_NAME]\n\n```\n\n### harvester vm start\nThe `start` sub-command starts the VM which name corresponds to the first argument that follows. For the moment, if multiple arguments are given, only the first one will be used.\n\n\u003e Start a VM\n\u003e\n\u003e name: harvester vm start\n\n```\nNAME:\n   harvester vm start - Start a VM\n\nUSAGE:\n   harvester vm start [VM_NAME]\n\n```\n\n### harvester vm restart\nThe `restart` sub-command restarts the VM which name corresponds to the first argument that follows. For the moment, if multiple arguments are given, only the first one will be used.\n\n\u003e Restart a VM\n\u003e\n\u003e name: harvester vm restart\n\n```\nNAME:\n   harvester vm restart - Restart a VM\n\nUSAGE:\n   harvester vm restart [command options] [VM_NAME]\n\nOPTIONS:\n   --vm-name value, --name value  Name of the VM to restart\n\n\n```\n\n## Automatic Configuration download from Rancher\nIn order to get Harvester's Kubeconfig to be able to manage your particular Harvester Cluster, you have :\n- The manual way: get the KUBECONFIG file from the underlying RKE2 Cluster and put it on your client, then reference it in the `harvester` commands using:\n  - By default, the location `$HOME/.harvester/config`\n  - the flag `--harvester-config` to give, inline, a path to a valid HARVESTER-specific KUBECONFIG file \n  - the environment variable `HARVESTER_CONFIG`\n- Download the KUBECONFIG file from Rancher using a Rancher API token: this is done using the `harvester get-config` command. This procedure has been improved and gives the possibility to use the `login` command which will, thanks to a Rancher API Token, login to a Rancher Management Server where Harvester is imported.\n\nPlease keep in mind that, until now, the Harvester CLI program does not check if the given cluster is an actual Harvester Cluster, or which version it has.\n\n*TODO* : Improve this section\n\n\n# DISCLAIMER\nThis is still in a very early stage of development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelgaied2%2Fharvester-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbelgaied2%2Fharvester-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelgaied2%2Fharvester-cli/lists"}