我有一个Spring引导应用程序。我想加载到我的K8S(master+kubectl,172.16.100.83)我们的图像注册表是192.168.1.229:5000。
1) With command window
a. docker pull 192.168.1.229:5000/gearboxrack/gearbox-rack-eureka-server
b. kubectl run gearbox-rack-eureka-server --image=192.168.1.229:5000/gearboxrack/gearbox-rack-eureka-server --port=8761
c. kubectl expose deployment gearbox-rack-eureka-server --type NodePort
[root@master3 supwisdom]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
gearbox-rack-eureka-server NodePort 10.103.109.185 <none> 8761:30719/TCP 6s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
然后我成功地启动了应用程序
172.16.100.83:30719
。注意,现在端口由K8S随机生成。
现在我使用yaml文件尝试获得一些结果/目标。
尤里卡豆荚山药
apiVersion: v1
kind: Pod
metadata:
name: gearbox-rack-eureka-server
labels:
purpose: platform_eureka_demo
spec:
containers:
- name: gearbox-rack-eureka-server
image: 192.168.1.229:5000/gearboxrack/gearbox-rack-eureka-server
ports:
- containerPort: 8761
我的eureka_svc.yaml文件是
apiVersion: v1
kind: Service
metadata:
name: gearbox-rack-eureka-server
labels:
name: gearbox_rack_eureka_server
spec:
type: NodePort
ports:
- port: 8761
nodePort: 31501
name: tcp
[root@master3 supwisdom]# kubectl apply -f eureka_pod.yaml
pod "gearbox-rack-eureka-server" created
[root@master3 supwisdom]# kubectl apply -f eureka_svc.yaml
service "gearbox-rack-eureka-server" created
[root@master3 supwisdom]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
gearbox-rack-eureka-server NodePort 10.99.100.123 <none> 8761:31501/TCP 11s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2h
但现在我试着
172.16.100.83:31501
,我无法得到和命令行相同的结果。我的脚步有问题吗?