Skip to content

Setting service type to NodePort #2043

@filson1

Description

@filson1

Expected Behavior

Using Kompose convert on a docker-compose file with

services: my-service: image: my-service:${IMAGE_TAG-latest} ports: - "50352:50352" environment: - ASPNETCORE_URLS=http://+:50352 networks: - my-network deploy: replicas: 1 labels: kompose.service: my-service kompose.service.type: nodeport networks: my-network: driver: bridge 

generates a deployment yaml with:

apiVersion: apps/v1 kind: Deployment metadata: annotations: kompose.cmd: kompose convert kompose.version: 1.36.0 (ae2a39403) labels: io.kompose.service: my-service kompose.service: my-service kompose.service.type: nodeport name: my-service spec: replicas: 1 selector: matchLabels: io.kompose.service: my-service template: metadata: annotations: kompose.cmd: kompose convert kompose.version: 1.36.0 (ae2a39403) labels: io.kompose.service: my-service spec: containers: - env: - name: ASPNETCORE_URLS value: http://+:50352 image: my-service:123456789 name: my-service ports: - containerPort: 50352 protocol: TCP restartPolicy: Always 

Strangely enough, that never seems to be enough for K3s, as it registers it as using a ClusterIP rather than a NodePort

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-service ClusterIP 10.43.128.13 <none> 50352/TCP 46s 

I was hoping I could use the service type label from https://kompose.io/user-guide/#komposeservicetype to get the docker-compose file to control Kubernetes services. Is this assumption wrong?

Actual Behavior

Service type gets ClusterIP state regardless of kompose.service.type setting.

Steps To Reproduce

No response

Kompose Version

1.37.0 (fb0539e64). Example is from 1.36.0 but both versions does the same. 

Docker-Compose file

services: my-service: image: my-service:${IMAGE_TAG-latest} ports: - "50352:50352" environment: - ASPNETCORE_URLS=http://+:50352 networks: - my-network deploy: replicas: 1 labels: kompose.service: my-service kompose.service.type: nodeport networks: my-network: driver: bridge

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions