mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Change how Typha CPU / replias are determined.
This commit is contained in:
parent
83ec0d87ff
commit
948c6c8027
@ -6,7 +6,6 @@ Calico is an implementation of the Kubernetes network policy API. The provided
|
|||||||
- A DaemonSet which runs Calico on each node in the cluster.
|
- A DaemonSet which runs Calico on each node in the cluster.
|
||||||
- A Deployment which installs the Calico Typha agent.
|
- A Deployment which installs the Calico Typha agent.
|
||||||
- A Service for the Calico Typha agent.
|
- A Service for the Calico Typha agent.
|
||||||
- A HorizontalPodAutoscaler to dynamically adjust the Typha Deployment.
|
|
||||||
|
|
||||||
### Learn More
|
### Learn More
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ spec:
|
|||||||
# container programs network policy and routes on each
|
# container programs network policy and routes on each
|
||||||
# host.
|
# host.
|
||||||
- name: calico-node
|
- name: calico-node
|
||||||
image: calico/node:v1.3.0-rc1
|
image: calico/node:v1.3.0
|
||||||
env:
|
env:
|
||||||
- name: CALICO_DISABLE_FILE_LOGGING
|
- name: CALICO_DISABLE_FILE_LOGGING
|
||||||
value: "true"
|
value: "true"
|
||||||
@ -128,7 +128,7 @@ spec:
|
|||||||
# Used to install CNI binaries.
|
# Used to install CNI binaries.
|
||||||
- name: cni-bin-dir
|
- name: cni-bin-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /home/kubernetes/bin
|
path: __CALICO_CNI_DIR__
|
||||||
# Used to install CNI network config.
|
# Used to install CNI network config.
|
||||||
- name: cni-net-dir
|
- name: cni-net-dir
|
||||||
hostPath:
|
hostPath:
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
apiVersion: autoscaling/v1
|
|
||||||
kind: HorizontalPodAutoscaler
|
|
||||||
metadata:
|
|
||||||
name: calico-typha
|
|
||||||
namespace: kube-system
|
|
||||||
labels:
|
|
||||||
kubernetes.io/cluster-service: "true"
|
|
||||||
addonmanager.kubernetes.io/mode: Reconcile
|
|
||||||
k8s-app: calico-typha
|
|
||||||
spec:
|
|
||||||
scaleTargetRef:
|
|
||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
name: calico-typha
|
|
||||||
minReplicas: 1
|
|
||||||
maxReplicas: 20
|
|
||||||
targetCPUUtilizationPercentage: 75
|
|
@ -1,5 +1,5 @@
|
|||||||
kind: Deployment
|
|
||||||
apiVersion: extensions/v1beta1
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: calico-typha
|
name: calico-typha
|
||||||
namespace: kube-system
|
namespace: kube-system
|
||||||
@ -8,7 +8,7 @@ metadata:
|
|||||||
addonmanager.kubernetes.io/mode: Reconcile
|
addonmanager.kubernetes.io/mode: Reconcile
|
||||||
k8s-app: calico-typha
|
k8s-app: calico-typha
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: __CALICO_TYPHA_REPLICAS__
|
||||||
revisionHistoryLimit: 2
|
revisionHistoryLimit: 2
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
@ -24,7 +24,7 @@ spec:
|
|||||||
projectcalico.org/ds-ready: "true"
|
projectcalico.org/ds-ready: "true"
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
containers:
|
containers:
|
||||||
- image: calico/typha:v0.1.7
|
- image: calico/typha:v0.2.2
|
||||||
name: calico-typha
|
name: calico-typha
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5473
|
- containerPort: 5473
|
||||||
@ -39,10 +39,22 @@ spec:
|
|||||||
value: "info"
|
value: "info"
|
||||||
- name: TYPHA_PROMETHEUSMETRICSENABLED
|
- name: TYPHA_PROMETHEUSMETRICSENABLED
|
||||||
value: "true"
|
value: "true"
|
||||||
|
- name: TYPHA_CONNECTIONREBALANCINGMODE
|
||||||
|
value: "kubernetes"
|
||||||
- name: TYPHA_PROMETHEUSMETRICSPORT
|
- name: TYPHA_PROMETHEUSMETRICSPORT
|
||||||
value: "9093"
|
value: "9093"
|
||||||
- name: TYPHA_DATASTORETYPE
|
- name: TYPHA_DATASTORETYPE
|
||||||
value: "kubernetes"
|
value: "kubernetes"
|
||||||
|
- name: TYPHA_MAXCONNECTIONSLOWERLIMIT
|
||||||
|
value: "1"
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /etc/calico
|
||||||
|
name: etc-calico
|
||||||
|
readOnly: true
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 200m
|
cpu: __CALICO_TYPHA_CPU__
|
||||||
|
volumes:
|
||||||
|
- name: etc-calico
|
||||||
|
hostPath:
|
||||||
|
path: /etc/calico
|
||||||
|
@ -36,7 +36,7 @@ function create-dirs {
|
|||||||
|
|
||||||
# Vars assumed:
|
# Vars assumed:
|
||||||
# NUM_NODES
|
# NUM_NODES
|
||||||
function get-calico-cpu {
|
function get-calico-node-cpu {
|
||||||
local suggested_calico_cpus=100m
|
local suggested_calico_cpus=100m
|
||||||
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
suggested_calico_cpus=250m
|
suggested_calico_cpus=250m
|
||||||
@ -50,6 +50,38 @@ function get-calico-cpu {
|
|||||||
echo "${suggested_calico_cpus}"
|
echo "${suggested_calico_cpus}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Vars assumed:
|
||||||
|
# NUM_NODES
|
||||||
|
function get-calico-typha-replicas {
|
||||||
|
local typha_count=1
|
||||||
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
|
typha_count=2
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "100" ]]; then
|
||||||
|
typha_count=3
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "250" ]]; then
|
||||||
|
typha_count=4
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "500" ]]; then
|
||||||
|
typha_count=5
|
||||||
|
fi
|
||||||
|
echo "${typha_count}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vars assumed:
|
||||||
|
# NUM_NODES
|
||||||
|
function get-calico-typha-cpu {
|
||||||
|
local typha_cpu=200m
|
||||||
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
|
typha_cpu=500m
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "100" ]]; then
|
||||||
|
typha_cpu=1000m
|
||||||
|
fi
|
||||||
|
echo "${typha_cpu}"
|
||||||
|
}
|
||||||
|
|
||||||
# Create directories referenced in the kube-controller-manager manifest for
|
# Create directories referenced in the kube-controller-manager manifest for
|
||||||
# bindmounts. This is used under the rkt runtime to work around
|
# bindmounts. This is used under the rkt runtime to work around
|
||||||
# https://github.com/kubernetes/kubernetes/issues/26816
|
# https://github.com/kubernetes/kubernetes/issues/26816
|
||||||
@ -1229,9 +1261,13 @@ function start-kube-addons {
|
|||||||
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" ]]; then
|
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" ]]; then
|
||||||
setup-addon-manifests "addons" "calico-policy-controller"
|
setup-addon-manifests "addons" "calico-policy-controller"
|
||||||
|
|
||||||
# Configure Calico resource requests based on cluster size.
|
# Configure Calico based on cluster size and image type.
|
||||||
local -r calico_file="${dst_dir}/calico-policy-controller/calico-node-daemonset.yaml"
|
local -r ds_file="${dst_dir}/calico-policy-controller/calico-node-daemonset.yaml"
|
||||||
sed -i -e "s@__CALICO_NODE_CPU__@$(get-calico-cpu)@g" "${calico_file}"
|
local -r typha_dep_file="${dst_dir}/calico-policy-controller/typha-deployment.yaml"
|
||||||
|
sed -i -e "s@__CALICO_CNI_DIR__@/opt/cni/bin@g" "${ds_file}"
|
||||||
|
sed -i -e "s@__CALICO_NODE_CPU__@$(get-calico-node-cpu)@g" "${ds_file}"
|
||||||
|
sed -i -e "s@__CALICO_TYPHA_CPU__@$(get-calico-typha-cpu)@g" "${typha_dep_file}"
|
||||||
|
sed -i -e "s@__CALICO_TYPHA_REPLICAS__@$(get-calico-typha-replicas)@g" "${typha_dep_file}"
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_DEFAULT_STORAGE_CLASS:-}" == "true" ]]; then
|
if [[ "${ENABLE_DEFAULT_STORAGE_CLASS:-}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "storage-class/gce"
|
setup-addon-manifests "addons" "storage-class/gce"
|
||||||
|
@ -34,7 +34,7 @@ function setup-os-params {
|
|||||||
|
|
||||||
# Vars assumed:
|
# Vars assumed:
|
||||||
# NUM_NODES
|
# NUM_NODES
|
||||||
function get-calico-cpu {
|
function get-calico-node-cpu {
|
||||||
local suggested_calico_cpus=100m
|
local suggested_calico_cpus=100m
|
||||||
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
suggested_calico_cpus=250m
|
suggested_calico_cpus=250m
|
||||||
@ -48,6 +48,39 @@ function get-calico-cpu {
|
|||||||
echo "${suggested_calico_cpus}"
|
echo "${suggested_calico_cpus}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Vars assumed:
|
||||||
|
# NUM_NODES
|
||||||
|
function get-calico-typha-replicas {
|
||||||
|
local typha_count=1
|
||||||
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
|
typha_count=2
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "100" ]]; then
|
||||||
|
typha_count=3
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "250" ]]; then
|
||||||
|
typha_count=4
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "500" ]]; then
|
||||||
|
typha_count=5
|
||||||
|
fi
|
||||||
|
echo "${typha_count}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vars assumed:
|
||||||
|
# NUM_NODES
|
||||||
|
function get-calico-typha-cpu {
|
||||||
|
local typha_cpu=200m
|
||||||
|
if [[ "${NUM_NODES}" -gt "10" ]]; then
|
||||||
|
typha_cpu=500m
|
||||||
|
fi
|
||||||
|
if [[ "${NUM_NODES}" -gt "100" ]]; then
|
||||||
|
typha_cpu=1000m
|
||||||
|
fi
|
||||||
|
echo "${typha_cpu}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function config-ip-firewall {
|
function config-ip-firewall {
|
||||||
echo "Configuring IP firewall rules"
|
echo "Configuring IP firewall rules"
|
||||||
# The GCI image has host firewall which drop most inbound/forwarded packets.
|
# The GCI image has host firewall which drop most inbound/forwarded packets.
|
||||||
@ -1627,9 +1660,13 @@ function start-kube-addons {
|
|||||||
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" ]]; then
|
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" ]]; then
|
||||||
setup-addon-manifests "addons" "calico-policy-controller"
|
setup-addon-manifests "addons" "calico-policy-controller"
|
||||||
|
|
||||||
# Configure Calico resource requests based on cluster size.
|
# Configure Calico based on cluster size and image type.
|
||||||
local -r calico_file="${dst_dir}/calico-policy-controller/calico-node-daemonset.yaml"
|
local -r ds_file="${dst_dir}/calico-policy-controller/calico-node-daemonset.yaml"
|
||||||
sed -i -e "s@__CALICO_NODE_CPU__@$(get-calico-cpu)@g" "${calico_file}"
|
local -r typha_dep_file="${dst_dir}/calico-policy-controller/typha-deployment.yaml"
|
||||||
|
sed -i -e "s@__CALICO_CNI_DIR__@/home/kubernetes/bin@g" "${ds_file}"
|
||||||
|
sed -i -e "s@__CALICO_NODE_CPU__@$(get-calico-node-cpu)@g" "${ds_file}"
|
||||||
|
sed -i -e "s@__CALICO_TYPHA_CPU__@$(get-calico-typha-cpu)@g" "${typha_dep_file}"
|
||||||
|
sed -i -e "s@__CALICO_TYPHA_REPLICAS__@$(get-calico-typha-replicas)@g" "${typha_dep_file}"
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_DEFAULT_STORAGE_CLASS:-}" == "true" ]]; then
|
if [[ "${ENABLE_DEFAULT_STORAGE_CLASS:-}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "storage-class/gce"
|
setup-addon-manifests "addons" "storage-class/gce"
|
||||||
|
Loading…
Reference in New Issue
Block a user