Skip to content

Commit

Permalink
🌱 update CAPH upgrade docs (#1263)
Browse files Browse the repository at this point in the history
* update CAPH upgrade docs

Signed-off-by: kranurag7 <[email protected]>
  • Loading branch information
kranurag7 authored May 8, 2024
1 parent e6bccc2 commit 3392491
Showing 1 changed file with 66 additions and 84 deletions.
150 changes: 66 additions & 84 deletions docs/topics/upgrade.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# Upgrading the Kubernetes Cluster API Provider Hetzner

This guide explains how to upgrade Cluster API Provider Hetzner (aka CAPH).
This guide explains how to upgrade Cluster API and Cluster API Provider Hetzner (aka CAPH). Additionally, it also references [upgrading your kubernetes version](#external-cluster-api-reference) as part of this guide.

## Set matching kubeconfig

Connect `kubectl` to the management cluster.

We use `.envrc` files with [direnv](https://direnv.net/),
but this is optional.

```
❯ cd mgm-cluster/
direnv: loading ~/mgm-cluster/.envrc
direnv: export +KUBECONFIG +STARSHIP_CONFIG
```

Check, that you are connected to the correct cluster:

```
Expand All @@ -24,13 +15,22 @@ mgm-cluster-admin@mgm-cluster

OK, looks good.

# Update clusterctl
## Update clusterctl

Is clusterctl still up to date?

```
❯ clusterctl version
clusterctl version: &version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.2", GitCommit:"18c6e8e6cda0eaf71d509258186fa8db30a8fa62", GitTreeState:"clean", BuildDate:"2023-01-10T13:20:59Z", GoVersion:"go1.19.4", Compiler:"gc", Platform:"linux/amd64"}
$ clusterctl version -oyaml
clusterctl:
buildDate: "2024-04-09T17:23:12Z"
compiler: gc
gitCommit: c9136af030eaba5deed7be5ca9f6c3f5e6d69334
gitTreeState: clean
gitVersion: v1.7.0-rc.1
goVersion: go1.21.9
major: "1"
minor: "7"
platform: linux/amd64
```

You can see the current version here:
Expand All @@ -39,24 +39,24 @@ https://cluster-api.sigs.k8s.io/user/quick-start.html#install-clusterctl

If your clusterctl is outdated, then upgrade it. See the above URL for details.

# clusterctl upgrade plan
## clusterctl upgrade plan

Have a look at what could get upgraded:

```
clusterctl upgrade plan
$ clusterctl upgrade plan
Checking cert-manager version...
Cert-Manager will be upgraded from "v1.10.1" to "v1.11.0"
Cert-Manager is already up to date
Checking new release availability...
Latest release available for the v1beta1 API Version of Cluster API (contract):
NAME NAMESPACE TYPE CURRENT VERSION NEXT VERSION
bootstrap-kubeadm capi-kubeadm-bootstrap-system BootstrapProvider v1.3.2 v1.4.1
control-plane-kubeadm capi-kubeadm-control-plane-system ControlPlaneProvider v1.3.2 v1.4.1
cluster-api capi-system CoreProvider v1.3.2 v1.4.1
infrastructure-hetzner cluster-api-provider-hetzner-system InfrastructureProvider v1.0.0-beta.14 Already up to date
NAME NAMESPACE TYPE CURRENT VERSION NEXT VERSION
bootstrap-kubeadm capi-kubeadm-bootstrap-system BootstrapProvider v1.6.0 v1.6.3
control-plane-kubeadm capi-kubeadm-control-plane-system ControlPlaneProvider v1.6.0 v1.6.3
cluster-api capi-system CoreProvider v1.6.0 v1.6.3
infrastructure-hetzner caph-system InfrastructureProvider v1.0.0-beta.30 Already up to date
You can now apply the upgrade by executing the following command:
Expand All @@ -67,89 +67,71 @@ Docs: [clusterctl upgrade plan](https://cluster-api.sigs.k8s.io/clusterctl/comma

You might be surprised that for `infrastructure-hetzner`, you see the "Already up to date" message below "NEXT VERSION".

`clusterctl upgrade plan` does not display pre-release versions by default.
NOTE: `clusterctl upgrade plan` does not display pre-release versions by default.

# Upgrade cluster-API
## Upgrade cluster-API

We will upgrade cluster API core components to v1.6.3 version.
Use the command, which you saw in the plan:

```
clusterctl upgrade apply --contract v1beta1
```bash
$ clusterctl upgrade apply --contract v1beta1
Checking cert-manager version...
Deleting cert-manager Version="v1.10.1"
Installing cert-manager Version="v1.11.0"
Waiting for cert-manager to be available...
Cert-manager is already up to date
Performing upgrade...
Scaling down Provider="cluster-api" Version="v1.3.2" Namespace="capi-system"
Scaling down Provider="bootstrap-kubeadm" Version="v1.3.2" Namespace="capi-kubeadm-bootstrap-system"
Scaling down Provider="control-plane-kubeadm" Version="v1.3.2" Namespace="capi-kubeadm-control-plane-system"
Deleting Provider="cluster-api" Version="v1.3.2" Namespace="capi-system"
Installing Provider="cluster-api" Version="v1.4.1" TargetNamespace="capi-system"
Deleting Provider="bootstrap-kubeadm" Version="v1.3.2" Namespace="capi-kubeadm-bootstrap-system"
Installing Provider="bootstrap-kubeadm" Version="v1.4.1" TargetNamespace="capi-kubeadm-bootstrap-system"
Deleting Provider="control-plane-kubeadm" Version="v1.3.2" Namespace="capi-kubeadm-control-plane-system"
Installing Provider="control-plane-kubeadm" Version="v1.4.1" TargetNamespace="capi-kubeadm-control-plane-system"
Scaling down Provider="cluster-api" Version="v1.6.0" Namespace="capi-system"
Scaling down Provider="bootstrap-kubeadm" Version="v1.6.0" Namespace="capi-kubeadm-bootstrap-system"
Scaling down Provider="control-plane-kubeadm" Version="v1.6.0" Namespace="capi-kubeadm-control-plane-system"
Deleting Provider="cluster-api" Version="v1.6.0" Namespace="capi-system"
Installing Provider="cluster-api" Version="v1.6.3" TargetNamespace="capi-system"
Deleting Provider="bootstrap-kubeadm" Version="v1.6.0" Namespace="capi-kubeadm-bootstrap-system"
Installing Provider="bootstrap-kubeadm" Version="v1.6.3" TargetNamespace="capi-kubeadm-bootstrap-system"
Deleting Provider="control-plane-kubeadm" Version="v1.6.0" Namespace="capi-kubeadm-control-plane-system"
Installing Provider="control-plane-kubeadm" Version="v1.6.3" TargetNamespace="capi-kubeadm-control-plane-system"
```


Great, cluster-API was upgraded.

NOTE: If you want to update only one components or update components one by one then there are flags for that under `clusterctl upgrade apply` subcommand like `--bootstrap`, `--control-plane` and `--core`.

# Upgrade CAPH
## Upgrade CAPH

You can find the latest version of CAPH here:

https://github.com/syself/cluster-api-provider-hetzner/tags

```
clusterctl upgrade apply --infrastructure cluster-api-provider-hetzner-system/hetzner:v1.0.0-beta.16
```bash
$ clusterctl upgrade apply --infrastructure=hetzner:v1.0.0-beta.33
Checking cert-manager version...
Cert-manager is already up to date
Performing upgrade...
Scaling down Provider="infrastructure-hetzner" Version="" Namespace="cluster-api-provider-hetzner-system"
Deleting Provider="infrastructure-hetzner" Version="" Namespace="cluster-api-provider-hetzner-system"
Installing Provider="infrastructure-hetzner" Version="v1.0.0-beta.16" TargetNamespace="cluster-api-provider-hetzner-system"
Scaling down Provider="infrastructure-hetzner" Version="" Namespace="caph-system"
Deleting Provider="infrastructure-hetzner" Version="" Namespace="caph-system"
Installing Provider="infrastructure-hetzner" Version="v1.0.0-beta.33" TargetNamespace="caph-system"
```

# Check your cluster
After the upgrade, you'll notice the new pod spinning up the `caph-system` namespace.
```bash
$ kubectl get pods -n caph-system
NAME READY STATUS RESTARTS AGE
caph-controller-manager-85fcb6ffcb-4sj6d 1/1 Running 0 79s
```

Check the health of your cluster with your preferred tools. For example `kubectl`.
NOTE: Please note that `clusterctl` doesn't support pre-release of GitHub by default so if you want to use a pre-release, you'll have to specify the version such as `hetzner:v1.0.0-beta.33`

```
❯ k get pods -A --sort-by=metadata.creationTimestamp
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-565d847f94-ppj8z 1/1 Running 685 (33d ago) 79d
kube-system kube-proxy-6p7lt 1/1 Running 2 (33d ago) 79d
kube-system coredns-565d847f94-nrgsk 1/1 Running 686 (33d ago) 79d
kube-system kube-apiserver-host-cluster-control-plane-64j47 1/1 Running 970 (33d ago) 79d
kube-system kube-scheduler-host-cluster-control-plane-64j47 1/1 Running 484 (33d ago) 79d
kube-system kube-controller-manager-host-cluster-control-plane-64j47 1/1 Running 493 (33d ago) 79d
kube-system etcd-host-cluster-control-plane-64j47 1/1 Running 813 (33d ago) 79d
kube-system cilium-operator-6f64975cf7-5489z 1/1 Running 524 (33d ago) 79d
kube-system cilium-qk7v7 1/1 Running 644 (33d ago) 79d
kube-system cilium-operator-6f64975cf7-z9m72 1/1 Running 538 (33d ago) 79d
kube-system ccm-ccm-hcloud-655cf4fdcc-xjszz 1/1 Running 3 (33d ago) 79d
kube-system kube-proxy-hbtnt 1/1 Running 1 (35d ago) 79d
kube-system cilium-gtvfw 1/1 Running 643 (35d ago) 79d
kube-system kube-scheduler-host-cluster-control-plane-t97fn 1/1 Running 492 (33d ago) 79d
kube-system etcd-host-cluster-control-plane-t97fn 1/1 Running 491 (33d ago) 79d
kube-system kube-apiserver-host-cluster-control-plane-t97fn 1/1 Running 560 (33d ago) 79d
kube-system kube-controller-manager-host-cluster-control-plane-t97fn 1/1 Running 492 (33d ago) 79d
kube-system hubble-relay-6676b755f6-l7vcd 1/1 Running 0 33d
kube-system hubble-ui-55f87db549-q4bxb 2/2 Running 0 33d
default netshoot 1/1 Running 2 (21d ago) 21d
kube-system cilium-l8p7s 1/1 Running 0 20d
kube-system kube-proxy-n7pwh 1/1 Running 0 20d
kube-system kube-scheduler-host-cluster-control-plane-2r25q 1/1 Running 0 20d
kube-system etcd-host-cluster-control-plane-2r25q 1/1 Running 0 20d
kube-system kube-apiserver-host-cluster-control-plane-2r25q 1/1 Running 0 20d
kube-system kube-controller-manager-host-cluster-control-plane-2r25q 1/1 Running 0 20d
cert-manager cert-manager-cainjector-ffb4747bb-bt2l7 1/1 Running 0 10m
cert-manager cert-manager-99bb69456-ntvz6 1/1 Running 0 10m
cert-manager cert-manager-webhook-545bd5d7d8-6cxxk 1/1 Running 0 10m
capi-system capi-controller-manager-746b4f5db4-zzbv9 1/1 Running 0 9m17s
capi-kubeadm-bootstrap-system capi-kubeadm-bootstrap-controller-manager-8654485994-tpvkf 1/1 Running 0 9m14s
capi-kubeadm-control-plane-system capi-kubeadm-control-plane-controller-manager-5d9d9494d5-2mqlc 1/1 Running 0 9m11s
cluster-api-provider-hetzner-system caph-controller-manager-566f996fbd-jrqc4 1/1 Running 0 2m30s
```
## Check your cluster

Check the health of your workload cluster with your preferred tools and ensure that all components are healthy especially apiserver and etcd pods.

## External Cluster API Reference

After upgrading cluster API, you may want to update the Kubernetes version of your controlplane and worker nodes. Those details can be found in the [Cluster API documentation](https://cluster-api.sigs.k8s.io/tasks/upgrading-clusters).

NOTE: The update can be done on either management cluster or workload cluster separately as well.

You should upgrade your kubernetes version after considering the following:

````markdown
A Cluster API minor release supports (when it’s initially created):
- 4 Kubernetes minor releases for the management cluster (N - N-3)
- 6 Kubernetes minor releases for the workload cluster (N - N-5)
````

0 comments on commit 3392491

Please sign in to comment.