About the Author
Ju Hongchao, SUSE SW Engineering, has 6 years of experience in the field of cloud computing. He has participated in the product development of Longhorn and Rancher2.x. Currently, he is mainly devoted to the product design and development of Rancher Enterprise Edition, and is the core maintainer of AutoK3s.

AutoK3s is an automated K3s cluster deployment tool that facilitates developers to self-manage K3s clusters in a multi-cloud environment. The previous version supports the four mainstream public clouds of AWS/Aliyun/Tencent/Google, and can help developers manage local K3d clusters.

The latest v0.4.8 version feature preview:

  • Supporting Harvester Provider, users can quickly create virtual machines on Harvester and automatically build a K3s cluster.
  • Support Google Provider, users can quickly create virtual machines on GCE, and automatically build K3s cluster, and support automatic deployment of Google K8s Cloud Provider (CCM).
  • Enhanced Native Provider feature, users can now manage and maintain K3s clusters created in Native mode on the UI.

Based on the latest v0.4.8 version, this article will introduce how to realize the dream linkage between AutoK3s and Harvester.

Environment version information used in this article:

PS: If you have not yet built a Harvester cluster, you can check the relevant introduction of Harvester or visit the Chinese document of Harvester: http://docs.rancher.cn/harvester1.0/

One-key start

If you are a Linux or MacOS user, you can use the following script to install AutoK3s and launch the UI Portal:

$ curl -sS http://rancher-mirror.cnrancher.com/autok3s/install.sh  | INSTALL_AUTOK3S_MIRROR=cn sh

$ autok3s serve

Or use Docker to start the UI Portal with one click:

# 标准Linux环境,使用以下命令
$ docker run -itd --restart=unless-stopped --net=host -v /var/run/docker.sock:/var/run/docker.sock cnrancher/autok3s:v0.4.7

# MacOS环境,使用以下命令
$ docker run -itd --restart=unless-stopped -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock cnrancher/autok3s:v0.4.7

After the service starts, open the browser, enter the address ( http://127.0.0.1:8080 ), and access the UI.

create cluster

Before using it, we need to build a Harvester cluster in advance and prepare a Kubeconfig file that can access the cluster (cluster-admin permission is required). If you have multiple Harvester clusters, AutoK3s can switch the effect of linkage between different Harvester clusters according to the Kubeconfig configuration.

Taking Rancher v2.6.3 as an example, after logging in as an administrator user, click the menu in the upper left corner, select Global Application > Virtualization Management, select a Harvester cluster to be operated, and click the drop-down button on the right to obtain Kubeconfig:

Next, we will use the Harvester Provider on the UI, specify the Harvester cluster we want to operate through Kubeconfig configuration, create two virtual machines on this Harvester cluster, and automatically start K3s consisting of 1 master and 1 worker node cluster.

The cluster configuration information is as follows:

  • In Instance Options, we set a virtual machine of 2C/4G/40G size, the Image Name is set to the Ubuntu 20.04 image, and the Network Name is set to the VLAN network we created, so that AutoK3s can connect to the virtual machine from external SSH; The Kubeconfig content is also filled in the corresponding location of the form:

  • In K3s Options, K3s Install Script selects the download link of mirror in China, which can speed up the installation of K3s cluster:

After the configuration information is complete, click the Create button and wait for the cluster to be created.

After the cluster is created, you can connect to the Harvester virtual machine through the SSH function. In the above example, we configured the cloud-init template, and installed curl and jq tools when starting the virtual machine. In this way, the jq tool can be used directly after connecting to the virtual machine.

After the cluster is created, you can use the Launch Kubectl function to directly operate the resources of the K3s cluster; you can also enable the kube-explorer function to manage the resources of the K3s cluster from the simplified explorer UI; these experience are consistent with those of other providers .

Accessing the Harvester environment, we can view the virtual machine information created by AutoK3s on the virtual machine list page.

In this scenario, you can build your own private K8s cloud environment based on Harvester and AutoK3s; you can combine the cloud-init template to make more preparations when the virtual machine is initialized, such as writing the proxy configuration file in advance, downloading the required Mirroring and other operations; more interesting usage scenarios are waiting for your exploration.

Tips:

Q: How to get the resource information in Harvester and fill in the AutoK3s configuration parameters, such as Image Name?
A: You can visit the Harvester Dashboard, find the Image resource you want to use, click the drop-down button on the right, and select View in API

Obtain the value of the id attribute of the JSON structure in the newly popped up page, which is the parameter content you need to fill in.

Cluster Management

Recently, we have summarized the issues frequently encountered by community users. The v0.4.8 version has enhanced the Native provider feature, and the use experience is consistent with other providers. Users can manage Native Clusters on the cluster list page.

In the native mode, the host information is maintained by the user, so the native mode only supports the establishment, uninstallation, and SSH connection to the specified host of the K3s cluster, and is not responsible for the life cycle management of the host.

Follow-up planning

In the next version, AutoK3s will integrate Kubeapp and add support for Helm repo. Users can deploy Helm Charts to different clusters with one click, such as building a K3s cluster and deploying Rancher with one click through AutoK3s. We will also add support for the K3s cluster upgrade experience to facilitate users to upgrade the K3s cluster version.

The future goal of AutoK3s is to create a self-service K3s management tool for developers, equivalent to a more lightweight Rancher.

For first-hand feature planning, please click: https://github.com/cnrancher/autok3s/milestones

everything open source

Interested users can get more documentation information through Github:
https://github.com/cnrancher/autok3s 
https://docs.rancher.cn/docs/k3s/autok3s/_index/

AutoK3s is a gadget purely for developers, not an enterprise-grade product. If you encounter problems during use, or you have good comments, please submit an issue; if you like us, please light star.

For more features of AutoK3s, please check:


Rancher
1.2k 声望2.5k 粉丝

Rancher是一个开源的企业级Kubernetes管理平台,实现了Kubernetes集群在混合云+本地数据中心的集中部署与管理。Rancher一向因操作体验的直观、极简备受用户青睐,被Forrester评为“2020年多云容器开发平台领导厂商...