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


#1

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.

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?

Thank you


#2

That’s not the purpose of continuous integration. The machine you specify will live for a few minutes, run tests or create build artefacts, and then will be torn down. It might be possible to see them in a web browser depending on the firewall configuration (port 22 is accessible on these machines for SSH access), but I am not sure it can be relied upon.

Can you explain in more detail why you want to do this?


#3