Kubernetes 服务无法获取其外部 IP 地址
Kubernetes Service does not get its external IP address
当我分两步构建 Kubernetes 服务时(1. 复制控制器;2. 公开复制控制器)我公开的服务获得一个外部 IP 地址:
initially:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.241.95 80/TCP app=app-1 7s
大约 30 秒后:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.241.95 104.155.93.79 80/TCP app=app-1 35s
但是当我在一步中提供 Service
和 ReplicationController
到 kubectl create -f dir_with_2_files
时,服务被创建但它没有获得和外部 IP:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.251.171 <none> 80/TCP app=app-1 2m
External IP 下的 <none>
让我担心。
对于服务,我使用 JSON 文件:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "app-1"
},
"spec": {
"selector": {
"app": "app-1"
},
"ports": [
{
"port": 80,
"targetPort": 8000
}
]
}
}
对于 ReplicationController:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "app-1"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"labels": {
"app": "app-1"
}
},
"spec": {
"containers": [
{
"name": "service",
"image": "gcr.io/sigma-cairn-99810/service:latest",
"ports": [
{
"containerPort": 8000
}
]
}
]
}
}
}
}
并手动公开服务我使用命令:
kubectl expose rc app-1 --port 80 --target-port=8000 --type="LoadBalancer"
如果您不指定服务类型,它默认为 ClusterIP。如果你想要 expose
的等价物,你必须:
- 确保您的服务通过匹配标签选择器从 RC 选择 pods
- 制作服务
type=LoadBalancer
当我分两步构建 Kubernetes 服务时(1. 复制控制器;2. 公开复制控制器)我公开的服务获得一个外部 IP 地址:
initially:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.241.95 80/TCP app=app-1 7s
大约 30 秒后:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.241.95 104.155.93.79 80/TCP app=app-1 35s
但是当我在一步中提供 Service
和 ReplicationController
到 kubectl create -f dir_with_2_files
时,服务被创建但它没有获得和外部 IP:
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
app-1 10.67.251.171 <none> 80/TCP app=app-1 2m
External IP 下的 <none>
让我担心。
对于服务,我使用 JSON 文件:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "app-1"
},
"spec": {
"selector": {
"app": "app-1"
},
"ports": [
{
"port": 80,
"targetPort": 8000
}
]
}
}
对于 ReplicationController:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "app-1"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"labels": {
"app": "app-1"
}
},
"spec": {
"containers": [
{
"name": "service",
"image": "gcr.io/sigma-cairn-99810/service:latest",
"ports": [
{
"containerPort": 8000
}
]
}
]
}
}
}
}
并手动公开服务我使用命令:
kubectl expose rc app-1 --port 80 --target-port=8000 --type="LoadBalancer"
如果您不指定服务类型,它默认为 ClusterIP。如果你想要 expose
的等价物,你必须:
- 确保您的服务通过匹配标签选择器从 RC 选择 pods
- 制作服务
type=LoadBalancer