これを行うには、複数のサービスを作成します(詳細はhttp://kubernetes.io/docs/user-guide/services/を参照)。
の例では、(あなたはまた、JSONを使用することができ、YAMLを使用して)次のようになります。
apiVersion: v1
kind: Service
metadata:
name: yourservice_1
namespace: default
labels:
component: yourcomponent
spec:
type: NodePort
selector:
component: yourcomponent
ports:
- name: http
port: 8080
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: yourservice_2
namespace: default
labels:
component: yourcomponent
spec:
type: NodePort
selector:
component: yourcomponent
ports:
- name: http
port: 8081
protocol: TCP
---
Etc.
そして、あなたの質問の後半部分に答えるために:
を---持つことです1つのファイルに複数の定義(サービスでも、任意のkubernetes yamlでもかまいません)が可能です。
しかし、一般的に一度だけロードされる傾向があるので、サービスのための別のファイルをアドバイスしてください。
複数のサービス定義に注意してください:少なくとも(私が使用しているKubernetes 1.3.5/1.3.6のバージョンでは)、セレクタの特定の組み合わせができるだけ多くのポッドから始まるkubernetes。これを防ぐには:テストと実験。この状態を避ける限り、機能します。
単一のサービス・エントリ・ポイントも使用することができるように定義することができます:あなたはすべてのこれらのサービスのための単一のエントリポイントを取得するにはどうすればよい
apiVersion: v1
kind: Service
metadata:
name: yourservice_1
namespace: default
labels:
component: yourcomponent
spec:
type: NodePort
selector:
component: yourcomponent
ports:
- name: http
port: 8080
protocol: TCP
- name: http2
port: 8081
protocol: TCP
- name: http2
port: 8082
protocol: TCP
?元の質問は:http:// example.com' ... –
ああ、異なる質問を理解した。答えのパート2を参照してください。 –