diff --git a/hack/install_devconsole/README.md b/hack/install_devconsole/README.md new file mode 100644 index 0000000..1938821 --- /dev/null +++ b/hack/install_devconsole/README.md @@ -0,0 +1,25 @@ +##Non-admin user viewing the console with developer console perspective + +Refers [https://jira.coreos.com/browse/ODC-347](https://jira.coreos.com/browse/ODC-347) + +This PR provides a script to install + +the latest console with the developer perspective, and +the devconsole operator needed to enable the perspective. +The prerequisites for testing this are +export KUBECONFIG=kubeconfig file + +Run the script consoledeveloper.sh +It does the following: +1. Replaces the existing openshift console with the talamer console +2. Installs the operator. (Prompts if it already exists) +3. Creates a non-admin user consoledeveloper with the password as developer with the suitable rolebinding(rolebinding being used here is self-provisioner and view) + +Steps to test this + +`sh consoledeveloper.sh` +oc login -u `consoledeveloper` -p `developer` +Logging in as the consoledeveloper user, you can now create a new project and do oc get csvs in the suitable namespace to see the installed operator. +Expected Output- +On the UI you can now see a consoledeveloper user under the kubeadmin option. +You can enter the username as consoledeveloper and the password as developer here. diff --git a/hack/install_devconsole/consoledeveloper.sh b/hack/install_devconsole/consoledeveloper.sh new file mode 100644 index 0000000..441d744 --- /dev/null +++ b/hack/install_devconsole/consoledeveloper.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set +x + +oc apply -f ./yamls/unmanage.yaml +oc scale --replicas 0 deployment console-operator --namespace openshift-console-operator +oc scale --replicas 0 deployment console --namespace openshift-console +oc apply -f ./yamls/redeploy-console-operator.yaml +#It takes time to get the pod in running state +while [ "$(oc get pods --field-selector=status.phase=Running -n openshift-console-operator)" == "No resources found." ] +do + sleep 1s +done + +oc scale --replicas 1 deployment console --namespace openshift-console +#Delete the already existing pod in the openshift-console namespace +#Because it's a Deployment, Kubernetes will automatically recreate the pod and pull the latest image. +#Have also updated the image pull policy to Always in the yamls/redeploy-console-operator.yaml + +CONSOLE_POD="$(oc get pods -o=name -n openshift-console | cut -d'/' -f2- | cut -f 1 -d "-" | head -n 1)" +CONSOLE_POD_NAME="$(oc get pods -o=name -n openshift-console | cut -d'/' -f2- | cut -d'-' -f1- | head -n 1)" +if echo "${CONSOLE_POD}" == "console";then + oc delete pod ${CONSOLE_POD_NAME} -n openshift-console +fi +sh ./devconsole.sh +sh ./create_user.sh diff --git a/hack/install_devconsole/create_user.sh b/hack/install_devconsole/create_user.sh new file mode 100644 index 0000000..099d0c2 --- /dev/null +++ b/hack/install_devconsole/create_user.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +HTPASSWD_FILE="./htpass" +USERNAME="consoledeveloper" +USERPASS="developer" +HTPASSWD_SECRET="htpasswd-consoledeveloper-secret" + +OC_USERS_LIST="$(oc get users)" +if echo "${OC_USERS_LIST}" | grep -q "${USERNAME}"; then + echo -e "\n\033[0;32m \xE2\x9C\x94 User consoledeveloper already exists \033[0m\n" + exit; +fi +htpasswd -cb $HTPASSWD_FILE $USERNAME $USERPASS + +oc get secret $HTPASSWD_SECRET -n openshift-config &> /dev/null + +oc create secret generic ${HTPASSWD_SECRET} --from-file=htpasswd=${HTPASSWD_FILE} -n openshift-config + +oc apply -f - <