Skip to content

Commit

Permalink
chore: Bump default Kubernetes version to 1.22.0 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibordp authored Aug 6, 2021
1 parent 4477ed4 commit 863a220
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module "k8s" {
master_server_type = "cx31"
worker_server_type = "cx31"
worker_count = 2
kubernetes_version = "1.22.0"
}
output "kubeconfig" {
Expand All @@ -58,9 +60,9 @@ and check the access by viewing the created cluster nodes:
```cmd
$ kubectl get nodes --kubeconfig=kubeconfig.conf
NAME STATUS ROLES AGE VERSION
k8s-master-0 Ready control-plane,master 31m v1.21.1
k8s-worker-0 Ready <none> 31m v1.21.1
k8s-worker-1 Ready <none> 31m v1.21.1
k8s-master-0 Ready control-plane,master 31m v1.22.0
k8s-worker-0 Ready <none> 31m v1.22.0
k8s-worker-1 Ready <none> 31m v1.22.0
```

## High availability setup
Expand All @@ -75,7 +77,7 @@ cluster will have to be manually reconfigured (e.g [like this](https://blog.scot

### Removing/replacing master nodes

A first step before removing a control plane node is to remove its membership in the `etcd` cluster. **Read this section carefully before removing master nodes! If etcd membership is not removed from the prior to the node being shutdown, the whole cluster can become inoperable.** If the master node that is being removed is still functional, the easiest way to remove is by invoking the following command on the node:
A first step before removing a control plane node is to remove its membership in the `etcd` cluster. **Read this section carefully before removing master nodes! If etcd membership is not removed from the prior to the node being shutdown, the whole cluster can potentially become inoperable.** If the master node that is being removed is still functional, the easiest way to remove is by invoking the following command on the node:

```cmd
kubeadm reset --force
Expand All @@ -101,6 +103,8 @@ If the node is already defunct, there are two cases to consider:
Member 2a51630843ac2da6 removed from cluster 46b13f81dcebb93d
```

It is important to remove failed members from etcd even if quorum is still present as new master nodes will not be able to join until etcd cluster is healthy.

- etcd cluster no longer has quorum, e.g. a single master node is gone out of a 2-node cluster. In this case the etcd cluster will need to be rebuilt from snapshot, following the steps for [disaster recovery](https://etcd.io/docs/v3.4/op-guide/recovery/). Data loss may have occured.


Expand Down
13 changes: 6 additions & 7 deletions modules/kubernetes-node/scripts/prepare-node.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ sudo sysctl --system
sudo apt-get update -qq
sudo apt-get install -qq apt-transport-https ca-certificates curl gnupg lsb-release ipvsadm wireguard
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/kubernetes-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | \
sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo tee /etc/apt/sources.list.d/kubernetes.list >/dev/null

# Install container runtime and Kubernetes
sudo apt-get update -qq
sudo apt-get install -qq containerd.io kubelet=${kubernetes_version}-00 kubeadm=${kubernetes_version}-00 kubectl=${kubernetes_version}-00
apt-mark hold kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

# Enable systemd cgroups driver
sudo mkdir -p /etc/containerd
containerd config default | \
perl -i -pe 's/(\s+)(\[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options\])/\1\2\n\1 SystemdCgroup = true/g' | \
sudo tee /etc/containerd/config.toml > /dev/null
perl -pe 's/(\s+)(\[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options\])/\1\2\n\1 SystemdCgroup = true/g' | \
sudo tee /etc/containerd/config.toml >/dev/null

# Necessary for out-of-tree cloud providers as of 1.21.1 (soon to be deprecated)
cat <<EOF | sudo tee /etc/systemd/system/kubelet.service.d/20-hcloud.conf > /dev/null
[Service]
Environment="KUBELET_EXTRA_ARGS=--cloud-provider=external --node-ip=::"
Expand Down
2 changes: 1 addition & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ teardown_cluster() {

case "$1" in
kubectl)
curl -LO https://dl.k8s.io/release/v1.21.2/bin/linux/amd64/kubectl
curl -LO https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl
chmod +x kubectl
;;
setup)
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ variable "primary_ip_family" {
}

variable "kubernetes_version" {
description = "Version of Kubernetes to install (default: 1.21.2)"
description = "Version of Kubernetes to install (default: 1.22.0)"
type = string
default = "1.21.2"
default = "1.22.0"
}

0 comments on commit 863a220

Please sign in to comment.