在访问eurka的时候是可以看到网关服务的,这是因为在gateway的配置文件里面配置了eurka服务的,所以在启动的时候会注册到eurka当中。
[root@master portal-service]# docker build -t reg.harbor.com/microservice/portal:v1 .
Sending build context to Docker daemon 47.53MB
Step 1/5 : FROM java:8-jdk-alpine
---> 3fd9dd82815c
Step 2/5 : RUN apk add -U tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
---> Using cache
---> a9034491fdd5
Step 3/5 : COPY ./target/portal-service.jar ./
---> 73f9d23d7d63
Step 4/5 : EXPOSE 8080
---> Running in 6e9075e4b750
Removing intermediate container 6e9075e4b750
---> 032bd2444ffa
Step 5/5 : CMD java -jar /portal-service.jar
---> Running in f5bec1116b49
Removing intermediate container f5bec1116b49
---> 7d746f188d53
Successfully built 7d746f188d53
Successfully tagged reg.harbor.com/microservice/portal:v1
[root@master portal-service]# docker push reg.harbor.com/microservice/portal:v1
The push refers to repository [reg.harbor.com/microservice/portal]
42ba10527973: Pushed
8994a8716f11: Mounted from microservice/gateway
a1e7033f082e: Mounted from microservice/gateway
78075328e0da: Mounted from microservice/gateway
9f8566ee5135: Mounted from microservice/gateway
v1: digest: sha256:8b8c353179a74ba8ae035e59009dca3ead17078127f4fd38a3eb9cf430e06359 size: 1370
[root@master k8s]# cat portal.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: portal
namespace: ms
spec:
rules:
- host: portal.ctnrs.com
http:
paths:
- path: /
backend:
serviceName: portal
servicePort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: portal
namespace: ms
spec:
ports:
- port: 8080
name: portal
selector:
project: ms
app: portal
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: portal
namespace: ms
spec:
replicas: 1
selector:
matchLabels:
project: ms
app: portal
template:
metadata:
labels:
project: ms
app: portal
spec:
imagePullSecrets:
- name: registry-pull-secret
containers:
- name: portal
image: reg.harbor.com/microservice/portal:v1
imagePullPolicy: Always
ports:
- protocol: TCP
containerPort: 8080
resources:
requests:
cpu: 0.5
memory: 512Mi
limits:
cpu: 1
memory: 1Gi
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
查看 portal 是否注册到 eureka 中
在浏览器访问 eureka.ctnrs.com 可看到 portal 服务已经注册到 eureka 了
访问前端页面
在浏览器访问 portal.ctnrs.com