Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Autogenerating port names #38

Closed
kadel opened this issue Jun 20, 2017 · 7 comments · Fixed by #76
Closed

Autogenerating port names #38

kadel opened this issue Jun 20, 2017 · 7 comments · Fixed by #76

Comments

@kadel
Copy link
Member

kadel commented Jun 20, 2017

if multiple ports are specified in a single service they have to be named. see https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services

We can make names optional and autogenerate them if no name is specified.

name: test

containers:
- name: nginx
  image: quay.io/tomkral/nonroot-nginx
- name: nginx2
  image: nginx

services:
  - name: test
    type: LoadBalancer
    ports:
      - port: 8080
        # default name: port-8080
      - ports: 80
        # default name: port-80
@kadel kadel changed the title Missing port names Autogenerating port names Jun 20, 2017
@surajssd
Copy link
Member

@kadel is this necessary?

@kadel
Copy link
Member Author

kadel commented Jun 21, 2017

@kadel is this necessary?

yes! Port name is required by kubernetes once you specify more that on port

@surajssd
Copy link
Member

@kadel TIL 👍

@concaf
Copy link
Collaborator

concaf commented Jun 21, 2017

@concaf
Copy link
Collaborator

concaf commented Jun 21, 2017

picking this up

@concaf concaf self-assigned this Jun 21, 2017
@kadel
Copy link
Member Author

kadel commented Jun 22, 2017

[bump] Encountered this while converting out - https://raw.githubusercontent.com/containscafeine/fabric8-analytics-data-model/master/local-setup/docker-compose.yaml

you can still convert that, it's not a blocker, you just have to explicitly set port names

@concaf
Copy link
Collaborator

concaf commented Jun 23, 2017

@kadel yep, not a blocker, just bumped because I faced this :P

concaf added a commit to concaf/kedge that referenced this issue Jun 26, 2017
Before this commit, if a definition is passed with multiple ports
in one service, then in the generated Kubernetes output, the port
names are not populated, which when deployed to a Kubernetes
cluster, throws an error.

This commit fixes this, such that if multiple ports for one
service are specified, then if the port names are not specified,
they are auto generated and populated, in the format -
"service_name-service_port"

Note that, the auto generation and population only happens in
case of multiple ports, and in the case when the port names
are not already specified.

e.g. - for the input -

name: test
containers:
 - image: nginx
services:
- name: nginx
  ports:
  - port: 8080
  - port: 8081

the resulting output will contain Kubernetes service as -

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: test
  name: nginx
spec:
  ports:
  - name: nginx-8080
    port: 8080
    targetPort: 0
  - name: nginx-8081
    port: 8081
    targetPort: 0
  selector:
    app: test

This commit also adds tests for this behavior.

Fix kedgeproject#38
concaf added a commit to concaf/kedge that referenced this issue Jun 27, 2017
Before this commit, if a definition is passed with multiple ports
in one service, then in the generated Kubernetes output, the port
names are not populated, which when deployed to a Kubernetes
cluster, throws an error.

This commit fixes this, such that if multiple ports for one
service are specified, then if the port names are not specified,
they are auto generated and populated, in the format -
"service_name-service_port"

Note that, the auto generation and population only happens in
case of multiple ports, and in the case when the port names
are not already specified.

e.g. - for the input -

name: test
containers:
 - image: nginx
services:
- name: nginx
  ports:
  - port: 8080
  - port: 8081

the resulting output will contain Kubernetes service as -

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: test
  name: nginx
spec:
  ports:
  - name: nginx-8080
    port: 8080
    targetPort: 0
  - name: nginx-8081
    port: 8081
    targetPort: 0
  selector:
    app: test

This commit also adds tests for this behavior.

Fix kedgeproject#38
@kadel kadel closed this as completed in #76 Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants