From de7945b69ef9c1f05c694a33f528c798745d33d1 Mon Sep 17 00:00:00 2001 From: Alberto Bellotti Date: Wed, 27 Mar 2024 21:24:12 -0400 Subject: [PATCH] doc: Updated the README.md to mention the pull secret - Included the create_pull_secret.sh script with registry.redhat.io default. - Updated and reorganized the README.md for the CLI usage. --- README.md | 62 ++++++++++++++++++++++++++------------- bin/create_pull_secret.sh | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 20 deletions(-) create mode 100755 bin/create_pull_secret.sh diff --git a/README.md b/README.md index 266be90..c57a43e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Discovery Helm Chart Repository (downstream) +# Discovery Helm Chart Repository This Helm repository contains the helm charts for the RedHat Discovery product. @@ -30,26 +30,15 @@ Within a minute or so then the Discovery Helm Chart will appear in the OpenShift ## Installing Discovery using the Helm CLI Altenatively, one can download a specific version of the Helm Chart from this repo and install Discovery by using the Helm CLI. -First look at the chart index in this repo to determine which helm chart version to download. -In [Chart Index](https://quipucords.github.io/discovery-helm-repo/charts/index.yaml), find the Helm Chart `version` that reflects the desired `appVersion` of Discovery. -For example, you can see Helm Chart version `0.9.2` pulls in Discovery `1.5.3`. - -Then download the appropriate +First, login to the OpenShift cluster and create a project for running discovery. For these examples we will use `discovery-qe`: ``` -$ mkdir -p ~/discovery-helm -$ cd ~/discovery-helm -$ curl -k https://quipucords.github.io/discovery-helm-repo/charts/discovery-0.9.2.tgz \ - --output discovery-0.9.2.tgz -$ tar -xzf discovery-0.9.2.tgz -$ ls -FC -discovery/ discovery-0.9.2.tgz +$ oc login https://api.:6443 -u kubeadmin -p +$ oc new-project discovery-qe ``` -The downloaded and extracted Discovery helm chart 0.9.2 will be in the `discovery` directory - -To deploy to your OpenShift cluster, first make sure the Helm CLI is installed: +Next, make sure the Helm CLI is installed: On Mac: @@ -59,14 +48,47 @@ $ brew install helm For all others, please visit [https://helm.sh/docs/intro/install/]() -First, login to the OpenShift cluster and set your working project, for these examples we will use `discovery-qe`: +For downloading the Discovery image, you need to create a `discovery-pull-secret` that has the credentials needed to access `registry.redhat.io`. The secret can be created using `oc create secret ...` or by using the helper script provided here: ``` -$ oc login https://api.:6443 -u kubeadmin -p -$ oc project discovery-qe +$ mkdir ~/bin +$ curl -k https://quipucords.github.io/discovery-helm-repo/bin/create_pull_secret.sh \ + --output ~/bin/create_pull_secret.sh +$ chmod 755 ~/bin/create_pull_secret.sh +$ create_pull_secret.sh "discovery-pull-secret" + +Registry server - registry.redhat.io: +Registry username - : +Registry password: .... +Registry user e-mail - : + +Add another docker server (y/n)?n +Creating pull secret discovery-pull-secret ... +secret/discovery-pull-secret created +$ +``` + + +Next, look at the chart index in this repo to determine which helm chart version to download. +In [Chart Index](https://quipucords.github.io/discovery-helm-repo/charts/index.yaml), find the Helm Chart `version` that reflects the desired `appVersion` of Discovery. + +For example, you can see Helm Chart version `0.9.2` pulls in Discovery `1.5.3`. + +Then download the appropriate + +``` +$ mkdir -p ~/discovery-helm +$ cd ~/discovery-helm +$ curl -k https://quipucords.github.io/discovery-helm-repo/charts/discovery-0.9.2.tgz \ + --output discovery-0.9.2.tgz +$ tar -xzf discovery-0.9.2.tgz +$ ls -FC +discovery/ discovery-0.9.2.tgz ``` -Then, install discovery using the Helm CLI: +The downloaded and extracted Discovery helm chart 0.9.2 will be in the `discovery` directory + +Finally, install discovery using the Helm CLI: ``` $ helm install discovery ./discovery --set server.password="EXAMPLE-superadmin1" diff --git a/bin/create_pull_secret.sh b/bin/create_pull_secret.sh new file mode 100755 index 0000000..47c3209 --- /dev/null +++ b/bin/create_pull_secret.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Helper script to create a pull secret with one or more registry servers. +# +if [ $# -ne 1 ]; then + echo "Usage: ${0} " + exit 1 +fi + +pull_secret="${1}" +config_json='{"auths":{}}' + +while : +do + default="registry.redhat.io" + echo + reg_server=$(read -p "Registry server - $default: " server; echo $server) + reg_server=${reg_server:-$default} + + default="$(whoami)" + reg_username=$(read -p "Registry username - $default: " username; echo $username) + reg_username=${reg_username:-$default} + + reg_password=$(read -s -p "Registry password: " pwd; echo $pwd) + stty echoe; echo + + default="${reg_username}" + [[ ! "${default}" =~ "@" ]] && default="${default}@redhat.com" + + reg_email=$(read -p "Registry user e-mail - $default: " email; echo $email) + reg_email=${reg_email:-$default} + + config_json=`echo ${config_json} | jq ".auths += {\"${reg_server}\":{\"username\":\"${reg_username}\",\"password\":\"${reg_password}\",\"email\":\"${reg_email}\"}}"` + + echo + another=$(read -p "Add another registry server (y/n)?" ans; echo $ans) + if [ ! "${another}" = "y" ]; then + break + fi +done + +config_json_file="$(mktemp)" +echo -n "${config_json}" > "${config_json_file}" +echo +echo "Creating pull secret ${pull_secret} ..." +oc delete secret/${pull_secret} --ignore-not-found=true +oc create secret generic ${pull_secret} \ + --from-file=.dockerconfigjson="${config_json_file}" \ + --type=kubernetes.io/dockerconfigjson +rm -f "${config_json_file}" +