k8s Service

Nats nodeportのYaml

Natsのnodeportタイプに関してのYaml 外部のサーバからアクセスできるようになる。 外部からアクセスするためのPort(targetport) を指定していないので、ランダムなポートが割り当てられる。 また、外部からのアクセス先のPodに関しては、selectorで対象pod/deploymentのlabelを指定する。 deploymentのlabelを指定したところ、外部から通信できないので、対象のPodのlabelを指定する必要があるかも?

以下の場合selecotで”app: samlepod”が指定されているので、こちらのpodに紐づけれる。

apiVersion: v1
kind: Service
metadata:
  labels:
    app: bioservice
  name: bioservice
spec:
  ports:
  - name: "8888"
    port: 8888
    protocol: TCP
  type: NodePort
  selector:
    app : samplepod