Feat: Add hostPort and protocol to containers (#1558)
* feat: add the host port to containers * test(unit): add unit tests for host port and protocol * test(functional): add functional tests of host port and protocol * test(functional): add functional tests of host port and protocol for openshift
This commit is contained in:
@@ -216,3 +216,11 @@ convert::expect_success "$os_cmd" "$os_output"
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/single-file-output/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/single-file-output/output-k8s.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
|
||||
# Test host port and protocol feature
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/docker-compose.yaml convert --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-k8s.yaml"
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
ports:
|
||||
- target: 80
|
||||
published: 80
|
||||
protocol: tcp
|
||||
mode: host
|
||||
image: nginx
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- name: "80"
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
io.kompose.service: nginx
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
io.kompose.service: nginx
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
io.kompose.service: nginx
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
hostPort: 80
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: host-port-protocol-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- name: "80"
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
io.kompose.service: nginx
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: DeploymentConfig
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
io.kompose.service: nginx
|
||||
strategy:
|
||||
resources: {}
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
io.kompose.service: nginx
|
||||
spec:
|
||||
containers:
|
||||
- image: ' '
|
||||
name: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
hostPort: 80
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
test: false
|
||||
triggers:
|
||||
- type: ConfigChange
|
||||
- imageChangeParams:
|
||||
automatic: true
|
||||
containerNames:
|
||||
- nginx
|
||||
from:
|
||||
kind: ImageStreamTag
|
||||
name: nginx:latest
|
||||
type: ImageChange
|
||||
status:
|
||||
availableReplicas: 0
|
||||
latestVersion: 0
|
||||
observedGeneration: 0
|
||||
replicas: 0
|
||||
unavailableReplicas: 0
|
||||
updatedReplicas: 0
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ImageStream
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
lookupPolicy:
|
||||
local: false
|
||||
tags:
|
||||
- annotations: null
|
||||
from:
|
||||
kind: DockerImage
|
||||
name: nginx
|
||||
generation: null
|
||||
importPolicy: {}
|
||||
name: latest
|
||||
referencePolicy:
|
||||
type: ""
|
||||
status:
|
||||
dockerImageRepository: ""
|
||||
|
||||
Reference in New Issue
Block a user