Skip to content

Bad LoadBalancer service generation #1399

Closed
@mixitgit

Description

I try to use kompose on the example docker-compose.yaml:
version: "2"

services:

  redis-master:
    image: k8s.gcr.io/redis:e2e 
    ports:
      - "6379"

  redis-slave:
    image: gcr.io/google_samples/gb-redisslave:v1
    ports:
      - "6379"
    environment:
      - GET_HOSTS_FROM=dns

  frontend:
    image: gcr.io/google-samples/gb-frontend:v4
    ports:
      - "80:80"
    environment:
      - GET_HOSTS_FROM=dns
    labels:
      kompose.service.type: LoadBalancer

kompose generates this yaml for frontend service:

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert -f docker-compose.yaml
    kompose.service.type: LoadBalancer
    kompose.version: 1.23.0 (bc7d9f4f)
  creationTimestamp: null
  labels:
    io.kompose.service: frontend-tcp
  name: frontend-tcp
spec:
  ports:
    - name: "80"
      port: 80
      targetPort: 80
  selector:
    io.kompose.service: frontend-tcp
  type: LoadBalancer
status:
  loadBalancer: {}

And deployment for frontend looks like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f docker-compose.yaml
    kompose.service.type: LoadBalancer
    kompose.version: 1.23.0 (bc7d9f4f)
  creationTimestamp: null
  labels:
    io.kompose.service: frontend
  name: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: frontend
  strategy: {}
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f docker-compose.yaml
        kompose.service.type: LoadBalancer
        kompose.version: 1.23.0 (bc7d9f4f)
      creationTimestamp: null
      labels:
        io.kompose.service: frontend
    spec:
      containers:
        - env:
            - name: GET_HOSTS_FROM
              value: dns
          image: gcr.io/google-samples/gb-frontend:v4
          name: frontend
          ports:
            - containerPort: 80
          resources: {}
      restartPolicy: Always
status: {}

Which doesn't work, since the selector for service is

  selector:
    io.kompose.service: frontend-tcp

And deployment has this label:

  labels:
    io.kompose.service: frontend

If I change selector to

  selector:
    io.kompose.service: frontend

LoadBalancer starts working

Am I doing something wrong or it is a bug?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions