AutoK3s is an automatic deployment tool for K3s cluster, which can facilitate developers to self-manage K3s cluster in the cloud environment. It can support mainstream public clouds such as AWS/Aliyun/TencentCloud, deploy as needed, and release as used up. For the development and testing personnel who need various K8s environments in their daily work, This greatly reduces the time of repeated deployment and improves work efficiency.

The newly released V0.4.1 version enhances the user experience of local UI and optimizes the configuration of common K3s parameters, making the configuration of K3s parameters easy, such as one-click disable components, configure Runtime, set network components, etc., which has good compatibility for both beginners and K8s in-depth users.

This article will introduce how to use AWS Provider to rapidly deploy Rancher HA environment based on AutoK3s v0.4.1, and create K3s cluster to import Rancher for unified management.

This article relies on related software versions:

A key to start

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


 1. $ curl -sS http://rancher-mirror.cnrancher.com/autok3s/install.sh  |
    INSTALL_AUTOK3S_MIRROR=cn sh
 2. $ autok3s serve
Copy the code

Or use Docker to launch UI Portal with one click:

$docker run-itd --restart=unless-stopped -p 8080:8080 cnrancher/autok3s:v0.4.1Copy the code

Open a browser and enter the address http://127.0.0.1:8080 to access the UI.

Creating a Local cluster

We are going to create a K3s cluster with 1 master and 2 workers. The cluster configuration is as follows:

  1. Instance-type in Instance Options is t2.medium
  2. SSH Public and SSH Private in Instance Options
  3. For Instance Options security-group, you are advised to use the Allow All rule because it is used to quickly build a temporary environment
  4. K3s-version in K3s Options uses V1.18.8 + k3S1
  5. You are advised to disable Traefik in master-extra-args of K3s Options. Select Disabled Traefik from the drop-down list and move it to the right to disable components in one click.

After modifying the configuration, click the Create button and wait for the cluster to be created.

Tip: You can save cluster information as a template to simplify repeated configuration.

Deploy the Rancher

Since Rancher HA requires the configuration of access Certificates, this article uses the simplest form of Rancher Generated Certificates. First, we deploy the cert-Manager application.

Click the cluster name to go to the cluster details page and use Excute Shell to connect to the master host. In the/var/lib/rancher/k3s/server/manifests directory, and increase the cert – manager. Yaml:

apiVersion: v1 kind: Namespace metadata: name: cert-manager --- apiVersion: helm.cattle.io/v1 kind: HelmChart metadata: name: cert-manager namespace: cert-manager spec: chart: https://charts.jetstack.io/charts/cert-manager-v1.2.0.tgz targetNamespace: cert - manager set: installCRDs: "true"Copy the code
You can verify the installation result with $kubectl -n cert-manager get PodsCopy the code

In the/var/lib/rancher/k3s/server/manifests directory, increase the rancher. Yaml:

apiVersion: v1 kind: Namespace metadata: name: cattle-system --- apiVersion: helm.cattle.io/v1 kind: HelmChart metadata: name: rancher namespace: kube-system spec: chart: https://releases.rancher.com/server-charts/stable/rancher-2.5.7.tgz targetNamespace: cattle - system set: hostname: ApiVersion: v1 kind: Service metadata: labels: app: rancher name: apiVersion: v1 kind: Service metadata: labels: app: rancher name rancher-lb-svc namespace: cattle-system spec: ports: - name: http port: 80 protocol: TCP targetPort: 80 - name: https port: 443 protocol: TCP targetPort: 443 selector: app: rancher sessionAffinity: None type: LoadBalancerCopy the code

Use THE K3s servicelb as the load balancing entry for the lightest implementation of the L4 Rancher HA deployment mode:

$kubectl get SVC rancher-lb-svc-n cattle-system $kubectl get SVC rancher-lb-svc-n cattle-systemCopy the code

On the console of the DOMAIN name service provider, configure the mapping between the domain name (Rancher-test.jacie. work) and the external-IPS of Rancher-lb-SVC, so that you can directly access the Rancher HA environment using the domain name. Since Autok3s automatically sets the Node External IP for us when deploying K3s, servicelB can naturally use this External IP as an access point.

Note: In the public cloud scenario, please note that the IP address of the instance changes after shutdown. The above description is for the verification scenario of destruction on demand.

Create a cluster and import Rancher management

Next, we can use AutoK3s to create a K3s cluster with 1 master 1 worker using Docker Runtime and import it into Rancher for management.

The cluster configuration information is as follows:

  1. Instance-type in Instance Options is t2.medium
  2. SSH Public and SSH Private in Instance Options
  3. For Instance Options security-group, you are advised to use the Allow All rule because it is used to quickly build a temporary environment
  4. In K3s Options, set the K3s version to V1.19.7 + K3S1
  5. The master-extra-args parameter in K3s Options, select Docker Runtime from the drop-down menu and move it to the right, AutoK3s will automatically install Docker on the host for you, and use Docker as a container for K3s runtime.

After modifying the configuration, click the Create button and wait for the cluster to be created.

Once the cluster is created, use Launch Kubectl to import the cluster to Rancher for management.

conclusion

AutoK3s can be very convenient to deploy different versions of K3s cluster, and the UI provides some common parameter configuration, convenient user personalized configuration of K3s cluster parameters, for the novice and K8s in-depth users have a good compatibility.

AutoK3s is optimized for the local environment. By default, the K3s installation script points to the local installation source, which greatly improves the efficiency of r&d and testing by reducing repeated deployment and deployment failures.

Later versions of AutoK3s will support the automatic deployment of Mainfests, which allows you to deploy a K3s cluster and install the application automatically by specifying its manifests file.

There will also be an APP Market Place feature that allows you to automatically publish applications to different K3s clusters by adding your own HELM REPO, simplifying the process of installing and deploying your applications.

AutoK3s all open source, welcome trial, interested users can open source address in the making for more document information: github.com/cnrancher/autok3s https://docs.ranch…