For this scenario, im trying to migrate replicationcontroller (RC) between two OCP with different version. One OCP is on version 3.x, while the other one is 4.x.
So, it’s actually quite tricky. This is the first method that im doing, a simple export on OCP 3
oc get rc -o yaml -n projectname --export > rc.yaml
And do a simple import on OCP 4
oc create -n projectname -f rc.yaml
But there are some error happens,
Error from server (Forbidden): replicationcontrollers "rc-1" is forbidden: cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on: no RBAC policy matched, <nil>
It seems like despite im using –export parameter, somehow still exporting the previous DC uid on rc.yaml
labels:
app: HelloWorld
group: com.redhat.edw
openshift.io/deployment-config.name: helloworld
provider: fabric8
version: "1.0"
name: helloworld-5
namespace: project
ownerReferences:
- apiVersion: apps.openshift.io/v1
blockOwnerDeletion: true
controller: true
kind: DeploymentConfig
name: helloworld
uid: 8a96de62-9be4-11ea-a05c-0a659b38d468
resourceVersion: "65350349"
selfLink: /api/v1/namespaces/project/replicationcontrollers/helloworld-5
uid: 257eda84-9be7-11ea-a05c-0a659b38d468
The solution is by removing ownerReferences tag from yaml,
sed -i '/ownerReferences/,+6 d' rc.yaml
It will regenerate ownerReference tag once successfully imported to a new project.
But another problem arise. It seems like despite i’ve successfully import all my RCs, they are not showing when i do a oc get rc command. The culprit is revisionHistoryLimit, removing it from our dc solve this problem.
oc patch dc helloworld -n project --type json --patch '[{ "op": "remove", "path": "/spec/revisionHistoryLimit" }]'