Uploaded image for project: 'Red Hat OpenShift Dev Spaces (formerly CodeReady Workspaces) '
  1. Red Hat OpenShift Dev Spaces (formerly CodeReady Workspaces)
  2. CRW-1770

Installation jobs should dynamically obtain default checluster CR

XMLWordPrintable

    • False
    • False
    • Undefined
    • QE-2021-05-26 (Sprint: 202)

      Instead of having "hardcoded" whole checluster CR and use this in our installation jobs, we should somewhat dynamically obtain the latest version of default checluster CR and then possibly patch it according to the installation scenario.

      There are multiple ways of obtaining default checluster CR, but I would opt in for obtaining it directly from catalogsource image on the cluster like so (this snippet is from my WIP for installing in disconnected env, so it might need som tweaking for this use-case, like parameterize the catalogsource name for example):

      oc port-forward -n openshift-marketplace $(oc get pods -n openshift-marketplace -l olm.catalogSource=crw-disconnected-catalog -o name) 50051 &
                          PORT_FORWARD_PID=$!
                          # wait for container to run and be accessible 
                          touch tmp.txt
                          while ! grpcurl -plaintext -d '{"pkgName":"codeready-workspaces", "channelName":"latest"}' localhost:50051 api.Registry/GetBundleForChannel > tmp.txt ; do
                              sleep 0.1
                          done
      
                          # Get default checluster CR
                          grpcurl -plaintext -d '{"pkgName":"codeready-workspaces", "channelName":"latest"}' localhost:50051 api.Registry/GetBundleForChannel |jq -cr ".object" |jq -r ".[1]" |jq -r '.metadata.annotations["alm-examples"]'|jq ".[]" > checluster.json
      kill $PORT_FORWARD_PID
      

      Once we obtain checluster.json like this we are sure it's the "default" checluster CR from the catalogsource which is being used for installing CRW, then we can patch the CR with any options we need for any specific installation scenario like this (example with setting up proxy fields):

      oc patch --local -f checluster.json --type merge --patch "{\\"spec\\":{\\"server\\":{\\"proxyURL\\":\\"\${PROXY_URL}\\", \\"proxyPort\\":\\"\${PROXY_PORT}\\", \\"nonProxyHosts\\":\\"\${NON_PROXY_HOSTS}\\"}}}" -o yaml > checluster-patched.yaml
      

              oshmarai Shmaraiev Oleksandr
              rhopp@redhat.com Radim Hopp
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: