Skip to content

Commit bdaf643

Browse files
Fixing Calico installation steps (#1523)
This update moves Calico to an operator based installer. Removes the `calico.yaml` since it is not the recommended way. What's next section.
1 parent 3b15086 commit bdaf643

File tree

2 files changed

+46
-3811
lines changed

2 files changed

+46
-3811
lines changed

docs/usage/advanced/calico.md

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,76 @@
11
# Use Calico instead of Flannel
22

33
!!! info "Network Policies"
4-
k3s comes with a controller that enforces network policies by default. You do not need to switch to Calico for network policies to be enforced. See <https://github.com/k3s-io/k3s/issues/1308> for more information.
5-
The docs below assume you want to switch to Calico's policy engine, thus setting `--disable-network-policy`.
4+
k3s comes with a controller that enforces network policies by default.
5+
While You do not need to switch to any CNIs for Kubernetes network policies to be enforced, other CNIs such as Calico can help you to bridge the gap where Kubernetes network policies may lack some capabilities. See <https://github.com/k3s-io/k3s/issues/1308> for more information.
6+
The docs below assume you want to switch to Calico's policy engine, thus setting `--disable-network-policy@server:*`.
67

7-
## 1. Download and modify the Calico descriptor
8-
9-
You can following the [documentation](https://docs.projectcalico.org/master/reference/cni-plugin/configuration)
10-
11-
And then you have to change the ConfigMap `calico-config`. On the `cni_network_config` add the entry for allowing IP forwarding
12-
13-
```json
14-
"container_settings": {
15-
"allow_ip_forwarding": true
16-
}
17-
```
18-
19-
Or you can directly use this [calico.yaml](calico.yaml) manifest
20-
21-
## 2. Create the cluster without flannel and with calico
22-
23-
On the k3s cluster creation :
24-
25-
- add the flags `--flannel-backend=none` and `--disable-network-policy`. For this, on k3d you need to forward this flag to k3s with the option `--k3s-arg`.
26-
- mount (`--volume`) the calico descriptor in the auto deploy manifest directory of k3s `/var/lib/rancher/k3s/server/manifests/`
27-
28-
So the command of the cluster creation is (when you are at root of the k3d repository)
8+
## 1. Create the cluster without flannel
9+
By default K3s deploys flannel CNI to take care of networking in your environment.
10+
Since we want to use Calico in this example we have to disable the default CNI.
11+
This can be done by using the `--k3s-arg` flag at the cluster creation time.
2912

13+
Use the following command to create your cluster:
3014
```bash
3115
k3d cluster create "${clustername}" \
3216
--k3s-arg '--flannel-backend=none@server:*' \
33-
--k3s-arg '--disable-network-policy' \
34-
--volume "$(pwd)/docs/usage/guides/calico.yaml:/var/lib/rancher/k3s/server/manifests/calico.yaml"
17+
--k3s-arg '--disable-network-policy@server:*' \
18+
--k3s-arg '--cluster-cidr=192.168.0.0/16@server:*'
3519
```
3620

3721
In this example :
3822

39-
- change `"${clustername}"` with the name of the cluster (or set a variable).
40-
- `$(pwd)/docs/usage/guides/calico.yaml` is the absolute path of the calico manifest, you can adapt it.
23+
- Change the `"${clustername}"` with the name of the cluster (or set a variable).
24+
- Cluster will use the "192.168.0.0/16" CIDR, if you want to change the default CIDR make sure to change it in the `custom-resources.yaml` too.
4125

42-
You can add other options, [see](../commands.md).
26+
## 2. Install Calico
27+
A simple way to install Calico is to use the Tigera Operator.
28+
The operator helps us to configure, install and upgrade Calico in an environment.
4329

44-
The cluster will start without flannel and with Calico as CNI Plugin.
30+
Use the following command to install the operator:
31+
```bash
32+
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/tigera-operator.yaml
33+
```
4534

46-
For watching for the pod(s) deployment
35+
The operator periodically checks for the installation manifest.
36+
This manifest is how we instruct the Tigera Operator to install Calico.
4737

38+
Use the following command to create the installation manifest:
4839
```bash
49-
watch "kubectl get pods -n kube-system"
40+
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.0/manifests/custom-resources.yaml
5041
```
5142

52-
You will have something like this at beginning (with the command line `#!bash kubectl get pods -n kube-system`)
53-
43+
At this point, our installation is in progress, and we can verify it by using the following command:
5444
```bash
55-
NAME READY STATUS RESTARTS AGE
56-
helm-install-traefik-pn84f 0/1 Pending 0 3s
57-
calico-node-97rx8 0/1 Init:0/3 0 3s
58-
metrics-server-7566d596c8-hwnqq 0/1 Pending 0 2s
59-
calico-kube-controllers-58b656d69f-2z7cn 0/1 Pending 0 2s
60-
local-path-provisioner-6d59f47c7-rmswg 0/1 Pending 0 2s
61-
coredns-8655855d6-cxtnr 0/1 Pending 0 2s
45+
kubectl get tigerastatus
46+
```
47+
48+
After a minute, you should see a result similar to the following:
49+
```
50+
NAME AVAILABLE PROGRESSING DEGRADED SINCE
51+
apiserver True False False 30s
52+
calico True False False 10s
53+
ippools True False False 70s
6254
```
6355

64-
And when it finish to start
56+
Great Calico is up and running!
6557

58+
## 3. IP forwarding
59+
By default, Calico disables IP forwarding inside the containers.
60+
This can cause an issue in some cases where you are using load balancers. You can learn more about loadblanacers [here](https://docs.k3s.io/networking/networking-services#service-load-balancer).
61+
To fix this issue we have to turn on the IP forwarding flag inside `calico-node` pods.
62+
63+
Use the following command to enable forwarding via the operator:
6664
```bash
67-
NAME READY STATUS RESTARTS AGE
68-
metrics-server-7566d596c8-hwnqq 1/1 Running 0 56s
69-
calico-node-97rx8 1/1 Running 0 57s
70-
helm-install-traefik-pn84f 0/1 Completed 1 57s
71-
svclb-traefik-lmjr5 2/2 Running 0 28s
72-
calico-kube-controllers-58b656d69f-2z7cn 1/1 Running 0 56s
73-
local-path-provisioner-6d59f47c7-rmswg 1/1 Running 0 56s
74-
traefik-758cd5fc85-x8p57 1/1 Running 0 28s
75-
coredns-8655855d6-cxtnr 1/1 Running 0 56s
65+
kubectl patch installation default --type=merge --patch='{"spec":{"calicoNetwork":{"containerIPForwarding":"Enabled"}}}'
7666
```
7767

78-
Note :
79-
80-
- you can use the auto deploy manifest or a kubectl apply depending on your needs
81-
- :exclamation: Calico is not as quick as Flannel (but it provides more features)
68+
## 4. What's next?
69+
Check out our other guides, here some suggestions:
70+
- Add an additional node to your setup. [see](k3d_node.md)
71+
- Expose your services. [see](exposing_services.md)
8272

8373
## References
8474

8575
- <https://rancher.com/docs/k3s/latest/en/installation/network-options/>
86-
- <https://docs.projectcalico.org/getting-started/kubernetes/k3s/>
76+
- <https://docs.tigera.io/calico/latest/getting-started/kubernetes/k3s/quickstart>

0 commit comments

Comments
 (0)