[cloud native | kubernetes] self built high availability k8s cluster optimization

Lansonli 2022-06-24 07:51:38 阅读数:174

cloudnativekubernetesselfbuilt

Surprise at the end of the article  

List of articles

Self built high availability k8s Cluster optimization

One 、Docker Configuration optimization

Two 、 Optimize kubelet

3、 ... and 、 Time zone problem


Self built high availability k8s Cluster optimization

One 、Docker Configuration optimization

# All nodes execute
// max-concurrent-downloads: Maximum concurrent Downloads
// "max-concurrent-uploads": Maximum concurrent upload
// log-opts: Log Settings , Single file is the largest , The largest number of files
// The container logs are all in /var/lib/docker/containers/ Container name /xxx.log
// "live-restore": Shutdown and keep alive
vi /etc/docker/daemon.json
{
"registry-mirrors": [
"https://82m6ar63.mirror.aliyuncs.com"
],
"exec-opts": ["native.cgroupdriver=systemd"],
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"log-opts": {
"max-size": "300m",
"max-file": "2"
},
"live-restore": true
}
systemctl daemon-reload && systemctl restart docker

Two 、 Optimize kubelet

Refer to the official documentation : Kubelet To configure (v1beta1) | Kubernetes

vi /etc/kubernetes/kubelet-conf.yml
# kubeReserved: kubelet Reserve resources
kubeReserved:
cpu: "500m"
memory: 300m
ephemeral-storage: 3Gi
systemReserved:
cpu: "200m"
memory: 500m
ephemeral-storage: 3Gi

Verification cluster kube-proxy Use ipvs Mode works ; 10249 Each node kube-proxy Of metrics Information port , You can visit /proxyMode perhaps /metrics etc.

curl 127.0.0.1:10249/proxyMode

3、 ... and 、 Time zone problem

Many applications mirror time zones UTC, Not local time ( Of course , The premise is that the local time is correct , The ECS does not have this problem )

We don't need every one Pod Set the local time for mounting

apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-localtime
namespace: spinnaker
spec:
selector:
matchLabels:
volumeMounts:
- mountPath: /etc/localtime
name: localtime
volumes:
- name: localtime
hostPath:
path: etc/localtime
kubectl apply -f xxx.yaml

docker hub Download almost all of them Pod All are UTC Time .

java -- Pod -- UTC

This requires feature gating

vi /usr/lib/systemd/system/kube-apiserver.service
# 1、 add to --runtime-config=settings.k8s.io/v1alpha1=true
# 2、 add to --enable-admission-plugins Add PodPreset
systemctl daemon-reload && systemctl restart kube-apiserver

Unfortunately, this feature is used in 1.20 It's abandoned later .

PodPreset(Pod Preset ) From the v1.11 The version began to appear , But again v1.20 Version cancelled .

So later , Use Pod Standard template . Mount time zone

 volumeMounts:
- name: localtime
mountPath: /etc/localtime
volumes:
- name: localtime
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai

  Surprise at the end of the article  

Develop cloud special offers

【 Developing the cloud 】 It's a discount every year , You don't have to go around collecting sheep


  • Blog home page :https://lansonli.blog.csdn.net
  • Welcome to thumb up Collection Leaving a message. Please correct any mistakes !
  • This paper is written by Lansonli original , First appeared in CSDN Blog
  • When you stop to rest, don't forget that others are still running , I hope you will seize the time to learn , Go all out for a better life
copyright:author[Lansonli],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/202206240337059376.html