k8s安装eureka
# 1.编辑k8s-eureka-prod.yml
apiVersion: v1
kind: ConfigMap
metadata:
name: eureka-cm
data:
# if you want to deploy n instances of eureka cluster,
# you should set eureka_service_address: http://eureka-0.eureka:8761/eureka,...,http://eureka-(n-1).eureka:8761/eureka
eureka_service_address: http://eureka-0.eureka:8761/eureka,http://eureka-1.eureka:8761/eureka,http://eureka-2.eureka:8761/eureka
---
apiVersion: v1
kind: Service
metadata:
name: eureka-np
labels:
app: eureka
spec:
type: NodePort
ports:
- port: 8761
nodePort: 28600
name: eureka
selector:
app: eureka
---
apiVersion: v1
kind: Service
metadata:
name: eureka
labels:
app: eureka
spec:
clusterIP: None
ports:
- port: 8761
name: eureka
selector:
app: eureka
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: eureka
spec:
serviceName: 'eureka'
# n instances
replicas: 3
selector:
matchLabels:
app: eureka
template:
metadata:
labels:
app: eureka
spec:
containers:
- name: eureka
image: bitinit/eureka
ports:
- containerPort: 8761
resources:
requests:
memory: "1Gi"
cpu: "500m"
limits:
memory: "1200Mi"
cpu: "500m"
env:
- name: EUREKA_SERVER_ADDRESS
valueFrom:
configMapKeyRef:
name: eureka-cm
key: eureka_service_address
- name: ENVIRONMENT
value: "prod"
- name: JVM_OPTS
value: "-Xms1g -Xmx1g"
livenessProbe:
httpGet:
path: /
port: 8761
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /
port: 8761
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[root@master ~]# kubectl apply -f k8s-eureka-prod.yml
configmap/eureka-cm created
service/eureka-np created
service/eureka created
statefulset.apps/eureka created
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 0/1 ContainerCreating 0 6s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m36s
eureka-1 0/1 Running 1 2m8s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m40s
eureka-1 0/1 Running 1 2m12s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m41s
eureka-1 0/1 Running 1 2m13s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m41s
eureka-1 0/1 Running 1 2m13s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m42s
eureka-1 0/1 Running 1 2m14s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m43s
eureka-1 0/1 Running 1 2m15s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 6m43s
eureka-1 0/1 Running 1 2m15s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-0 1/1 Running 3 15m
eureka-1 1/1 Running 1 11m
eureka-2 1/1 Running 2 8m54s
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
37
38
39
40
41
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
37
38
39
40
41
# 结果展示
浏览器访问各个节点的IP:28600 都可以查看注册中心哟