2017-09-04 16:29:51 +08:00
|
|
|
---
|
|
|
|
# This manifest installs the calico/node container, as well
|
|
|
|
# as the Calico CNI plugins and network config on
|
|
|
|
# each master and worker node in a Kubernetes cluster.
|
|
|
|
kind: DaemonSet
|
2019-09-11 03:06:55 +08:00
|
|
|
apiVersion: apps/v1
|
2017-09-04 16:29:51 +08:00
|
|
|
metadata:
|
|
|
|
name: calico-node
|
2018-03-30 19:29:13 +08:00
|
|
|
namespace: kube-system
|
2017-09-04 16:29:51 +08:00
|
|
|
labels:
|
|
|
|
k8s-app: calico-node
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
k8s-app: calico-node
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
k8s-app: calico-node
|
|
|
|
annotations:
|
2020-10-21 22:32:20 +08:00
|
|
|
{% if calico_datastore == "etcd" %}
|
2017-09-14 02:00:51 +08:00
|
|
|
kubespray.etcd-cert/serial: "{{ etcd_client_cert_serial }}"
|
2020-10-21 22:32:20 +08:00
|
|
|
{% endif %}
|
2018-11-15 07:01:35 +08:00
|
|
|
{% if calico_felix_prometheusmetricsenabled %}
|
|
|
|
prometheus.io/scrape: 'true'
|
|
|
|
prometheus.io/port: "{{ calico_felix_prometheusmetricsport }}"
|
|
|
|
{% endif %}
|
2017-09-04 16:29:51 +08:00
|
|
|
spec:
|
2018-09-25 22:50:22 +08:00
|
|
|
priorityClassName: system-node-critical
|
2017-09-04 16:29:51 +08:00
|
|
|
hostNetwork: true
|
|
|
|
serviceAccountName: calico-node
|
|
|
|
tolerations:
|
2020-06-02 20:38:15 +08:00
|
|
|
- operator: Exists
|
2018-02-06 03:34:59 +08:00
|
|
|
# Minimize downtime during a rolling upgrade or deletion; tell Kubernetes to do a "force
|
|
|
|
# deletion": https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
|
|
|
|
terminationGracePeriodSeconds: 0
|
2019-01-29 03:03:49 +08:00
|
|
|
initContainers:
|
2020-09-25 00:04:06 +08:00
|
|
|
{% if calico_datastore == "kdd" %}
|
2019-07-10 03:42:28 +08:00
|
|
|
# This container performs upgrade from host-local IPAM to calico-ipam.
|
|
|
|
# It can be deleted if this is a fresh installation, or if you have already
|
|
|
|
# upgraded to use calico-ipam.
|
|
|
|
- name: upgrade-ipam
|
|
|
|
image: {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }}
|
|
|
|
command: ["/opt/cni/bin/calico-ipam", "-upgrade"]
|
|
|
|
env:
|
|
|
|
- name: KUBERNETES_NODE_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
- name: CALICO_NETWORKING_BACKEND
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: calico_backend
|
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /var/lib/cni/networks
|
|
|
|
name: host-local-net-dir
|
|
|
|
- mountPath: /host/opt/cni/bin
|
|
|
|
name: cni-bin-dir
|
2020-07-15 15:22:38 +08:00
|
|
|
securityContext:
|
|
|
|
privileged: true
|
2019-07-10 03:42:28 +08:00
|
|
|
{% endif %}
|
2019-01-29 03:03:49 +08:00
|
|
|
# This container installs the Calico CNI binaries
|
|
|
|
# and CNI network config file on each node.
|
|
|
|
- name: install-cni
|
|
|
|
image: {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }}
|
2020-09-25 21:15:11 +08:00
|
|
|
command: ["{{ (calico_version is version('v3.16.0', '<'))|ternary('/install-cni.sh','/opt/cni/bin/install') }}"]
|
2019-01-29 03:03:49 +08:00
|
|
|
env:
|
|
|
|
# Name of the CNI config file to create.
|
|
|
|
- name: CNI_CONF_NAME
|
|
|
|
value: "10-calico.conflist"
|
2019-04-02 18:32:36 +08:00
|
|
|
# Install CNI binaries
|
2019-01-29 03:03:49 +08:00
|
|
|
- name: UPDATE_CNI_BINARIES
|
2019-04-02 18:32:36 +08:00
|
|
|
value: "true"
|
2019-01-29 03:03:49 +08:00
|
|
|
# The CNI network config to install on each node.
|
|
|
|
- name: CNI_NETWORK_CONFIG_FILE
|
|
|
|
value: "/host/etc/cni/net.d/calico.conflist.template"
|
|
|
|
# Prevents the container from sleeping forever.
|
|
|
|
- name: SLEEP
|
|
|
|
value: "false"
|
2019-04-25 20:00:48 +08:00
|
|
|
{% if calico_datastore == "kdd" %}
|
|
|
|
# Set the hostname based on the k8s node name.
|
|
|
|
- name: KUBERNETES_NODE_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
{% endif %}
|
2019-01-29 03:03:49 +08:00
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /host/etc/cni/net.d
|
|
|
|
name: cni-net-dir
|
2019-04-02 18:32:36 +08:00
|
|
|
- mountPath: /host/opt/cni/bin
|
|
|
|
name: cni-bin-dir
|
2020-07-15 15:22:38 +08:00
|
|
|
securityContext:
|
|
|
|
privileged: true
|
2017-09-04 16:29:51 +08:00
|
|
|
containers:
|
|
|
|
# Runs calico/node container on each Kubernetes node. This
|
|
|
|
# container programs network policy and routes on each
|
|
|
|
# host.
|
|
|
|
- name: calico-node
|
|
|
|
image: {{ calico_node_image_repo }}:{{ calico_node_image_tag }}
|
|
|
|
env:
|
|
|
|
# The location of the Calico etcd cluster.
|
2019-04-25 20:00:48 +08:00
|
|
|
{% if calico_datastore == "etcd" %}
|
2017-09-04 16:29:51 +08:00
|
|
|
- name: ETCD_ENDPOINTS
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: etcd_endpoints
|
2019-04-25 20:00:48 +08:00
|
|
|
# Location of the CA certificate for etcd.
|
|
|
|
- name: ETCD_CA_CERT_FILE
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: etcd_ca
|
|
|
|
# Location of the client key for etcd.
|
|
|
|
- name: ETCD_KEY_FILE
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: etcd_key
|
|
|
|
# Location of the client certificate for etcd.
|
|
|
|
- name: ETCD_CERT_FILE
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: etcd_cert
|
|
|
|
{% elif calico_datastore == "kdd" %}
|
|
|
|
# Use Kubernetes API as the backing datastore.
|
|
|
|
- name: DATASTORE_TYPE
|
|
|
|
value: "kubernetes"
|
2019-10-17 22:02:38 +08:00
|
|
|
{% if typha_enabled %}
|
2019-04-25 20:00:48 +08:00
|
|
|
# Typha support: controlled by the ConfigMap.
|
|
|
|
- name: FELIX_TYPHAK8SSERVICENAME
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: typha_service_name
|
2019-10-17 22:02:38 +08:00
|
|
|
{% if typha_secure %}
|
|
|
|
- name: FELIX_TYPHACN
|
|
|
|
value: typha-server
|
|
|
|
- name: FELIX_TYPHACAFILE
|
|
|
|
value: /etc/typha-ca/ca.crt
|
|
|
|
- name: FELIX_TYPHACERTFILE
|
|
|
|
value: /etc/typha-client/typha-client.crt
|
|
|
|
- name: FELIX_TYPHAKEYFILE
|
|
|
|
value: /etc/typha-client/typha-client.key
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2019-04-25 20:00:48 +08:00
|
|
|
# Wait for the datastore.
|
|
|
|
- name: WAIT_FOR_DATASTORE
|
|
|
|
value: "true"
|
2020-09-22 16:04:48 +08:00
|
|
|
{% endif %}
|
|
|
|
{% if calico_network_backend is defined and calico_network_backend == 'vxlan' %}
|
|
|
|
- name: FELIX_VXLANVNI
|
|
|
|
value: "{{ calico_vxlan_vni }}"
|
|
|
|
- name: FELIX_VXLANPORT
|
|
|
|
value: "{{ calico_vxlan_port }}"
|
2019-04-25 20:00:48 +08:00
|
|
|
{% endif %}
|
2017-09-04 16:29:51 +08:00
|
|
|
# Choose the backend to use.
|
|
|
|
- name: CALICO_NETWORKING_BACKEND
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: calico_backend
|
|
|
|
# Cluster type to identify the deployment type
|
|
|
|
- name: CLUSTER_TYPE
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: calico-config
|
|
|
|
key: cluster_type
|
2018-02-06 03:34:59 +08:00
|
|
|
# Set noderef for node controller.
|
|
|
|
- name: CALICO_K8S_NODE_REF
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: spec.nodeName
|
2017-09-04 16:29:51 +08:00
|
|
|
# Disable file logging so `kubectl logs` works.
|
|
|
|
- name: CALICO_DISABLE_FILE_LOGGING
|
|
|
|
value: "true"
|
|
|
|
# Set Felix endpoint to host default action to ACCEPT.
|
|
|
|
- name: FELIX_DEFAULTENDPOINTTOHOSTACTION
|
|
|
|
value: "{{ calico_endpoint_to_host_action|default('RETURN') }}"
|
2018-09-18 20:48:29 +08:00
|
|
|
- name: FELIX_HEALTHHOST
|
|
|
|
value: "{{ calico_healthhost }}"
|
2019-02-05 04:42:40 +08:00
|
|
|
{% if kube_proxy_mode == 'ipvs' and kube_apiserver_node_port_range is defined %}
|
|
|
|
- name: FELIX_KUBENODEPORTRANGES
|
|
|
|
value: "{{ kube_apiserver_node_port_range.split('-')[0] }}:{{ kube_apiserver_node_port_range.split('-')[1] }}"
|
2020-01-08 18:27:40 +08:00
|
|
|
{% endif %}
|
|
|
|
- name: FELIX_IPTABLESBACKEND
|
|
|
|
value: "{{ calico_iptables_backend }}"
|
2019-01-05 00:00:56 +08:00
|
|
|
- name: FELIX_IPTABLESLOCKTIMEOUTSECS
|
2020-02-19 18:28:25 +08:00
|
|
|
value: "{{ calico_iptables_lock_timeout_secs }}"
|
2017-09-04 16:29:51 +08:00
|
|
|
# should be set in etcd before deployment
|
|
|
|
# # Configure the IP Pool from which Pod IPs will be chosen.
|
|
|
|
# - name: CALICO_IPV4POOL_CIDR
|
2019-07-08 17:20:03 +08:00
|
|
|
# value: "{{ calico_pool_cidr | default(kube_pods_subnet) }}"
|
2020-06-30 05:39:58 +08:00
|
|
|
{% if calico_veth_mtu is defined %}
|
|
|
|
# Set MTU for the Wireguard tunnel device.
|
|
|
|
- name: FELIX_WIREGUARDMTU
|
|
|
|
value: "{{ calico_veth_mtu }}"
|
|
|
|
{% endif %}
|
2018-10-12 15:09:36 +08:00
|
|
|
- name: CALICO_IPV4POOL_IPIP
|
|
|
|
value: "{{ calico_ipv4pool_ipip }}"
|
2017-09-04 16:29:51 +08:00
|
|
|
# Disable IPv6 on Kubernetes.
|
|
|
|
- name: FELIX_IPV6SUPPORT
|
|
|
|
value: "false"
|
|
|
|
# Set Felix logging to "info"
|
|
|
|
- name: FELIX_LOGSEVERITYSCREEN
|
2018-11-28 16:55:01 +08:00
|
|
|
value: "{{ calico_loglevel }}"
|
2020-04-27 15:03:30 +08:00
|
|
|
# Enable or disable usage report
|
|
|
|
- name: FELIX_USAGEREPORTINGENABLED
|
|
|
|
value: "{{ calico_usage_reporting }}"
|
2017-09-04 16:29:51 +08:00
|
|
|
# Set MTU for tunnel device used if ipip is enabled
|
|
|
|
{% if calico_mtu is defined %}
|
|
|
|
- name: FELIX_IPINIPMTU
|
2020-07-22 14:58:18 +08:00
|
|
|
value: "{{ calico_veth_mtu | default(calico_mtu) }}"
|
2017-09-04 16:29:51 +08:00
|
|
|
{% endif %}
|
2020-03-14 21:36:35 +08:00
|
|
|
- name: FELIX_CHAININSERTMODE
|
|
|
|
value: "{{ calico_felix_chaininsertmode }}"
|
2017-10-04 05:24:05 +08:00
|
|
|
- name: FELIX_PROMETHEUSMETRICSENABLED
|
|
|
|
value: "{{ calico_felix_prometheusmetricsenabled }}"
|
|
|
|
- name: FELIX_PROMETHEUSMETRICSPORT
|
|
|
|
value: "{{ calico_felix_prometheusmetricsport }}"
|
|
|
|
- name: FELIX_PROMETHEUSGOMETRICSENABLED
|
|
|
|
value: "{{ calico_felix_prometheusgometricsenabled }}"
|
|
|
|
- name: FELIX_PROMETHEUSPROCESSMETRICSENABLED
|
|
|
|
value: "{{ calico_felix_prometheusprocessmetricsenabled }}"
|
2018-03-23 21:33:20 +08:00
|
|
|
{% if calico_ip_auto_method is defined %}
|
2018-03-24 06:46:26 +08:00
|
|
|
- name: IP_AUTODETECTION_METHOD
|
|
|
|
value: "{{ calico_ip_auto_method }}"
|
2019-01-28 15:09:18 +08:00
|
|
|
- name: IP
|
|
|
|
value: "autodetect"
|
2018-03-23 21:33:20 +08:00
|
|
|
{% else %}
|
2020-12-21 16:58:25 +08:00
|
|
|
- name: NODEIP
|
2017-09-04 16:29:51 +08:00
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: status.hostIP
|
2020-12-21 16:58:25 +08:00
|
|
|
- name: IP_AUTODETECTION_METHOD
|
|
|
|
value: "can-reach=$(NODEIP)"
|
|
|
|
- name: IP
|
|
|
|
value: "autodetect"
|
2020-08-27 17:07:01 +08:00
|
|
|
{% endif %}
|
2020-09-25 00:04:06 +08:00
|
|
|
{% if calico_use_default_route_src_ipaddr|default(false) %}
|
2020-08-27 17:07:01 +08:00
|
|
|
- name: FELIX_DEVICEROUTESOURCEADDRESS
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: status.hostIP
|
2018-03-23 21:33:20 +08:00
|
|
|
{% endif %}
|
2017-09-04 16:29:51 +08:00
|
|
|
- name: NODENAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
- name: FELIX_HEALTHENABLED
|
|
|
|
value: "true"
|
2017-11-13 17:35:13 +08:00
|
|
|
- name: FELIX_IGNORELOOSERPF
|
|
|
|
value: "{{ calico_node_ignorelooserpf }}"
|
2020-07-22 15:08:04 +08:00
|
|
|
{% if calico_node_extra_envs is defined %}
|
|
|
|
{% for key in calico_node_extra_envs %}
|
|
|
|
- name: {{ key }}
|
|
|
|
value: "{{ calico_node_extra_envs[key] }}"
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2017-09-04 16:29:51 +08:00
|
|
|
securityContext:
|
|
|
|
privileged: true
|
|
|
|
resources:
|
|
|
|
limits:
|
|
|
|
cpu: {{ calico_node_cpu_limit }}
|
|
|
|
memory: {{ calico_node_memory_limit }}
|
|
|
|
requests:
|
|
|
|
cpu: {{ calico_node_cpu_requests }}
|
|
|
|
memory: {{ calico_node_memory_requests }}
|
|
|
|
livenessProbe:
|
2020-01-08 18:27:40 +08:00
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- /bin/calico-node
|
|
|
|
- -felix-live
|
2020-06-02 03:44:14 +08:00
|
|
|
{% if calico_network_backend|default("bird") == "bird" %}
|
2020-01-08 18:27:40 +08:00
|
|
|
- -bird-live
|
|
|
|
{% endif %}
|
2019-04-24 05:46:02 +08:00
|
|
|
initialDelaySeconds: 5
|
2017-09-04 16:29:51 +08:00
|
|
|
failureThreshold: 6
|
|
|
|
readinessProbe:
|
2019-04-24 05:46:02 +08:00
|
|
|
failureThreshold: 6
|
2019-01-29 03:03:49 +08:00
|
|
|
exec:
|
|
|
|
command:
|
|
|
|
- /bin/calico-node
|
2020-06-02 03:44:14 +08:00
|
|
|
{% if calico_network_backend|default("bird") == "bird" %}
|
2019-01-29 03:03:49 +08:00
|
|
|
- -bird-ready
|
2020-06-02 03:44:14 +08:00
|
|
|
{% endif %}
|
2019-01-29 03:03:49 +08:00
|
|
|
- -felix-ready
|
2017-09-04 16:29:51 +08:00
|
|
|
volumeMounts:
|
|
|
|
- mountPath: /lib/modules
|
|
|
|
name: lib-modules
|
|
|
|
readOnly: true
|
|
|
|
- mountPath: /var/run/calico
|
|
|
|
name: var-run-calico
|
2018-08-23 22:17:18 +08:00
|
|
|
- mountPath: /var/lib/calico
|
|
|
|
name: var-lib-calico
|
2017-09-04 16:29:51 +08:00
|
|
|
readOnly: false
|
2019-04-25 20:00:48 +08:00
|
|
|
{% if calico_datastore == "etcd" %}
|
2017-09-04 16:29:51 +08:00
|
|
|
- mountPath: /calico-secrets
|
|
|
|
name: etcd-certs
|
2019-04-25 20:00:48 +08:00
|
|
|
{% endif %}
|
2019-01-05 00:00:56 +08:00
|
|
|
- name: xtables-lock
|
|
|
|
mountPath: /run/xtables.lock
|
|
|
|
readOnly: false
|
2019-10-17 22:02:38 +08:00
|
|
|
{% if typha_secure %}
|
|
|
|
- name: typha-client
|
|
|
|
mountPath: /etc/typha-client
|
|
|
|
readOnly: true
|
|
|
|
- name: typha-cacert
|
|
|
|
subPath: ca.crt
|
|
|
|
mountPath: /etc/typha-ca/ca.crt
|
|
|
|
readOnly: true
|
|
|
|
{% endif %}
|
|
|
|
|
2017-09-04 16:29:51 +08:00
|
|
|
volumes:
|
|
|
|
# Used by calico/node.
|
|
|
|
- name: lib-modules
|
|
|
|
hostPath:
|
|
|
|
path: /lib/modules
|
|
|
|
- name: var-run-calico
|
|
|
|
hostPath:
|
|
|
|
path: /var/run/calico
|
2018-08-23 22:17:18 +08:00
|
|
|
- name: var-lib-calico
|
|
|
|
hostPath:
|
|
|
|
path: /var/lib/calico
|
2017-09-04 16:29:51 +08:00
|
|
|
# Used to install CNI.
|
|
|
|
- name: cni-net-dir
|
|
|
|
hostPath:
|
|
|
|
path: /etc/cni/net.d
|
2019-04-02 18:32:36 +08:00
|
|
|
- name: cni-bin-dir
|
|
|
|
hostPath:
|
|
|
|
path: /opt/cni/bin
|
2019-04-25 20:00:48 +08:00
|
|
|
{% if calico_datastore == "etcd" %}
|
2017-09-04 16:29:51 +08:00
|
|
|
# Mount in the etcd TLS secrets.
|
|
|
|
- name: etcd-certs
|
|
|
|
hostPath:
|
|
|
|
path: "{{ calico_cert_dir }}"
|
2019-04-25 20:00:48 +08:00
|
|
|
{% endif %}
|
2019-01-05 00:00:56 +08:00
|
|
|
# Mount the global iptables lock file, used by calico/node
|
|
|
|
- name: xtables-lock
|
|
|
|
hostPath:
|
|
|
|
path: /run/xtables.lock
|
|
|
|
type: FileOrCreate
|
2020-09-25 00:04:06 +08:00
|
|
|
{% if calico_datastore == "kdd" %}
|
2019-07-10 03:42:28 +08:00
|
|
|
# Mount in the directory for host-local IPAM allocations. This is
|
|
|
|
# used when upgrading from host-local to calico-ipam, and can be removed
|
|
|
|
# if not using the upgrade-ipam init container.
|
|
|
|
- name: host-local-net-dir
|
|
|
|
hostPath:
|
|
|
|
path: /var/lib/cni/networks
|
2019-10-17 22:02:38 +08:00
|
|
|
{% endif %}
|
|
|
|
{% if typha_enabled and typha_secure %}
|
|
|
|
- name: typha-client
|
|
|
|
secret:
|
|
|
|
secretName: typha-client
|
|
|
|
items:
|
2020-06-30 03:39:59 +08:00
|
|
|
- key: tls.crt
|
|
|
|
path: typha-client.crt
|
|
|
|
- key: tls.key
|
|
|
|
path: typha-client.key
|
2019-10-17 22:02:38 +08:00
|
|
|
- name: typha-cacert
|
|
|
|
hostPath:
|
|
|
|
path: "/etc/kubernetes/ssl/"
|
2019-07-10 03:42:28 +08:00
|
|
|
{% endif %}
|
2017-09-04 16:29:51 +08:00
|
|
|
updateStrategy:
|
|
|
|
rollingUpdate:
|
2017-09-15 20:19:37 +08:00
|
|
|
maxUnavailable: {{ serial | default('20%') }}
|
2018-09-27 20:28:54 +08:00
|
|
|
type: RollingUpdate
|