koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

Service Short Syntax #42

Closed wlan0 closed 6 years ago

wlan0 commented 6 years ago

selector should be called selector

ServicePort can be simplified

to


- name: $name
  $protocol://$port:$targetPort

or
- name: $name
  $protocol://$port:$nodePort

ExternalName should be called cname

ClusterIP and LoadBalancerIP can be consolidated into one field called ip (and inferred based on type)

ExternalIP should be external_ip

a field called stickiness (bool or string) can consolidate SessionAffinity and SessionAffinityConfig and should be defaulted to v1.DefaultClientIPServiceAffinitySeconds (10800). If this is specified as bool, then the affinity is clientIP with default duration, and if specified as string, then use the duration as the ClientIPServiceAffinityTimeout

LoadBalancerSourceRanges should be called lb_client_ips

ExternalTrafficPolicy should be called route_policy: (node-local|cluster-wide)

HealthCheckNodePort should be called healthcheck_port

PublishNotReadyAddresses should be called unready_endpoints: (true|false)

Service.Status.Ingresses should just be called endpoints

endpoints:
 - ipaddr (space or tab separation) hostname

if only one is specified we can infer if it a hostname or ip addr using the actual data values. (Even though all ip addrs are valid hostnames)

ublubu commented 6 years ago

From the online docs:

LoadBalancerIP and ClusterIP can both exist.

kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376
  clusterIP: 10.0.171.239
  loadBalancerIP: 78.11.24.19
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: 146.148.47.155
wlan0 commented 6 years ago

Great! Can you figure out a solution?

ublubu commented 6 years ago

Yeah, I just put them as separate fields called cluster_ip and lb_ip.

wlan0 commented 6 years ago

There was an error in my earlier port transformation. It looks like targetPort and nodePort can co-exists

and there is also a bug:

apiVersion: v1
kind: Service
metadata:
  name: prune-svc
  labels:
    prune-group: "true"
spec:
  selector:
    prune-group-nomatch: "true"
  ports:
  - port: 80
    protocol: TCP
- service:
    labels:
      prune-group: "true"
    name: prune-svc
    port: "80:0"
    selector:
      prune-group-nomatch: "true"
    version: v1

The new format should be able to capture the information about ports more clearly.

Here's the new format as per our discussion

If there is only one unnamed port

service:
  port: 1234
  node_port: 5678

If there is one named port or multiple ports

service:
 - ports:
     - port_name: 1234:1231  # the field after : is the target port. Should not print if it is same as port
       node_port: 5678  #should not print if node_port is empty