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.

  • AWS Elastic Beanstalk Application and Static Assets Deployment Isolation
  • Kubernetes and vSphere, AWS
  • How to delegate Kubernetes scheduler to Yarn
  • Go Web app on AWS with Elastic Beanstalk not showing output in logs
  • Run one app on multiple elastic beanstalk instances
  • Serving Jupyter Notebook from within docker container on AWS not working?
  • 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

  • Using Laradock, the “display_errors” flag is not working
  • Amazon Container Registry Only with ECS?
  • Docker container not showing volume mounted - Access issue
  • Using Docker with nodejs with node-gyp dependencies
  • Issue regarding the Dockerfile creation
  • Docker not running on OS/X
  • 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.