-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path3-capture-ocp-workloads.sh
executable file
·66 lines (63 loc) · 2.75 KB
/
3-capture-ocp-workloads.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/zsh
source envs.sh
kubectx ${context_src}
# Capture workload
for dc in $(./oc get dc -n $ns -o jsonpath='{.items[*].metadata.name}' ); do
echo "Exporting DeploymentConfigs: " $dc;
./oc get dc $dc -n $ns -o yaml \
| yq e 'del(.metadata.creationTimestamp)' - \
| yq e 'del(.metadata.annotations.*)' - \
| yq e 'del(.metadata.labels.template*)' - \
| yq e 'del(.metadata.labels.xpaas)' - \
| yq e 'del(.metadata.resourceVersion)' - \
| yq e 'del(.metadata.selfLink)' - \
| yq e 'del(.metadata.uid)' - \
| yq e 'del(.metadata.generation)' - \
| yq e 'del(.metadata.managedFields)' - \
| yq e 'del(.status)' - \
> ocp-manifests/namespaces/$ns/$dc-dc.yaml;
done
for route in $(./oc get route -n $ns -o jsonpath='{.items[*].metadata.name}' ); do
echo "Exporting Route: " $route;
./oc get route $route -n $ns -o yaml \
| yq e 'del(.metadata.creationTimestamp)' - \
| yq e 'del(.metadata.annotations.*)' - \
| yq e 'del(.metadata.labels.template*)' - \
| yq e 'del(.metadata.labels.xpaas)' - \
| yq e 'del(.metadata.resourceVersion)' - \
| yq e 'del(.metadata.selfLink)' - \
| yq e 'del(.metadata.managedFields)' - \
| yq e 'del(.metadata.uid)' - \
| yq e 'del(.status)' - \
> ocp-manifests/namespaces/$ns/$route-route.yaml
done
#imagestreams
for is in $(./oc get is -n $ns -o jsonpath='{.items[*].metadata.name}' ); do
echo "Exporting ImageStreams: " $is;
./oc get is $is -n $ns -o yaml \
| yq e 'del(.metadata.creationTimestamp)' - \
| yq e 'del(.metadata.annotations.*)' - \
| yq e 'del(.metadata.resourceVersion)' - \
| yq e 'del(.metadata.selfLink)' - \
| yq e 'del(.metadata.generation)' - \
| yq e 'del(.metadata.uid)' - \
> ocp-manifests/namespaces/$ns/$is-is.yaml
done;
#services
for service in $(./oc get service -n $ns -o jsonpath='{.items[*].metadata.name}' ); do
echo "Exporting service: " $service;
./oc get svc $service -n $ns -o yaml \
| yq e 'del(.metadata.creationTimestamp)' - \
| yq e 'del(.metadata.annotations.*)' - \
| yq e 'del(.metadata.labels.template*)' - \
| yq e 'del(.metadata.labels.xpaas)' - \
| yq e 'del(.metadata.resourceVersion)' - \
| yq e 'del(.metadata.selfLink)' - \
| yq e 'del(.metadata.uid)' - \
| yq e 'del(.metadata.managedFields)' - \
| yq e 'del(.status)' - \
| yq e 'del(.spec.clusterIP)' - \
| yq e 'del(.spec.clusterIPs)' - \
> ocp-manifests/namespaces/$ns/$service-service.yaml
done;
./shifter convert -f ./ocp-manifests/namespaces/$ns -t yaml -o ./kubernetes-manifests/namespaces/$ns