kubeless icon indicating copy to clipboard operation
kubeless copied to clipboard

function service template annotations

Open yvz5 opened this issue 4 years ago • 3 comments

I would like to create an http trigger using azure internal load balancers. In order to do this I need to add the following annotation to the function service:

apiVersion: v1
kind: Service
metadata:
  name: todo-app-service
  annotations:
    **service.beta.kubernetes.io/azure-load-balancer-internal: "true"**
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: todo-app

I did try using yaml files to define the function:

apiVersion: kubeless.io/v1beta1
kind: Function
metadata:
  name: api-endpoint
spec:  
  deps: "package.json"
  function: "app.js"
  function-content-type: url
  handler: app.app
  runtime: nodejs8
  service:
    metadata:
      annotations:
        service.beta.kubernetes.io/azure-load-balancer-internal: "true"
    ports:
    - name: http-function-port
      port: 80
      protocol: TCP
      targetPort: 80
    selector:
      created-by: kubeless
      function: api-endpoint
    type: LoadBalancer

but the metadata of the service does not appear when I call describe:

Name:                     api-endpoint
Namespace:                kubeless
Labels:                   created-by=kubeless
                          function=api-endpoint
Annotations:              
Selector:                 created-by=kubeless,function=api-endpoint
Type:                     LoadBalancer
IP:                       <local ip>
LoadBalancer Ingress:     <public ip>
Port:                     http-function-port  80/TCP
TargetPort:               80/TCP
NodePort:                 http-function-port  31439/TCP
Endpoints:                
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                Age    From                Message
  ----    ------                ----   ----                -------
  Normal  EnsuringLoadBalancer  3m16s  service-controller  Ensuring load balancer
  Normal  EnsuredLoadBalancer   91s    service-controller  Ensured load balancer

is there any way to force the service to have metadata ?

yvz5 avatar Sep 24 '19 08:09 yvz5

Unfortunately the function annotations are not forwarded right now to the Service (only the labels are forwarded).

You can either add support for that in the Kubeless controller (as we do for the Deployments) or create an additional service with the annotations that you need.

andresmgot avatar Sep 24 '19 11:09 andresmgot

do you mean to change the code of the controller to make it transfer annotations ?

yvz5 avatar Sep 24 '19 13:09 yvz5

yes, that's one option. We are doing that for Deployments:

https://github.com/kubeless/kubeless/blob/master/pkg/utils/kubelessutil.go#L590

So we could do something similar for the services.

andresmgot avatar Sep 25 '19 07:09 andresmgot