在一个已存在POD容器上执行命令
k exec kubia-752jx -- curl -s http://10.111.179.108
如果需要连接外部资源,需要创建没有选择器的服务,在创建同名的Endpoint,在Endpoint中指定外部服务的IP和端口
使用NodePort将服务暴露给外部客户端
apiVersion: apps/v1beta2
kind: ReplicaSet
metadata:
name: kubia
spec:
replicas: 3
selector:
matchLabels:
env: dev
template:
metadata:
labels:
env: dev
spec:
containers:
- name: kubia
image: charliejiang233/kubia
ports:
- containerPort: 8080
apiVersion: v1
kind: Service
metadata:
name: kubia-nodeport
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
nodePort: 30123
selector:
env: dev