forked from waynedovey/ocp4-vsphere-upi-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisconnected-operators.sh
executable file
·115 lines (94 loc) · 4.83 KB
/
disconnected-operators.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# Cleanup:
rm -fr redhat-operators-manifests postinstall/catalogsource.yaml
# Exports - required environment variables:
export OCP_RELEASE=4.3.5-x86_64
export LOCAL_REGISTRY='quay.ocp4.gsslab.brq.redhat.com:443'
export LOCAL_REPOSITORY='openshift/ocp4.3.5-x86_64'
export PRODUCT_REPO='openshift-release-dev'
export LOCAL_SECRET_JSON='/root/.docker/config.json'
export RELEASE_NAME="ocp-release"
# Log in to gsslab's local Quay:
docker login -u="openshift+openshift" -p="P276A6HFEGCN3D8857C3TSXQQWRI0P047H1TYCY0YJ8HYCDDQJ7LHZYQ57R2C3PY" quay.ocp4.lab.gsslab.pek2.redhat.com
docker login -u="openshift+openshift" -p="P276A6HFEGCN3D8857C3TSXQQWRI0P047H1TYCY0YJ8HYCDDQJ7LHZYQ57R2C3PY" quay.ocp4.lab.gsslab.pek2.redhat.com:443
# Mirror the repository:
# This command pulls the release information as a digest, and its output includes the imageContentSources data that you require when you install your cluster.
oc adm -a ${LOCAL_SECRET_JSON} release mirror \
--from=quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE} \
--to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} \
--to-release-image=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE} \
--insecure=true
# Example:
# imageContentSources:
# - mirrors:
# - quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ocp4.3.5-x86_64
# source: quay.io/openshift-release-dev/ocp-release
# - mirrors:
# - quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ocp4.3.5-x86_64
# source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
# Create Operator Lifecycle Manager (OLM):
oc adm catalog build \
--appregistry-endpoint https://quay.io/cnr \
--appregistry-org redhat-operators \
--to=${LOCAL_REGISTRY}/openshift/redhat-operators:v1
oc patch OperatorHub cluster --type json \
-p '[{"op": "add", "path": "/spec/disableAllDefaultSources", "value": true}]'
oc adm catalog mirror \
${LOCAL_REGISTRY}/openshift/redhat-operators:v1 \
${LOCAL_REGISTRY}/openshift
oc apply -f ./redhat-operators-manifests
cat << EOF >postinstall/catalogsource.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: my-redhat-operators-catalog
namespace: openshift-marketplace
spec:
sourceType: grpc
image: ${LOCAL_REGISTRY}/openshift/redhat-operators:v1
displayName: My Red Hat Operator Catalog
publisher: grpc
EOF
oc create -f postinstall/catalogsource.yaml
# Create custom resources:
rm -fr olm-4.3
postinstall/get-operator-package.sh
cd olm-4.3/manifests/redhat-operators/cluster-logging/cluster-logging-*
# Replace the default registry with the Quay local registry:
sed -i 's|registry.redhat.io/openshift4|quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift|' */cluster-logging*.clusterserviceversion.yaml
# Remove `replaces` line as we only have one version:
sed -i '/replaces/'d */cluster-logging*.clusterserviceversion.yaml
# Check if it was correct:
cat */cluster-logging*.clusterserviceversion.yaml | grep quay.ocp4.lab.gsslab.pek2.redhat.com
oc image mirror registry.redhat.io/openshift4/ose-cluster-logging-operator quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ose-cluster-logging-operator
oc image mirror registry.redhat.io/openshift4/ose-logging-curator5 quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ose-logging-curator5
oc image mirror registry.redhat.io/openshift4/ose-logging-elasticsearch5 quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ose-logging-elasticsearch5
oc image mirror registry.redhat.io/openshift4/ose-logging-fluentd quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ose-logging-fluentd
oc image mirror registry.redhat.io/openshift4/ose-oauth-proxy quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/ose-oauth-proxy
cat <<EOF > Dockerfile.olm
FROM registry.redhat.io/openshift4/ose-operator-registry:latest as builder
COPY olm-4.3/manifests/redhat-operators/cluster-logging/cluster-logging-vk69sqz9 manifests
RUN /bin/initializer -o ./bundles.db
FROM registry.redhat.io/ubi8/ubi-minimal:latest
COPY --from=builder /registry/bundles.db /bundles.db
COPY --from=builder /usr/bin/registry-server /registry-server
COPY --from=builder /usr/bin/grpc_health_probe /bin/grpc_health_probe
EXPOSE 50051
ENTRYPOINT ["/registry-server"]
CMD ["--database", "bundles.db"]
EOF
podman login -u="openshift+openshift" -p="P276A6HFEGCN3D8857C3TSXQQWRI0P047H1TYCY0YJ8HYCDDQJ7LHZYQ57R2C3PY" quay.ocp4.lab.gsslab.pek2.redhat.com
podman login -u="openshift+openshift" -p="P276A6HFEGCN3D8857C3TSXQQWRI0P047H1TYCY0YJ8HYCDDQJ7LHZYQ57R2C3PY" quay.ocp4.lab.gsslab.pek2.redhat.com:443
podman build -f Dockerfile.olm -t ${LOCAL_REGISTRY}/openshift/custom-registry .
podman push ${LOCAL_REGISTRY}/openshift/custom-registry
cat <<EOF | oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: my-operator-catalog
namespace: openshift-marketplace
spec:
displayName: My Operator Catalog
sourceType: grpc
image: quay.ocp4.lab.gsslab.pek2.redhat.com:443/openshift/custom-registry:latest
EOF