2015-08-19 2 views
0

Я создал докер местного установку kubernetes, и я смог создать реплики и услуги, как показано ниже (это от kubernetes 201):Как я могу открыть службу в узле в kubernetes 1.0?

гс:

apiVersion: v1 
kind: ReplicationController 
metadata: 
    name: nginx-controller 
spec: 
    replicas: 2 
    # selector identifies the set of Pods that this 
    # replication controller is responsible for managing 
    selector: 
    app: nginx 
    # podTemplate defines the 'cookie cutter' used for creating 
    # new pods when necessary 
    template: 
    metadata: 
     labels: 
     # Important: these labels need to match the selector above 
     # The api server enforces this constraint. 
     app: nginx 
    spec: 
     containers: 
     - name: nginx 
     image: nginx 
     ports: 
     - containerPort: 80 

и service.yaml:

apiVersion: v1 
kind: Service 
metadata: 
    name: nginx-service 
spec: 
    ports: 
    - port: 8000 # the port that this service should serve on 
    # the container on each pod to connect to, can be a name 
    # (e.g. 'www') or a number (e.g. 80) 
    targetPort: 80 
    protocol: TCP 
    nodePort: 30000 
    type: LoadBalancer 
    # just like the selector in the replication controller, 
    # but this time it identifies the set of pods to load balance 
    # traffic to. 
    selector: 
    app: nginx 

С моей точки зрения, я должен иметь доступ к службе из порта 30000 в узле, но все, что я получаю, это пустой ответ. Любая помощь?

ответ

0

Если вы используете kubernetes как non-root, вам может потребоваться проверить диапазон портов, если не-root разрешено открывать порт.

Никогда не пробовал это, но другим способом вы можете открыть порт на узлах для конкретного контейнера через replicationcontroller путем добавления hostPort: 30000 ниже - containerPort: 80

+0

Ну, он работает с привилегированными = верно, так оно должно иметь права суперпользователя. Я попробую это, но заметьте, что это может быть обходным путем. В идеале это должно быть разрешено на «уровне обслуживания». –