preface

Last time, Clusterfile was explained in detail, and you should have a better understanding of SEALer, so this article will talk about cluster backup scaling knowledge.

1. Enlarge shrinks

1.1 ALI_CLOUD Capacity Expansion

The ALI_CLOUD mode is provider: ALI_CLOUD

1.1.1 Clusterfile Configuring capacity expansion

For example, the following configuration file is a clusterFile under your current cluster.sealer /my-cluster/ path (you can also write a new file and overwrite the running file) :

We can see that the count on the master node has 3 nodes. If you want to expand the number of nodes, change the count to 4; If you want to shrink the number of nodes, change count to 2 and use apply to effect ClusterFile

ApiVersion: sealer.aliyun.com/v1alpha1 kind: Cluster metadata: name: my - Cluster spec: # Cluster mirror image: Registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes:v1.19.9 # current cluster pattern provider: ALI_CLOUD network: # in use NIC name interface: eth0 # Network plug-in name cniName: calico podCIDR: 100.64.0.0/10 svcCIDR: 10.96.0.0/22 withoutCNI: false certSANS: -aliyun-inc.com -10.0.0.2 masters: CPU: 4 memory: 4 # Scale down or expand the capacity based on the value of count: 3 systemDisk: 100 dataDisks: -100 Nodes: CPU: 4 Memory: 4 3 systemDisk: 100 dataDisks: - 100Copy the code

1.1.2 Using the join command, delete capacity reduction was configured

Of course, in this mode, you can also use the join command to expand the size

# expand sealer join --masters 2 --nodes 3 # expand Sealer delete --masters 2 --nodes 3Copy the code

1.2 Capacity Expansion in BAREMETAL Mode

The BAREMETAL mode is provider: BAREMETAL

1.2.1 Clusterfile Configuring capacity expansion

For example, the following configuration file is a clusterFile under your current cluster.sealer /my-cluster/ path (you can also write a new file and overwrite the running file) :

If you want to shrink the ipList, delete one IP. If you want to increase the ipList, add another IP. Then apply to clusterFile.

ApiVersion: sealer.aliyun.com/v1alpha1 kind: Cluster metadata: name: my - Cluster spec: # Cluster mirror image: Registry.cn-qingdao.aliyuncs.com/sealer-io/kubernetes:v1.19.9 # current cluster pattern provider: BAREMETAL SSH: # SSH login password, if you use the key to login, you don't need to set it passwd: ## The absolute path of the ssh private key file, for example /root/.ssh/id_rsa pk: xxx # The password of the ssh private key file, if there is none, set it to "" pkPasswd: xxx # ssh login user user: Root network: # in use NIC name interface: eth0 # network plug-in name cniName: calico podCIDR: 100.64.0.0/10 svcCIDR: 10.96.0.0/22 withoutCNI: false certSANS: -aliyun-inc.com -10.0.0.2 masters: -172.20.126.4 -172.20.126.5 -172.20.126.6 Nodes: # Reduce or expand ipList based on the iplList value: 172.20.126.8-172.20.126.9-172.20.126.10Copy the code

1.2.2 Run the join command to expand capacity, and run the delete command to reduce capacity

In this mode, you can also use the join command to expand capacity or the delete command to reduce capacity

Sealer delete --masters 192.168.0.2 --nodes 192.168.0.3Copy the code

Backup and restoration

Backups utilize the plugin mechanism, kind: If you have an OSS address in YAML, it will upload your backup files to oss. If not, the default path is $(rootfs)/ Plugin /ETCD_BACKUP file.

--- apiVersion: sealer.aliyun.com/v1alpha1 kind: Plugin metadata: name: ETCD_BACKUP spec: action: Manual #, you can configure the oss address for backup storage data: | alioss: ossendpoint: oss-cn-hangzhou.aliyuncs.com accesskeyid: ***** accesskeysecrets: **** bucketname: etcdbackup objectpath: /sealos/Copy the code

3. Upgrade

Run the following command to upgrade a cluster mirror

sealer upgrade
Copy the code

The workflow of the upgrade command can be summarized as follows:

Parse the parameters of the command -> execute the Apply() function -> execute the diff() function to get todoList -> execute the function in todoList -> Upgrade successfully -> update the value of the Image variable of the current cluster.

Source code analysis refer to the official documentation sealer upgrade command principle and implementation

conclusion

For more information about Clusterfile, please visit sealer’s official Git address. Creation is not easy, please click like, click follow, will share more useful information later.

Recommended reading

  • One of Sealer’s full family of cluster packaging tools – download, install and use
  • Cluster Package Sealer Series ii – Overview of the architecture
  • Cluster Package Sealer series 3 – Clusterfile super details