Fix merge compose file's replicas error (#1446)

This commit is contained in:
Hang Yan
2021-10-17 14:21:58 +08:00
committed by GitHub
parent c7ba832556
commit a87dd94532
30 changed files with 318 additions and 733 deletions
@@ -0,0 +1,12 @@
version: '3'
services:
web:
image: richarvey/nginx-php-fpm
environment:
- ERRORS=0
- HIDE_NGINX_HEADERS=0
- REMOVE_FILES=0
- RUN_SCRIPTS=0
- PHP_ERRORS_STDERR=0
- ENABLE_XDEBUG=0
@@ -0,0 +1,8 @@
version: '3'
services:
server:
ports:
- 5000:5000
new-my-service:
image: nginx
@@ -0,0 +1,11 @@
version: '3'
services:
server:
image: test
container_name: test_server
build:
context: .
dockerfile: Dockerfile-dev
ports:
- 3000:3000
@@ -0,0 +1,6 @@
version: '3'
services:
server:
ports:
- 5000:5000
@@ -0,0 +1,17 @@
version: '3'
services:
web:
deploy:
resources:
limits:
cpus: "1" # as opposed to 0.1 (default)
reservations:
cpus: "1"
environment:
- ERRORS=1
- HIDE_NGINX_HEADERS=0
- REMOVE_FILES=0
- RUN_SCRIPTS=1
- PHP_ERRORS_STDERR=1
- ENABLE_XDEBUG=1
@@ -0,0 +1 @@
First config
@@ -0,0 +1,15 @@
version: "3.3"
services:
other-toplevel-base:
image: nginx
volumes:
- firstvolume:/var/www/nginx
configs:
- source: firstconfig
target: /etc/nginx.conf
mode: 644
configs:
firstconfig:
file: ./first_config.txt
@@ -0,0 +1,20 @@
version: "3.3"
services:
other-toplevel-dev:
image: nginx
volumes:
- firstvolume:/var/www/nginx
configs:
- source: firstconfig
target: /etc/nginx.conf
mode: 644
volumes:
firstvolume:
driver_opts:
type: "nfs"
configs:
firstconfig:
file: ./first_config.txt
@@ -0,0 +1,19 @@
version: "3.3"
services:
other-toplevel-second:
image: nginx
volumes:
- secondvolume:/var/www/nginx
configs:
- source: secondconfig
target: /etc/nginx.conf
mode: 644
volumes:
secondvolume:
external: true
configs:
secondconfig:
file: ./second_config.txt
@@ -0,0 +1,9 @@
version: "3.3"
volumes:
firstvolume:
external: true
configs:
firstconfig:
file: ./second_config.txt
@@ -0,0 +1,90 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
},
"name": "web"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "web"
}
},
"strategy": {},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
},
"spec": {
"containers": [
{
"env": [
{
"name": "ENABLE_XDEBUG",
"value": "1"
},
{
"name": "ERRORS",
"value": "1"
},
{
"name": "HIDE_NGINX_HEADERS",
"value": "0"
},
{
"name": "PHP_ERRORS_STDERR",
"value": "1"
},
{
"name": "REMOVE_FILES",
"value": "0"
},
{
"name": "RUN_SCRIPTS",
"value": "1"
}
],
"image": "richarvey/nginx-php-fpm",
"imagePullPolicy": "",
"name": "web",
"resources": {
"limits": {
"cpu": "1"
},
"requests": {
"cpu": "1"
}
}
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": null
}
}
},
"status": {}
}
]
}
@@ -0,0 +1,150 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
}
},
"spec": {
"ports": [
{
"name": "3000",
"port": 3000,
"targetPort": 3000
},
{
"name": "5000",
"port": 5000,
"targetPort": 5000
}
],
"selector": {
"io.kompose.service": "server"
}
},
"status": {
"loadBalancer": {}
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "new-my-service"
},
"name": "new-my-service"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "new-my-service"
}
},
"strategy": {},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "new-my-service"
}
},
"spec": {
"containers": [
{
"image": "nginx",
"imagePullPolicy": "",
"name": "new-my-service",
"resources": {}
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": null
}
}
},
"status": {}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"name": "server"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "server"
}
},
"strategy": {},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
}
},
"spec": {
"containers": [
{
"image": "test",
"imagePullPolicy": "",
"name": "test-server",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 5000
}
],
"resources": {}
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": null
}
}
},
"status": {}
}
]
}
@@ -0,0 +1,100 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
}
},
"spec": {
"ports": [
{
"name": "3000",
"port": 3000,
"targetPort": 3000
},
{
"name": "5000",
"port": 5000,
"targetPort": 5000
}
],
"selector": {
"io.kompose.service": "server"
}
},
"status": {
"loadBalancer": {}
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"name": "server"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "server"
}
},
"strategy": {},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
}
},
"spec": {
"containers": [
{
"image": "test",
"imagePullPolicy": "",
"name": "test-server",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 5000
}
],
"resources": {}
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": null
}
}
},
"status": {}
}
]
}
@@ -0,0 +1,230 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
}
},
"spec": {
"ports": [
{
"name": "3000",
"port": 3000,
"targetPort": 3000
},
{
"name": "5000",
"port": 5000,
"targetPort": 5000
}
],
"selector": {
"io.kompose.service": "server"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "new-my-service",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "new-my-service"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"new-my-service"
],
"from": {
"kind": "ImageStreamTag",
"name": "new-my-service:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "new-my-service"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "new-my-service"
}
},
"spec": {
"containers": [
{
"name": "new-my-service",
"image": " ",
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "new-my-service",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "new-my-service"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "nginx"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"test_server"
],
"from": {
"kind": "ImageStreamTag",
"name": "server:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "server"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
}
},
"spec": {
"containers": [
{
"name": "test-server",
"image": " ",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 5000
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "test"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
}
]
}
@@ -0,0 +1,245 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "firstconfig",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-dev"
}
},
"data": {
"first_config.txt": "First config\n"
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-dev"
},
"name": "other-toplevel-dev"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "other-toplevel-dev"
}
},
"strategy": {
"type": "Recreate"
},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-dev"
}
},
"spec": {
"containers": [
{
"image": "nginx",
"imagePullPolicy": "",
"name": "other-toplevel-dev",
"resources": {},
"volumeMounts": [
{
"mountPath": "/etc/nginx.conf",
"name": "firstconfig",
"subPath": "nginx.conf"
},
{
"mountPath": "/var/www/nginx",
"name": "firstvolume"
}
]
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": [
{
"configMap": {
"defaultMode": 644,
"items": [
{
"key": "first_config.txt",
"path": "nginx.conf"
}
],
"name": "firstconfig"
},
"name": "firstconfig"
},
{
"name": "firstvolume",
"persistentVolumeClaim": {
"claimName": "firstvolume"
}
}
]
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "firstvolume",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "firstvolume"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "secondconfig",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-second"
}
},
"data": {
"second_config.txt": "Second config\n"
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-second"
},
"name": "other-toplevel-second"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "other-toplevel-second"
}
},
"strategy": {
"type": "Recreate"
},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-second"
}
},
"spec": {
"containers": [
{
"image": "nginx",
"imagePullPolicy": "",
"name": "other-toplevel-second",
"resources": {},
"volumeMounts": [
{
"mountPath": "/etc/nginx.conf",
"name": "secondconfig",
"subPath": "nginx.conf"
},
{
"mountPath": "/var/www/nginx",
"name": "secondvolume"
}
]
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": [
{
"configMap": {
"defaultMode": 644,
"items": [
{
"key": "second_config.txt",
"path": "nginx.conf"
}
],
"name": "secondconfig"
},
"name": "secondconfig"
},
{
"name": "secondvolume",
"persistentVolumeClaim": {
"claimName": "secondvolume"
}
}
]
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "secondvolume",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "secondvolume"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
}
]
}
@@ -0,0 +1,126 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "firstconfig",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-base"
}
},
"data": {
"second_config.txt": "Second config\n"
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-base"
},
"name": "other-toplevel-base"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "other-toplevel-base"
}
},
"strategy": {
"type": "Recreate"
},
"template": {
"metadata": {
"annotations": {
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "other-toplevel-base"
}
},
"spec": {
"containers": [
{
"image": "nginx",
"imagePullPolicy": "",
"name": "other-toplevel-base",
"resources": {},
"volumeMounts": [
{
"mountPath": "/etc/nginx.conf",
"name": "firstconfig",
"subPath": "nginx.conf"
},
{
"mountPath": "/var/www/nginx",
"name": "firstvolume"
}
]
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": [
{
"configMap": {
"defaultMode": 644,
"items": [
{
"key": "second_config.txt",
"path": "nginx.conf"
}
],
"name": "firstconfig"
},
"name": "firstconfig"
},
{
"name": "firstvolume",
"persistentVolumeClaim": {
"claimName": "firstvolume"
}
}
]
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "firstvolume",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "firstvolume"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
}
]
}
@@ -0,0 +1,244 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "server",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"annotations": {
"complexlabel": "override",
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"simplelabel.first": "Foo",
"simplelabel.second": "Bar"
}
},
"spec": {
"ports": [
{
"name": "3000",
"port": 3000,
"targetPort": 3000
},
{
"name": "5000",
"port": 5000,
"targetPort": 5000
}
],
"selector": {
"io.kompose.service": "server"
}
},
"status": {
"loadBalancer": {}
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"complexlabel": "override",
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"simplelabel.first": "Foo",
"simplelabel.second": "Bar"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
},
"name": "server"
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "server"
}
},
"strategy": {
"type": "Recreate"
},
"template": {
"metadata": {
"annotations": {
"complexlabel": "override",
"kompose.cmd": "%CMD%",
"kompose.version": "%VERSION%",
"simplelabel.first": "Foo",
"simplelabel.second": "Bar"
},
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server"
}
},
"spec": {
"containers": [
{
"env": [
{
"name": "NEW_ONE",
"value": "1234"
},
{
"name": "SAMPLE_TO_BE_OVERRIDDEN",
"value": "new"
},
{
"name": "SIMPLE_ONE",
"value": "true"
}
],
"image": "test",
"imagePullPolicy": "",
"name": "test-server",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 5000
}
],
"resources": {},
"volumeMounts": [
{
"mountPath": "/simple/base/volume",
"name": "server-claim0"
},
{
"mountPath": "/common/mount/point",
"name": "server-claim1"
},
{
"mountPath": "/additional/added/volume",
"name": "server-claim2"
},
{
"mountPath": "/base-tmpdir",
"name": "server-tmpfs0"
},
{
"mountPath": "/additional-tmpdir",
"name": "server-tmpfs1"
}
]
}
],
"restartPolicy": "Always",
"serviceAccountName": "",
"volumes": [
{
"name": "server-claim0",
"persistentVolumeClaim": {
"claimName": "server-claim0"
}
},
{
"name": "server-claim1",
"persistentVolumeClaim": {
"claimName": "server-claim1"
}
},
{
"name": "server-claim2",
"persistentVolumeClaim": {
"claimName": "server-claim2"
}
},
{
"emptyDir": {
"medium": "Memory"
},
"name": "server-tmpfs0"
},
{
"emptyDir": {
"medium": "Memory"
},
"name": "server-tmpfs1"
}
]
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "server-claim0",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server-claim0"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "server-claim1",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server-claim1"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "server-claim2",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "server-claim2"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
}
]
}
@@ -0,0 +1 @@
Second config
@@ -0,0 +1,27 @@
version: '3'
services:
server:
image: test
container_name: test_server
environment:
- SIMPLE_ONE=true
- SAMPLE_TO_BE_OVERRIDDEN=original
expose:
- "3000"
dns:
- 1.1.1.1
- 8.8.8.8
dns_search: first.search.domain.com
external_links:
- other_service_1
- common_service:alias1
labels:
- "simplelabel.first=Foo"
- "complexlabel=original"
tmpfs:
- /base-tmpdir
volumes:
- /simple/base/volume
- /base/dir:/common/mount/point
@@ -0,0 +1,24 @@
version: '3'
services:
server:
image: test
container_name: test_server
environment:
- SAMPLE_TO_BE_OVERRIDDEN=new
- NEW_ONE=1234
expose:
- "5000"
dns: 9.9.9.9
dns_search:
- second.search.domain.com
external_links:
- other_service_2
- common_service:alias2
labels:
simplelabel.second: "Bar"
complexlabel: override
tmpfs: /additional-tmpdir
volumes:
- /additional/added/volume
- /override/dir:/common/mount/point