From 9ae483e82c8176313168beee5c331f071fb8ced0 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Mon, 15 Jan 2024 14:19:41 +0100 Subject: [PATCH] Migration from DeploymentConfig to Deployment For more information see https://docs.openshift.com/container-platform/4.12/applications/deployments/what-deployments-are.html Since OpenShift 4.14 DeploymentConfigs are deprecated. https://access.redhat.com/articles/7041372 Signed-off-by: Petr "Stone" Hracek --- .../templates/cakephp-mysql-persistent.json | 59 +++++-------------- openshift/templates/cakephp-mysql.json | 59 +++++-------------- openshift/templates/cakephp.json | 31 +++------- 3 files changed, 36 insertions(+), 113 deletions(-) diff --git a/openshift/templates/cakephp-mysql-persistent.json b/openshift/templates/cakephp-mysql-persistent.json index 763ea0e41..0c5137389 100644 --- a/openshift/templates/cakephp-mysql-persistent.json +++ b/openshift/templates/cakephp-mysql-persistent.json @@ -142,13 +142,14 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${NAME}", "annotations": { "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { @@ -166,27 +167,11 @@ } } }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "cakephp-mysql-persistent" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${NAME}" + "matchLabels": { + "name": "${NAME}" + } }, "template": { "metadata": { @@ -328,41 +313,25 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${DATABASE_SERVICE_NAME}", "annotations": { "description": "Defines how to deploy the database", - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mysql:${MYSQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { "strategy": { "type": "Recreate" }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mysql" - ], - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "mysql:${MYSQL_VERSION}" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${DATABASE_SERVICE_NAME}" + "matchLabels": { + "name": "${DATABASE_SERVICE_NAME}" + } }, "template": { "metadata": { diff --git a/openshift/templates/cakephp-mysql.json b/openshift/templates/cakephp-mysql.json index f879a6d88..b7f5f0043 100644 --- a/openshift/templates/cakephp-mysql.json +++ b/openshift/templates/cakephp-mysql.json @@ -142,13 +142,14 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${NAME}", "annotations": { "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { @@ -166,27 +167,11 @@ } } }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "cakephp-mysql-example" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${NAME}" + "matchLabels": { + "name": "${NAME}" + } }, "template": { "metadata": { @@ -311,41 +296,25 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${DATABASE_SERVICE_NAME}", "annotations": { "description": "Defines how to deploy the database", - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"mysql:${MYSQL_VERSION}\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { "strategy": { "type": "Recreate" }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "mysql" - ], - "from": { - "kind": "ImageStreamTag", - "namespace": "${NAMESPACE}", - "name": "mysql:${MYSQL_VERSION}" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${DATABASE_SERVICE_NAME}" + "matchLabels": { + "name": "${DATABASE_SERVICE_NAME}" + } }, "template": { "metadata": { diff --git a/openshift/templates/cakephp.json b/openshift/templates/cakephp.json index 32d403c3f..75b86f91a 100644 --- a/openshift/templates/cakephp.json +++ b/openshift/templates/cakephp.json @@ -139,40 +139,25 @@ } }, { - "kind": "DeploymentConfig", - "apiVersion": "apps.openshift.io/v1", + "kind": "Deployment", + "apiVersion": "apps/v1", "metadata": { "name": "${NAME}", "annotations": { "description": "Defines how to deploy the application server", - "template.alpha.openshift.io/wait-for-ready": "true" + "template.alpha.openshift.io/wait-for-ready": "true", + "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${NAME}:latest\"},\"fieldPath\": \"spec.template.spec.containers[0].image\"}]" } }, "spec": { "strategy": { - "type": "Rolling" + "type": "RollingUpdate" }, - "triggers": [ - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "cakephp-example" - ], - "from": { - "kind": "ImageStreamTag", - "name": "${NAME}:latest" - } - } - }, - { - "type": "ConfigChange" - } - ], "replicas": 1, "selector": { - "name": "${NAME}" + "matchLabels": { + "name": "${NAME}" + } }, "template": { "metadata": {