Kubernetes Eureka Deployment

Service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
apiVersion: v1
kind: Service
metadata:
name: eureka-headless-service
labels:
app: eureka
spec:
ports:
- name: "8080"
port: 8080 # Service 提供的服务端口
targetPort: 8080 # 容器对应端口
clusterIP: None
selector:
app: eureka

# pod fixed address is eureka-0.eureka-headless-service

apiVersion: v1
kind: Service
metadata:
name: eureka-service # Service全局唯一名称
spec:
ports:
- name: "8080"
port: 8080 # Service 提供的服务端口
targetPort: 8080 # 容器对应端口
selector:
app: eureka

Deployment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: eureka # 全局唯一名称
spec:
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
app: eureka
replicas: 2
serviceName: eureka-headless-service
template:
metadata:
labels:
app: eureka
spec:
containers:
- name: eureka
image:
resources:
requests:
memory: 256Mi
cpu: 400m
limits:
cpu: 2.0
memory: 512Mi
ports:
- containerPort: 8080
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: EUREKA_CLUSTER_URL
value: http://eureka-0.eureka-headless-service:8080/eureka/,http://eureka-1.eureka-headless-service:8080/eureka/

Error

  1. EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY’RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

保护模式主要用于一组客户端和Eureka Server之间存在网络分区场景下的保护。一旦进入保护模式,Eureka Server将会尝试保护其服务注册表中的信息,不再删除服务注册表中的数据(也就是不会注销任何微服务)。

原因是 Eureka Server 和其他的 Eureka Server 不能进行同步数据。

http://www.itmuch.com/spring-cloud-sum-eureka/