バックエンドノードがクラスターの一部ではなく、固定されたノードのセット(固定IPを持つ)であるKubernetesサービスを作成したので、同じ名前のエンドポイントリソースも作成しました。
apiVersion: v1
kind: Service
metadata:
name: hive
spec:
type: ClusterIP
ports:
- name: http
port: 80
protocol: TCP
targetPort: 10002
---
apiVersion: v1
kind: Endpoints
metadata:
name: hive
subsets:
- addresses:
- ip: 10.52.7.28
- ip: 10.52.7.29
ports:
- port: 10002
サービスとエンドポイントの説明:
$ kubectl describe svc/hive
Name: hive
Namespace: default
Labels: <none>
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP: 10.0.192.103
Port: http 80/TCP
TargetPort: 10002/TCP
Endpoints:
Session Affinity: None
Events: <none>
$
$ kubectl describe ep/hive
Name: hive
Namespace: default
Labels: <none>
Annotations: <none>
Subsets:
Addresses: 10.52.7.28,10.52.7.29
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
<unset> 10002 TCP
Events: <none>
ポッドの1つに実行し、エンドポイントサブセットアドレスに直接Telnetで接続すると、接続できますが、サービス経由でアクセスすると、接続が拒否されます。完全を期すために、サービスとポッドは同じ名前空間にあります。
# telnet 10.52.7.28 10002
Trying 10.52.7.28...
Connected to 10.52.7.28.
Escape character is '^]'.
^CConnection closed by foreign host.
#
# telnet 10.52.7.29 10002
Trying 10.52.7.29...
Connected to 10.52.7.29.
Escape character is '^]'.
^CConnection closed by foreign host.
#
# telnet hive 80
Trying 10.0.192.103...
telnet: Unable to connect to remote host: Connection refused
#
IPに直接接続できるのに、Kubernetesサービスを経由できない理由はありますか?これはファイアウォールルールが原因ではないと思います。直接リクエストもブロックする必要があるからです。
編集:Endpoints
実行時に空であることが関係していると思われkubectl describe svc/hive
ますが、ダッシュボードでエンドポイント([サービス]ページの下)にそれらのエンドポイントが表示されていることがわかります。
ポートの名前はとの間Service
で一致する必要がありEndpoint
ます。サービス内のポート名を削除するか、エンドポイントに追加します。
apiVersion: v1
kind: Service
metadata:
name: hive
spec:
type: ClusterIP
ports:
- name: http
port: 80
protocol: TCP
targetPort: 10002
---
apiVersion: v1
kind: Endpoints
metadata:
name: hive
subsets:
- addresses:
- ip: 10.52.7.28
- ip: 10.52.7.29
ports:
- name: http
port: 10002
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加