最近忙的要死, 👻👻👻. 上一周来了一次比 996 更猛的 907
. 这周二终于有点遭不住了, 调休一天, 稍微歇息一下.
同时手痒的不行, 把筹备了好久的重磅文章发上来哈哈. 😆😆😆
不过时间还是有点仓促, 所以这次就先开个头, 后面有时间再细化.
root
启动以及配置其他特权. 如无必要, 一律使用普通用户.LANG
配置: LANG = en_US.UTF-8
. 目的: 避免生产出现 乱码等问题TZ=Asia/Shanghai
目的: 避免生产出现时区不一致的问题${version}
或${gitCommitId}
这一类的标签. 目的: 通过版本号或 commit id, 保证正确地的版本流转到生产worker_processes 1;
然后按需调节副本数.maxUnavailable
或minAvailable
(特别适用于: 有状态应用. 典型如: redis, kafka, zookeeper 等)podAntiAffinity
. 保证同一组微服务/应用/组件尽可能打散在不同 node 上.5-6 操作步骤:
nodeSelector:
zone: internet
11 步示例如下:
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 60
readinessProbe:
httpGet:
path: /myapp/services/
port: 8080
scheme: HTTP
initialDelaySeconds: 60
14 步示例如下: (注意关键词: maxUnavailable
和 minAvailable
)
kind: PodDisruptionBudget
apiVersion: policy/v1beta1
metadata:
name: kafka-prod-kafka
labels:
app.kubernetes.io/instance: kafka-prod
app.kubernetes.io/managed-by: strimzi-cluster-operator
app.kubernetes.io/name: strimzi
strimzi.io/cluster: kafka-prod
strimzi.io/kind: Kafka
strimzi.io/name: kafka-prod-kafka
spec:
selector:
matchLabels:
strimzi.io/cluster: kafka-prod
strimzi.io/kind: Kafka
strimzi.io/name: kafka-prod-kafka
maxUnavailable: 1
kind: PodDisruptionBudget
apiVersion: policy/v1beta1
metadata:
name: redis-cluster-redis
namespace: myapp
labels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
spec:
minAvailable: 2
selector:
matchLabels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
15 步骤示例如下: (注意关键词: podAntiAffinity
)
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: redis-cluster-redis
labels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
spec:
replicas: 3
selector:
matchLabels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
spec:
containers:
<...>
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/component: redis
app.kubernetes.io/managed-by: redis-operator
app.kubernetes.io/name: redis
app.kubernetes.io/part-of: redis-cluster
redis.kun/v1beta1: myapp_redis
topologyKey: kubernetes.io/hostname
...
🎉🎉🎉
本文由博客一文多发平台 OpenWrite 发布!