Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-design ServiceExpose trait #53

Open
resouer opened this issue Aug 3, 2020 · 2 comments
Open

Re-design ServiceExpose trait #53

resouer opened this issue Aug 3, 2020 · 2 comments

Comments

@resouer
Copy link
Collaborator

resouer commented Aug 3, 2020

The idea is Expose should answer below questions:

  1. which target port I want to expose?
  2. expose to what service port?
  3. what's the type of this expose?
  4. what's the protocol?

It should be a list, with Kind of Expose. So I'd suggest re-design ServiceExpose as below.

Example 1:

apiVersion: core.oam.dev/v1alpha2
kind: Expose
spec:
  servicePorts:
    - port: 80
      targetPort: 80
    - port: 8001
      targetPort: 9376

This will generate one k8s Service:

apiVersion: v1
kind: Service
metadata:
  name: <component-name>-clusterip
spec:
  clusterIP: 10.96.193.247 # auto gen
  ports:
  - name: tcp-80 # auto gen
    port: 80
    protocol: TCP # default
    targetPort: 80
  - name: tcp-8080 # auto-gen
    port: 8080
    protocol: TCP # default
    targetPort: 80
  selector:
    component: <component-name>
  type: ClusterIP

Example 2:

apiVersion: core.oam.dev/v1alpha2
kind: Expose
spec:
  servicePorts:
    - port: 80
      targetPort: 80
      type: NodePort
    - port: 8001
      targetPort: 9376
      clusterIP: 10.0.171.239
      type: LoadBalancer
      protocol: HTTP

This will generate two k8s Services:

apiVersion: v1
kind: Service
metadata:
  name: <component-name>-nodeport
spec:
  type: NodePort
  ports:
  - name: tcp-80 # auto gen
    port: 80
    protocol: TCP # default
    targetPort: 80
  selector:
    component: <component-name> # this is auto label for workload
apiVersion: v1
kind: Service
metadata:
  name: <component-name>-loadbalancer
spec:
  type: LoadBalancer
  clusterIP: 10.0.171.239
  ports:
  - name: http-8001 # auto gen
    port: 8001
    protocol: HTTP
    targetPort: 9376
  selector:
    component: <component-name> # this is auto label for workload

For auto labels of workload, ref: crossplane/oam-kubernetes-runtime#174

@resouer
Copy link
Collaborator Author

resouer commented Aug 3, 2020

/cc @wonderflow

@hongchaodeng
Copy link
Member

I would recommend to take a look at the port abstraction in Exposing the service section in this blog: https://medium.com/kapitan-blog/keep-your-ship-together-with-kapitan-d82d441cc3e7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants