Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.

Conversation

@Avni-Sharma
Copy link
Contributor

@Avni-Sharma Avni-Sharma commented Apr 23, 2019

Refers 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

  1. sh consoledeveloper.sh
  2. oc login -u consoledeveloper -p developer
  3. 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.
You can enter the username as consoledeveloper and the password as developer here

… perspective

Refers https://jira.coreos.com/browse/ODC-347
The prerequisites for testing this are
export KUBECONFIG=<kubeconfig file>
export OC_LOGIN_PASSWORD=<kubeadmin login password>

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(roleinding being used here is `self-provisioner`)

After this you can login as the `consoledeveloper` user. Create a new project and do `oc get csvs` in the suitable namespace to see the installed operator.
Copy link
Collaborator

@rgarg1 rgarg1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script works fine @Avni-Sharma. Good job!

I was able to enable developer console on my OCP4 cluster hosted on AWS using this script. Since I already had the consoledeveloper user crreated prior, the script detected that duly and informed me of the same.

@@ -0,0 +1,16 @@
#!/bin/bash
set -x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is dumping all commands executed along with passwords on the terminal. May be set +x would be a better option here, even though this is going to be executed by kubeadmins.


oc apply -f ./yamls/unmanage.yaml
oc scale --replicas 0 deployment console-operator --namespace openshift-console-operator
sleep 20s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to let our customers use this script at any point? If yes then we should consider using conditional while loops instead of hard sleeps, as different environments may need different waits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we could have a loop here which checks if the console deployment in openshift-console namespace is updated to use the right image.

@baijum
Copy link
Collaborator

baijum commented Apr 24, 2019

How about creating a hack directory at top-level and moving these scripts under that. I have noticed the hack directory in many OpenShift and Kubernetes repositories.

@sbose78
Copy link
Member

sbose78 commented Apr 24, 2019

hack or install. Anything is good.

@baijum
Copy link
Collaborator

baijum commented Apr 24, 2019

hack or install. Anything is good.

How about creating a hack directory and within that install directory?

#!/bin/bash
set +x
OC_LOGIN_USERNAME=kubeadmin
oc login -u ${OC_LOGIN_USERNAME} -p ${OC_LOGIN_PASSWORD}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why login? Why not use KUBECONFIG?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this as well.. thanks Baiju :)

sleep 10s
oc create clusterrolebinding ${USERNAME}_role --clusterrole=self-provisioner --user=${USERNAME}
sleep 15s
oc login -u ${USERNAME} -p ${USERPASS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be wrong to have the script login with a different user than what the user had initially started as. I would suggest that we only print out the command to login with the user.

do
sleep 1s
done
oc scale --replicas 1 deployment console --namespace openshift-console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a loop which checks if the deploymentconfig/console has got updated with the new image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no deploymentconfig as such... just the deployment and when we apply that redeploy file then the image is there. (The new-image is already there in the yaml..it is not being replaced)

Copy link
Member

@sbose78 sbose78 Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to imply deployment/console :)

You are redeploying the deployment/console-operator not deployment/console. On re-deploying deployment/console-operator, the operator should update deployment/console's image which could take a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the redeployment the pod for this console-operator comes up. After this step the devconsole.sh script is called. So till the catalogsource and subscription is being applied that pod comes up and these two are kind of independent. so i thought of not putting it there. For pulling the latest image though I have a new commit which changes the imagePullPolicy to Always in the desired yaml and also does some changes in the consoledeveloper.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Avni-Sharma could you share the link to the workaround please? If there's an issue I would like to point people towards it every time they hit the bug.

@rgarg1
Copy link
Collaborator

rgarg1 commented Apr 25, 2019

@Avni-Sharma The scripts work only partially for me on OCP4 cluster hosted on AWS. Here are the logs, please notice the error messages:

sh consoledeveloper.sh 
Login successful.

You have access to the following projects and can switch between them with 'oc project <projectname>':

  * default
    kube-public
    kube-system
    openshift
    openshift-apiserver
    openshift-apiserver-operator
    openshift-authentication
    openshift-authentication-operator
    openshift-cloud-credential-operator
    openshift-cluster-machine-approver
    openshift-cluster-node-tuning-operator
    openshift-cluster-samples-operator
    openshift-cluster-storage-operator
    openshift-cluster-version
    openshift-config
    openshift-config-managed
    openshift-console
    openshift-console-operator
    openshift-controller-manager
    openshift-controller-manager-operator
    openshift-dns
    openshift-dns-operator
    openshift-image-registry
    openshift-infra
    openshift-ingress
    openshift-ingress-operator
    openshift-kube-apiserver
    openshift-kube-apiserver-operator
    openshift-kube-controller-manager
    openshift-kube-controller-manager-operator
    openshift-kube-scheduler
    openshift-kube-scheduler-operator
    openshift-machine-api
    openshift-machine-config-operator
    openshift-marketplace
    openshift-monitoring
    openshift-multus
    openshift-network-operator
    openshift-node
    openshift-operator-lifecycle-manager
    openshift-operators
    openshift-sdn
    openshift-service-ca
    openshift-service-ca-operator
    openshift-service-catalog-apiserver-operator
    openshift-service-catalog-controller-manager-operator

Using project "default".
Warning: oc apply should be used on resource created by either oc create --save-config or oc apply
clusterversion "version" configured
deployment "console-operator" scaled
deployment "console" scaled
Warning: oc apply should be used on resource created by either oc create --save-config or oc apply
deployment "console-operator" configured
No resources found.
deployment "console" scaled
**Error: unknown command "api-versions" for "oc"**
Run 'oc --help' for usage.
Running Openshift Version 4.x 


 Installing DevConsole Operator... 


 Installing Catalog Source... 

catalogsource "my-catalog" created

 Waiting for catalog source to get installed before creating subscription 


 Creating Subscription... 

subscription "my-devconsole" created
No resources found.
Adding password for user consoledeveloper
secret "htpasswd-consoledeveloper-secret" created
Warning: oc apply should be used on resource created by either oc create --save-config or oc apply
oauth "cluster" configured
clusterrolebinding "consoledeveloper_role" created
**Login failed (401 Unauthorized)
Verify you have provided correct credentials.**

@rgarg1
Copy link
Collaborator

rgarg1 commented Apr 25, 2019

@Avni-Sharma

Despite the errors, I could login using the developerconsole user and I could also see the perspective.

Removing login through oc command. Instead using kubeconfig file.
Prompting the user with credentials for login as a non admin user, instead of logging in through the script.
@Avni-Sharma
Copy link
Contributor Author

@Avni-Sharma

Despite the errors, I could login using the developerconsole user and I could also see the perspective.

Hi Ruchir.
Instead of logging in through the script, we would be just prompting the user with the credentials as suggested by @sbose78

@Avni-Sharma
Copy link
Contributor Author

/test lint

1 similar comment
@Avni-Sharma
Copy link
Contributor Author

/test lint

@openshift-ci-robot
Copy link
Collaborator

New changes are detected. LGTM label has been removed.

env:
- name: IMAGE
value: quay.io/redhat-developer/console:master-next
imagePullPolicy: Always
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this - this looks mandatory and I had missed it in my review.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would have got deleted when

oc scale --replicas 0 deployment console --namespace openshift-console

was done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah..but regarding this - If you are already using the quay.io/redhat-developer/console:master-next image and the image has been updated, the deployment doesn't naturally pull the updated image. So to be really sure that it is the new image we can delete the existing one. Because it's a Deployment, Kubernetes will automatically recreate the pod and pull the latest image.

@baijum
Copy link
Collaborator

baijum commented Apr 30, 2019

hack or install. Anything is good.

How about creating a hack directory and within that install directory?

@Avni-Sharma Can you create a hack directory and move the install_devconsole directory (not individual files) under that?

@sbose78
Copy link
Member

sbose78 commented Apr 30, 2019

Screen Shot 2019-04-30 at 12 12 51 AM

While importing an application as consoledeveloper , I found out that the above error happened.
This happened because consoledeveloper didn't have view on the openshift namespace.

@sbose78
Copy link
Member

sbose78 commented Apr 30, 2019

The output doesn't get printed properly on my mac terminal

-e 
\e[1;35m User consoledeveloper created with the password developer. Type the below\e[0m 

-e 
\e[1;32m oc login -u\e[3m \e[1;36mconsoledeveloper\e[0m \e[1;32m-p\e[3m \e[1;36mdeveloper\e[0m 

@rohitkrai03
Copy link

@sbose78 On my mac terminal the output looks fine with colors and all.

➜  ~ echo -e "\n\e[1;32m oc login -u\e[3m \e[1;36mconsoledeveloper\e[0m \e[1;32m-p\e[3m \e[1;36mdeveloper\e[0m \n"

 oc login -u consoledeveloper -p developer 

➜  ~ echo -e "\n\e[1;35m User consoledeveloper created with the password developer. Type the below\e[0m \n"

 User consoledeveloper created with the password developer. Type the below 

➜  ~ echo -e "\n\e[1;35m User consoledeveloper created with the password developer. Type the below\e[0m \n"

 User consoledeveloper created with the password developer. Type the below 

@Avni-Sharma
Copy link
Contributor Author

/test lint


sleep 10s
oc create clusterrolebinding ${USERNAME}_role --clusterrole=self-provisioner --user=${USERNAME}
oc adm policy add-role-to-user view ${USERNAME}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this view only on the openshift namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in all namespaces

The builder image in the Import Flow will now work.
@sbose78
Copy link
Member

sbose78 commented May 1, 2019

/retest

@rgarg1
Copy link
Collaborator

rgarg1 commented May 2, 2019

@Avni-Sharma The command oc api-versions is dependent on version of the oc utility installed on the client system. For example, this command will fail if the version installed on the system is v3.9.0, but works with latest v4.1.0. You should add this limitation to the list of pre-requisites.

@Avni-Sharma
Copy link
Contributor Author

@rgarg1 This is only for v4. We are just exporting the kubeconfig for logging in(mentioned in the description above)) instead of the command oc login which is only possible in v4. so it is assumed that it is for the latest one..However, we can add it as well :)

@baijum
Copy link
Collaborator

baijum commented May 2, 2019

Please add a README.md. The content used for PR description would be fine.

@baijum
Copy link
Collaborator

baijum commented May 2, 2019

@Avni-Sharma (nitpick) Can you format the README.md with better Markdown syntax: https://www.markdownguide.org/basic-syntax

@sbose78
Copy link
Member

sbose78 commented May 2, 2019

Let's merge this.

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baijum, sbose78

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@baijum
Copy link
Collaborator

baijum commented May 2, 2019

I had some changes to README: https://paste.gnome.org/pv37d2syt
I can send a separate PR.

@sbose78 sbose78 merged commit 446a075 into redhat-developer:master May 2, 2019
akashshinde added a commit to akashshinde/devopsconsole-operator that referenced this pull request May 3, 2019
* upstream/master:
  Set registry log (redhat-developer#176)
  Non-admin user viewing the console with developer console perspective (redhat-developer#136)
  Use the base image available in the OpenShift CI (redhat-developer#175)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants