How to expose my pod to the internet and get to it from the browser?

first of all I downloaded kubernetes, kubectl and created a cluster from aws (export KUBERNETES_PROVIDER=aws; wget -q -O - https://get.k8s.io | bash
)

I added some lines to my project circle.yml to use circleCI services to build my image.

  • Why is the Node.js AWS-SDK returning the wrong SQS queue URL when creating a local queue
  • AWS - Beanstalk
  • How do I get an exit code from an Amazon ECS Task?
  • Install composer dependencies while deploying
  • AWS Elastic BeanStalk Docker root file system switch to read-only
  • Docker commands hanging with no response
  • To support docker I added:

    machine:
      services:
        - docker
    

    and to create my image and send it to my artifacts I added:

    deployment:
        commands:
          - docker login -e admin@comp.com -u ${ARTUSER} -p ${ARTKEY} docker-docker-local.someartifactory.com
          - sbt -DBUILD_NUMBER="${CIRCLE_BUILD_NUM}" docker:publish
    

    After that I created a 2 folders:

    my project (MyApp) folder with two files:

    controller.yaml

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: MyApp
      labels:
        name: MyApp
    spec:
      replicas: 1
      selector:
        name: MyApp
      template:
        metadata:
          labels:
            name: MyApp
            version: 0.1.4
        spec:
          containers:
          - name: MyApp
            #this is the image artifactory
            image: docker-docker-release.someartifactory.com/MyApp:0.1.4
            ports:
            - containerPort: 9000
          imagePullSecrets:
            - name: myCompany-artifactory
    

    service.yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: MyApp
      labels:
        name: MyApp
    spec:
      # if your cluster supports it, uncomment the following to automatically create
      # an external load-balanced IP for the frontend service.
      type: LoadBalancer
      ports:
        # the port that this service should serve on
      - port: 9000
      selector:
        name: MyApp
    

    And I have another folder for my artifactory (Kind : Secret).

    Now I created my pods with:

    kubectl create -f controller.yaml

    And now I have my pod running when I check in kubectl get pods.

    Now, how do I access my pod from the browser? my project is a play project so I want to get to it from the browser…how do I expose it the simplest way?

    thanks

  • Unable to install windowsServerCore Container Image
  • How to launch my docker container automatically on ECS?
  • Docker Nginx stopped: [emerg] 1#1: host not found in upstream
  • Docker mysql image - move internal container DB to the volume
  • Why pulled image is smaller than original image from the private registry?
  • How to reach docker containers by name instead of IP address?
  • One Solution collect form web for “How to expose my pod to the internet and get to it from the browser?”

    • The Replication Controller sole responsibility is ensuring that the amount of pods with the given configuration are run on your cluster.

    • The Service is what is public (or internally) exposing your pods to other parts of the system (or the internet).

    You should create your service with your yaml file (kubectl create -f service.yaml) which will create the service, selecting pods by the label selector MyApp for handling the load on the given port in your file (9000).

    Afterwards look at the registered service with kubectl get service to see which endpoint (ip) is allocated for it.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.