Skip to content

Commit d82e050

Browse files
devoncrousehyder
authored andcommitted
feat: Add Calico install options + VCN-Native CNI config
Signed-off-by: Devon Crouse <[email protected]>
1 parent 8e1a6ab commit d82e050

16 files changed

+604
-51
lines changed

docs/configuration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ kubectl --namespace=default get secret ocirsecret --export -o yaml | kubectl app
242242

243243
== Configure Calico parameters
244244

245-
The calico parameters control the installation of {uri-calico}[Calico] for {uri-calico-policy}[network policy].
245+
The Calico parameters control the installation of {uri-calico}[Calico] for {uri-calico-policy}[network policy].
246246

247247
{uri-terraform-options}#calico[Reference]
248248

docs/terraformoptions.adoc

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
:uri-rel-file-base: link:{uri-repo}/blob/main
1010
:uri-rel-tree-base: link:{uri-repo}/tree/main
1111
:uri-calico: https://www.projectcalico.org/
12-
:uri-calico-policy: https://docs.projectcalico.org/getting-started/kubernetes/flannel/flannel
12+
:uri-calico-docs: https://projectcalico.docs.tigera.io
13+
:uri-calico-networking: {uri-calico-docs}/networking/determine-best-networking#about-calico-networking
14+
:uri-calico-policy: {uri-calico-docs}/getting-started/kubernetes/flannel/flannel
15+
:uri-calico-mtu: {uri-calico-docs}/networking/mtu
16+
:uri-calico-manifests: https://github.com/projectcalico/calico/tree/master/manifests
17+
:uri-calico-apiserver: {uri-calico-docs}/reference/architecture/overview#calico-api-server
18+
:uri-typha: {uri-calico-docs}/reference/typha/overview
1319
:uri-cert-manager: https://cert-manager.readthedocs.io/en/latest/
1420
:uri-docs: {uri-rel-file-base}/docs
1521
:uri-kubernetes-hpa: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
@@ -1000,14 +1006,39 @@ Refer to {uri-topology}[topology] for more thorough examples.
10001006
|Default
10011007

10021008
|enable_calico
1003-
|Whether to install {uri-calico}[Calico] as {uri-calico-policy}[pod network policy].
1009+
|Whether to install {uri-calico}[Calico] for pod {uri-calico-policy}[network policy] and/or {uri-calico-networking}[networking].
10041010
|true/false
10051011
|false
10061012

10071013
|calico_version
10081014
|Version of {uri-calico}[Calico] to install.
1009-
|3.19
1010-
|3.19
1015+
|3.7-3.21, 3.24.1-3.24.5
1016+
|3.24.5
1017+
1018+
|calico_mode
1019+
|{uri-calico}[Calico] installation {uri-calico-manifests}[mode].
1020+
|canal, vxlan, flannel-migration, policy-only, ipip
1021+
|policy-only
1022+
1023+
|calico_mtu
1024+
|{uri-calico-mtu}[Interface MTU] for {uri-calico}[Calico] device(s).
1025+
|`8980` (IP-in-IP), `8950` (VXLAN), `0` (Auto)
1026+
|0
1027+
1028+
|calico_apiserver_enabled
1029+
|Whether to enable the {uri-calico-apiserver}[Calico apiserver] component.
1030+
|true/false
1031+
|false
1032+
1033+
|typha_enabled
1034+
|Whether to enable Typha. Requires `cni_type = flannel`. Always `true` when >50 nodes.
1035+
|true/false
1036+
|false
1037+
1038+
|typha_replicas
1039+
|# of Typha replicas.
1040+
|`0`-`5`+, `0` (Auto)
1041+
|0
10111042

10121043
|===
10131044

main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,16 @@ module "extensions" {
380380
username = var.username
381381

382382
# calico parameters
383-
calico_version = var.calico_version
384-
install_calico = var.enable_calico
383+
install_calico = var.enable_calico
384+
calico_version = var.calico_version
385+
calico_mode = var.calico_mode
386+
cni_type = var.cni_type
387+
calico_mtu = var.calico_mtu
388+
calico_url = var.calico_url
389+
calico_apiserver_enabled = var.calico_apiserver_enabled
390+
calico_staging_dir = var.calico_staging_dir
391+
typha_enabled = var.typha_enabled
392+
typha_replicas = var.typha_replicas
385393

386394
# metric server
387395
enable_metric_server = var.enable_metric_server

modules/extensions/calico.tf

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
## Copyright 2017, 2021 Oracle Corporation and/or affiliates.
2-
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
1+
# Copyright (c) 2017, 2022 Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
resource "null_resource" "install_calico" {
55
connection {
@@ -16,16 +16,47 @@ resource "null_resource" "install_calico" {
1616

1717
depends_on = [null_resource.install_k8stools_on_operator, null_resource.write_kubeconfig_on_operator]
1818

19+
provisioner "remote-exec" {
20+
inline = [
21+
"mkdir -p ${var.calico_staging_dir}"
22+
]
23+
}
24+
25+
provisioner "file" {
26+
source = "${path.module}/resources/calico"
27+
destination = "${var.calico_staging_dir}/"
28+
}
29+
1930
provisioner "file" {
20-
content = local.install_calico_template
21-
destination = "/home/opc/install_calico.sh"
31+
source = "${path.module}/scripts/split_yaml.awk"
32+
destination = "${var.calico_staging_dir}/split_yaml.awk"
33+
}
34+
35+
provisioner "file" {
36+
content = local.calico_env_template
37+
destination = "${var.calico_staging_dir}/calico_env.sh"
38+
}
39+
40+
provisioner "file" {
41+
source = "${path.module}/scripts/calico_install.sh"
42+
destination = "${var.calico_staging_dir}/calico_install.sh"
2243
}
2344

2445
provisioner "remote-exec" {
2546
inline = [
26-
"if [ -f \"$HOME/install_calico.sh\" ]; then bash \"$HOME/install_calico.sh\"; rm -f \"$HOME/install_calico.sh\";fi",
47+
"bash ${var.calico_staging_dir}/calico_install.sh && rm -r ${var.calico_staging_dir}"
2748
]
2849
}
2950

51+
triggers = {
52+
calico_mode = var.calico_mode
53+
calico_mtu = var.calico_mtu
54+
calico_url = var.calico_url
55+
calico_version = var.calico_version
56+
calico_apiserver_enabled = var.calico_apiserver_enabled
57+
typha_enabled = var.typha_enabled
58+
typha_replicas = var.typha_replicas
59+
}
60+
3061
count = local.post_provisioning_ops == true && var.install_calico == true ? 1 : 0
3162
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
spec:
2+
template:
3+
spec:
4+
containers:
5+
- name: "calico-node"
6+
env:
7+
- name: "CALICO_IPV4POOL_CIDR"
8+
value: "${POD_CIDR}"
9+
- name: "CALICO_IPV4POOL_VXLAN"
10+
value: "${IPV4POOL_VXLAN}"
11+
- name: "FELIX_IPTABLESBACKEND"
12+
value: "${IPTABLES_BACKEND}"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
spec:
2+
template:
3+
spec:
4+
containers:
5+
- name: "calico-node"
6+
env:
7+
- name: "FELIX_INTERFACEPREFIX"
8+
value: "oci"
9+
- name: "NO_DEFAULT_POOLS"
10+
value: "true"
11+
- name: "FELIX_CHAININSERTMODE"
12+
value: "Append"
13+
- name: "FELIX_IPTABLESMANGLEALLOWACTION"
14+
value: "Return"
15+
- name: "FELIX_IPTABLESBACKEND"
16+
value: "${iptables_backend}"
17+
- name: "USE_POD_CIDR"
18+
value: "true"
19+
- name: "FELIX_REMOVEEXTERNALROUTES"
20+
value: "false"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: crd.projectcalico.org/v1
2+
kind: FelixConfiguration
3+
metadata:
4+
name: default
5+
spec:
6+
ipv6Support: false
7+
iptablesBackend: ${iptables_backend}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: crd.projectcalico.org/v1
2+
kind: FelixConfiguration
3+
metadata:
4+
name: default
5+
spec:
6+
ipv6Support: false
7+
chainInsertMode: Append
8+
iptablesBackend: ${iptables_backend}
9+
interfacePrefix: oci
10+
iptablesMangleAllowAction: Return
11+
removeExternalRoutes: false
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2022 Oracle Corporation and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
4+
# shellcheck disable=SC2034,SC2154,SC2269 # Ignore templated file variables
5+
set -ae
6+
MODE=${mode}
7+
VERSION=${version}
8+
CNI_TYPE=${cni_type}
9+
POD_CIDR=${pod_cidr}
10+
MTU=${mtu}
11+
URL=${url}
12+
APISERVER_ENABLED=${apiserver_enabled}
13+
TYPHA_ENABLED=${typha_enabled}
14+
TYPHA_REPLICAS=${typha_replicas}

0 commit comments

Comments
 (0)