opencompose icon indicating copy to clipboard operation
opencompose copied to clipboard

Support for External IPs (Service)

Open kadel opened this issue 8 years ago • 2 comments
trafficstars

Kubernetes ExternalIPs

requested by @brainstorm:

Context: I came to test out opencompose since I needed a way to assign an already existing domain/AWS Elastic IP to a service, which I tried to achieve with kompose.io before @kadel kindly redirected me here instead.

In other words, I have an existing AWS Elastic IP I do not want to change and I want OpenCompose to instantiate my services pointing to that EIP via a mechanism similar to kompose's service labels.

kadel avatar Apr 12 '17 16:04 kadel

I have been playing with plain kubectl commands and In my usecase it would suffice to have this kind of definition:

(...)
          ports:
            - port: 5000
              type: external-ip
              ip: eipalloc-c81678ad

I know that is very AWS-specific, so think whatever internal abstraction opencompose has.

Right now it seems like opencompose does generate an EIP since the output from convert has a LoadBalancer involved:

spec:
  ports:
  - name: port-5000
    port: 5000
    targetPort: 5000
  selector:
    service: cgtd
  type: LoadBalancer
status:
  loadBalancer: {}

So editing the resulting kubernetes services file to:

(py2) romanvgs-Air:opencompose romanvg$ git diff
diff --git a/opencompose/cgtd-service.yaml b/opencompose/cgtd-service.yaml
index 065351a..e7376eb 100644
--- a/opencompose/cgtd-service.yaml
+++ b/opencompose/cgtd-service.yaml
@@ -10,8 +10,10 @@ spec:
   - name: port-5000
     port: 5000
     targetPort: 5000
+  externalIPs:
+    - 52.64.16.69
   selector:
     service: cgtd
-  type: ClusterIP
+  type: LoadBalancer
 status:
   loadBalancer: {}

Does define the specified IP in kubernetes (right after the ELB hostname, followed by comma):

(py2) romanvgs-Air:opencompose romanvg$ kubectl get svc -o wide
NAME         CLUSTER-IP       EXTERNAL-IP                                                                               PORT(S)                               AGE       SELECTOR
cgtd         100.67.182.32    af30a3281204b11e7a8e8020e815fd47-419734837.ap-southeast-2.elb.amazonaws.com,52.64.16.69   5000:32748/TCP                        50m       service=cgtd
ipfs         100.69.182.242   <none>                                                                                    5001/TCP,9094/TCP,9095/TCP,9096/TCP   1h        service=ipfs
kubernetes   100.64.0.1       <none>                                                                                    443/TCP                               1h        <none>

Unfortunately, I'm able to reach the service via the ELB, but cannot reach the same service via the ExternalIP nor its associated hostname: unimelb.edu.au.cancergenetrust.org.

So to sum up, relatively small changes should be necessary on the loader/transformer of opencompose (using kompose's terminology for its architecture), but I'm not sure why I cannot reach the service via its defined ExternalIP... but feels so close! ;)

brainstorm avatar Apr 13 '17 14:04 brainstorm

Got the possible cause for not being able to connect there... the externalip is not associated to any private ip in the cluster (second in the AWS console list):

screen shot 2017-04-13 at 16 44 44

So I guess that opencompose would have to make that assignment too (thinking out loud)... Next step: how does one do that via plain kubectl commands?

brainstorm avatar Apr 13 '17 14:04 brainstorm