Skip to content

Commit 1bdd051

Browse files
committed
fix(engine): enable support for high-availability via etcd
1 parent d708b1a commit 1bdd051

File tree

7 files changed

+222
-112
lines changed

7 files changed

+222
-112
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
A lightweight Kubernetes engine that deploys `k3s` clusters declaratively based on a cluster configuration file. The name is an abbreviation for _k3s engine_ and a hommage to the German word for cheese, _Käse [ˈkɛːzə]_.
88

9+
**🐉 Here be dragons:** As the version indicates, this is experimental software. The API is subject to change and there are no stability guarantees. Use at your own risk. We recommend to have a disaster recovery strategy in place.
10+
911
## Quickstart 💡
1012

1113
If you want to test `k3se` you can use [Vagrant][website-vagrant]. All examples in the `examples/` folder can be used with the provided `Vagrantfile` that provisions 3 Ubuntu VMs. To bring up the VMs you can run the following command:
@@ -32,11 +34,10 @@ $ echo "$(whoami) ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$(whoami)
3234

3335
The following features are currently not supported, but are planned for future releases:
3436

35-
- **High availability**
36-
Currently the installation will fail if more than a single node with the role `server` is specified.
37-
3837
- **Downsizing**
39-
If nodes are removed from the cluster configuration, they are not decommissioned. We plan to enable this feature in the future using the `git` history of the cluster configuration.
38+
If nodes are removed from the cluster configuration, they are not decommissioned. We plan to enable this feature in the future; performing operations similar to `kubectl cordon` and `kubectl drain` automagically.
39+
- **Diffing**
40+
Using the `git` history of the cluster configuration to display potential actions that can be taken to bring the cluster up to date with the configuration.
4041

4142
## License 📄
4243

examples/agents.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ version: stable
66
# to all nodes in the cluster. All options are equivalent to the
77
# commmand line options of the `k3s` command.
88
cluster:
9+
# It is highly recommended to always specify this option as it
10+
# is used to determine the server URL of the cluster.
911
tls-san:
1012
- 192.168.56.11
1113
write-kubeconfig-mode: "644"
14+
node-label:
15+
- example=agents
1216

1317
# A list of all nodes in the cluster and their connection information.
1418
nodes:
@@ -19,20 +23,22 @@ nodes:
1923
key-file: ~/.ssh/id_ed25519
2024
config:
2125
node-label:
22-
- site=vagrant
26+
- hostname=kube1
27+
2328
- role: agent
2429
ssh:
2530
host: 192.168.56.12
2631
user: vagrant
2732
key-file: ~/.ssh/id_ed25519
2833
config:
2934
node-label:
30-
- site=vagrant
35+
- hostname=kube2
36+
3137
- role: agent
3238
ssh:
3339
host: 192.168.56.13
3440
user: vagrant
3541
key-file: ~/.ssh/id_ed25519
3642
config:
3743
node-label:
38-
- site=vagrant
44+
- hostname=kube3

examples/ha.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Version may either be a specific k3s version or a release channel
2+
# as listed here: https://update.k3s.io/v1-release/channels
3+
version: stable
4+
5+
# Cluster provides cluster-wide settings that should be applied
6+
# to all nodes in the cluster. All options are equivalent to the
7+
# commmand line options of the `k3s` command.
8+
cluster:
9+
# It is highly recommended to always specify this option as it
10+
# is used to determine the server URL of the cluster.
11+
tls-san:
12+
- 192.168.56.11
13+
write-kubeconfig-mode: "644"
14+
# IMPORTANT: Setting this options is required if your
15+
# HA cluster nodes have multiple network interfaces.
16+
flannel-iface: "enp0s3"
17+
node-label:
18+
- example=ha
19+
20+
# A list of all nodes in the cluster and their connection information.
21+
nodes:
22+
- role: server
23+
ssh:
24+
host: 192.168.56.11
25+
user: vagrant
26+
key-file: ~/.ssh/id_ed25519
27+
config:
28+
node-label:
29+
- mylabel=a
30+
# IMPORTANT: Setting this options is required if your
31+
# HA cluster nodes have multiple network interfaces.
32+
node-ip: 192.168.56.11
33+
node-external-ip: 192.168.56.11
34+
35+
- role: server
36+
ssh:
37+
host: 192.168.56.12
38+
user: vagrant
39+
key-file: ~/.ssh/id_ed25519
40+
config:
41+
node-label:
42+
- mylabel=b
43+
# IMPORTANT: Setting this options is required if your
44+
# HA cluster nodes have multiple network interfaces.
45+
node-ip: 192.168.56.12
46+
node-external-ip: 192.168.56.12
47+
48+
- role: server
49+
ssh:
50+
host: 192.168.56.13
51+
user: vagrant
52+
key-file: ~/.ssh/id_ed25519
53+
config:
54+
node-label:
55+
- mylabel=c
56+
# IMPORTANT: Setting this options is required if your
57+
# HA cluster nodes have multiple network interfaces.
58+
node-ip: 192.168.56.13
59+
node-external-ip: 192.168.56.13

examples/proxy.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ version: stable
66
# to all nodes in the cluster. All options are equivalent to the
77
# commmand line options of the `k3s` command.
88
cluster:
9+
# It is highly recommended to always specify this option as it
10+
# is used to determine the server URL of the cluster.
911
tls-san:
1012
- 192.168.56.11
1113
write-kubeconfig-mode: "644"
14+
node-label:
15+
- example=proxy
1216

1317
# A list of all nodes in the cluster and their connection information.
1418
nodes:
@@ -19,7 +23,7 @@ nodes:
1923
key-file: ~/.ssh/id_ed25519
2024
config:
2125
node-label:
22-
- site=vagrant
26+
- mylabel=a
2327

2428
# An SSH proxy, also known as jumpbox or a bastion host
2529
# can be used to access nodes in a private network.

examples/standalone.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ version: stable
66
# to all nodes in the cluster. All options are equivalent to the
77
# commmand line options of the `k3s` command.
88
cluster:
9+
# It is highly recommended to always specify this option as it
10+
# is used to determine the server URL of the cluster.
911
tls-san:
1012
- 192.168.56.11
1113
write-kubeconfig-mode: "644"
14+
node-label:
15+
- example=standalone
1216

1317
# A list of all nodes in the cluster and their connection information.
1418
nodes:
@@ -19,4 +23,4 @@ nodes:
1923
key-file: ~/.ssh/id_ed25519
2024
config:
2125
node-label:
22-
- site=vagrant
26+
- mylabel=a

pkg/engine/config.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ type K3sConfig struct {
3333
TLSSAN []string `yaml:"tls-san,omitempty"`
3434
Disable []string `yaml:"disable,omitempty"`
3535
AdvertiseAddress string `yaml:"advertise-address,omitempty"`
36-
NodeLabel []string `yaml:"node-label"`
36+
FlannelIface string `yaml:"flannel-iface,omitempty"`
37+
NodeIP string `yaml:"node-ip,omitempty"`
38+
NodeExternalIP string `yaml:"node-external-ip,omitempty"`
39+
NodeLabel []string `yaml:"node-label,omitempty"`
3740
// TODO: Add missing config options as specified here:
3841
// https://rancher.com/docs/k3s/latest/en/installation/install-options/server-config/#k3s-server-cli-help
3942
}
@@ -118,10 +121,8 @@ func (c *Config) Verify() error {
118121
return errors.New("no control-plane nodes specified")
119122
}
120123

121-
if controlPlanes > 1 {
122-
return errors.New("unimplemented: multiple control-plane nodes")
123-
124-
// TODO: Check that backend is not SQLite if HA is enabled.
124+
if controlPlanes%2 == 0 {
125+
return errors.New("number of control-plane nodes must be odd")
125126
}
126127

127128
return nil

0 commit comments

Comments
 (0)