Skip to content

Commit

Permalink
fix: add resources limits to avoid eviction
Browse files Browse the repository at this point in the history
(cherry picked from commit a9747b3)
  • Loading branch information
oilbeater committed Nov 30, 2020
1 parent 762f1c2 commit 21a5edb
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 49 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ kind-init:
kind delete cluster --name=kube-ovn
ip_family=ipv4 ha=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl get no -o wide
kubectl describe no
docker exec kube-ovn-control-plane ip link add link eth0 mac1 type macvlan
docker exec kube-ovn-worker ip link add link eth0 mac1 type macvlan

kind-install:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
ENABLE_SSL=true dist/images/install.sh
kubectl get no -o wide
kubectl describe no

kind-init-ha:
kind delete cluster --name=kube-ovn
ip_family=ipv4 ha=true j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl get no -o wide
kubectl describe no

kind-init-ipv6:
kind delete cluster --name=kube-ovn
ip_family=ipv6 ha=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl get no -o wide
kubectl describe no

kind-install-ipv6:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
Expand Down
113 changes: 78 additions & 35 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ IFACE="" # The nic to support container network, i
REGISTRY="kubeovn"
VERSION="v1.5.1"
IMAGE_PULL_POLICY="IfNotPresent"
NAMESPACE="kube-system" # The ns to deploy kube-ovn
POD_CIDR="10.16.0.0/16" # Do NOT overlap with NODE/SVC/JOIN CIDR
SVC_CIDR="10.96.0.0/12" # Do NOT overlap with NODE/POD/JOIN CIDR
JOIN_CIDR="100.64.0.0/16" # Do NOT overlap with NODE/POD/SVC CIDR
Expand Down Expand Up @@ -39,12 +38,16 @@ VLAN_RANGE="1,4095"
DPDK="false"
DPDK_SUPPORTED_VERSIONS=("19.11")
DPDK_VERSION=""
DPDK_CPU="1000m" # Default CPU configuration for if --dpdk-cpu flag is not included
DPDK_MEMORY="2Gi" # Default Memory configuration for it --dpdk-memory flag is not included

display_help() {
echo "Usage: $0 [option...]"
echo
echo " -h, --help Print Help (this message) and exit"
echo " --with-dpdk=<version> Install Kube-OVN with OVS-DPDK instead of kernel OVS"
echo " --dpdk-cpu=<amount>m Configure DPDK to use a specific amount of CPU"
echo " --dpdk-memory=<amount>Gi Configure DPDK to use a specific amount of memory"
echo
exit 0
}
Expand All @@ -66,6 +69,26 @@ then
exit 1
fi
;;
--dpdk-cpu=*)
DPDK_CPU="${1#*=}"
if [[ $DPDK_CPU =~ ^[0-9]+(m)$ ]]
then
echo "CPU $DPDK_CPU"
else
echo "$DPDK_CPU is not valid, please use the format --dpdk-cpu=<amount>m"
exit 1
fi
;;
--dpdk-memory=*)
DPDK_MEMORY="${1#*=}"
if [[ $DPDK_MEMORY =~ ^[0-9]+(Gi)$ ]]
then
echo "MEMORY $DPDK_MEMORY"
else
echo "$DPDK_MEMORY is not valid, please use the format --dpdk-memory=<amount>Gi"
exit 1
fi
;;
-?*)
echo "Unknown argument $1"
exit 1
Expand Down Expand Up @@ -357,14 +380,14 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: ovn-config
namespace: ${NAMESPACE}
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ovn
namespace: ${NAMESPACE}
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -439,14 +462,14 @@ roleRef:
subjects:
- kind: ServiceAccount
name: ovn
namespace: ${NAMESPACE}
namespace: kube-system
---
kind: Service
apiVersion: v1
metadata:
name: ovn-nb
namespace: ${NAMESPACE}
namespace: kube-system
spec:
ports:
- name: ovn-nb
Expand All @@ -464,7 +487,7 @@ kind: Service
apiVersion: v1
metadata:
name: ovn-sb
namespace: ${NAMESPACE}
namespace: kube-system
spec:
ports:
- name: ovn-sb
Expand All @@ -482,7 +505,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: ovn-central
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
OVN components: northd, nb and sb.
Expand Down Expand Up @@ -542,8 +565,11 @@ spec:
fieldPath: metadata.namespace
resources:
requests:
cpu: 500m
cpu: 300m
memory: 300Mi
limits:
cpu: 3
memory: 3Gi
volumeMounts:
- mountPath: /var/run/openvswitch
name: host-run-ovs
Expand Down Expand Up @@ -613,7 +639,7 @@ kind: DaemonSet
apiVersion: apps/v1
metadata:
name: ovs-ovn
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
This daemon set launches the openvswitch daemon.
Expand Down Expand Up @@ -698,11 +724,11 @@ spec:
timeoutSeconds: 45
resources:
requests:
cpu: 500m
memory: 2Gi
cpu: $DPDK_CPU
memory: $DPDK_MEMORY
limits:
cpu: 1000m
memory: 2Gi
cpu: $DPDK_CPU
memory: $DPDK_MEMORY
hugepages-1Gi: 1Gi
nodeSelector:
kubernetes.io/os: "linux"
Expand Down Expand Up @@ -780,13 +806,13 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: ovn-config
namespace: ${NAMESPACE}
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ovn
namespace: ${NAMESPACE}
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -860,13 +886,13 @@ roleRef:
subjects:
- kind: ServiceAccount
name: ovn
namespace: ${NAMESPACE}
namespace: kube-system
---
kind: Service
apiVersion: v1
metadata:
name: ovn-nb
namespace: ${NAMESPACE}
namespace: kube-system
spec:
ports:
- name: ovn-nb
Expand All @@ -883,7 +909,7 @@ kind: Service
apiVersion: v1
metadata:
name: ovn-sb
namespace: ${NAMESPACE}
namespace: kube-system
spec:
ports:
- name: ovn-sb
Expand All @@ -900,7 +926,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: ovn-central
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
OVN components: northd, nb and sb.
Expand Down Expand Up @@ -960,8 +986,11 @@ spec:
fieldPath: metadata.namespace
resources:
requests:
cpu: 500m
memory: 300Mi
cpu: 300m
memory: 200Mi
limits:
cpu: 3
memory: 3Gi
volumeMounts:
- mountPath: /var/run/openvswitch
name: host-run-ovs
Expand Down Expand Up @@ -1030,7 +1059,7 @@ kind: DaemonSet
apiVersion: apps/v1
metadata:
name: ovs-ovn
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
This daemon set launches the openvswitch daemon.
Expand Down Expand Up @@ -1114,7 +1143,7 @@ spec:
resources:
requests:
cpu: 200m
memory: 300Mi
memory: 200Mi
limits:
cpu: 1000m
memory: 800Mi
Expand Down Expand Up @@ -1154,7 +1183,7 @@ fi

kubectl apply -f kube-ovn-crd.yaml
kubectl apply -f ovn.yaml
kubectl rollout status deployment/ovn-central -n ${NAMESPACE}
kubectl rollout status deployment/ovn-central -n kube-system
echo "-------------------------------"
echo ""

Expand All @@ -1166,7 +1195,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: kube-ovn-controller
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
kube-ovn controller
Expand Down Expand Up @@ -1246,6 +1275,13 @@ spec:
periodSeconds: 7
failureThreshold: 5
timeoutSeconds: 45
resources:
requests:
cpu: 200m
memory: 200Mi
limits:
cpu: 1000m
memory: 1Gi
nodeSelector:
kubernetes.io/os: "linux"
volumes:
Expand All @@ -1259,7 +1295,7 @@ kind: DaemonSet
apiVersion: apps/v1
metadata:
name: kube-ovn-cni
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
This daemon set launches the kube-ovn cni daemon.
Expand Down Expand Up @@ -1349,6 +1385,13 @@ spec:
initialDelaySeconds: 30
periodSeconds: 7
failureThreshold: 5
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 1000m
memory: 1Gi
nodeSelector:
kubernetes.io/os: "linux"
volumes:
Expand All @@ -1373,7 +1416,7 @@ kind: DaemonSet
apiVersion: apps/v1
metadata:
name: kube-ovn-pinger
namespace: ${NAMESPACE}
namespace: kube-system
annotations:
kubernetes.io/description: |
This daemon set launches the openvswitch daemon.
Expand Down Expand Up @@ -1445,7 +1488,7 @@ spec:
resources:
requests:
cpu: 100m
memory: 300Mi
memory: 100Mi
limits:
cpu: 200m
memory: 400Mi
Expand Down Expand Up @@ -1482,7 +1525,7 @@ kind: Service
apiVersion: v1
metadata:
name: kube-ovn-pinger
namespace: ${NAMESPACE}
namespace: kube-system
labels:
app: kube-ovn-pinger
spec:
Expand All @@ -1496,7 +1539,7 @@ kind: Service
apiVersion: v1
metadata:
name: kube-ovn-controller
namespace: ${NAMESPACE}
namespace: kube-system
labels:
app: kube-ovn-controller
spec:
Expand All @@ -1510,7 +1553,7 @@ kind: Service
apiVersion: v1
metadata:
name: kube-ovn-cni
namespace: ${NAMESPACE}
namespace: kube-system
labels:
app: kube-ovn-cni
spec:
Expand All @@ -1522,19 +1565,19 @@ spec:
EOF

kubectl apply -f kube-ovn.yaml
kubectl rollout status deployment/kube-ovn-controller -n ${NAMESPACE}
kubectl rollout status daemonset/kube-ovn-cni -n ${NAMESPACE}
kubectl rollout status deployment/kube-ovn-controller -n kube-system
kubectl rollout status daemonset/kube-ovn-cni -n kube-system
echo "-------------------------------"
echo ""

echo "[Step 4] Delete pod that not in host network mode"
for ns in $(kubectl get ns --no-headers -o custom-columns=NAME:.metadata.name); do
for pod in $(kubectl get pod --no-headers -n "$ns" --field-selector spec.restartPolicy=Always -o custom-columns=NAME:.metadata.name,HOST:spec.hostNetwork | awk '{if ($2!="true") print $1}'); do
kubectl delete pod "$pod" -n "$ns"
kubectl delete pod "$pod" -n "$ns" --ignore-not-found
done
done

kubectl rollout status daemonset/kube-ovn-pinger -n ${NAMESPACE}
kubectl rollout status daemonset/kube-ovn-pinger -n kube-system
kubectl rollout status deployment/coredns -n kube-system
echo "-------------------------------"
echo ""
Expand Down
Loading

0 comments on commit 21a5edb

Please sign in to comment.