Sample Code https://github.com/CodingSoldier/java-learn/tree/master/project/k8s-spring-cloud-csdn
csdn Download (integration can not seem to modify) https://download.csdn.net/download/u010606397/11245542
In this project, will deploy eureka, gateway, app01, app02
yaml look under the eureka configuration
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-eureka-server
spec:
# 注册中心只能部署一个pod
replicas: 1
selector:
matchLabels:
app: eureka-server
template:
metadata:
labels:
app: eureka-server
spec:
containers:
- name: eureka-server
image: codingsoldier/eureka-server:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 10001
---
apiVersion: v1
kind: Service
metadata:
# service的名字非常重要,必须跟application.properties的eureka.client.serviceUrl.defaultZone=http://server-eureka-server:10001/eureka/ 中的域名相同
name: server-eureka-server
spec:
selector:
app: eureka-server
# 使用NodePort类型的Service,绑定service的10001端口到宿主机,以便在物理机浏览器上看注册中心的信息
type: NodePort
ports:
- name: http
port: 10001
targetPort: 10001
# 暴露端口取值范围是30000-32767
nodePort: 30001
There are two important
1, the number of pod registry can only be one (just the demo, so with the actual deployment can be deployed in a cluster, this is too much trouble)
2, Service name is eureka.client.serviceUrl.defaultZone domain name. See below
Supplement, image used my warehouse, please change your own, labeled image on their machines
gateway, app01, app02 configure the registry
eureka.client.serviceUrl.defaultZone=http://server-eureka-server:10001/eureka/
In order to be able to call on a physical machine gateway, the gateway is set to NodePort type of service (loadBlance call gateway actual deployment should be provided by the ingress or cloud vendors here to engage in so complicated)
Steps for usage
1, the node jar package upload all nodes labeled mirror
2, the master node Deployment Services
app01 of / test01 / test02 / post interfaces will use feign call app02, adjustment to this interface.