Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions hack/install_devconsole/README.md
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 25 additions & 0 deletions hack/install_devconsole/consoledeveloper.sh
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions hack/install_devconsole/create_user.sh
Original file line number Diff line number Diff line change
@@ -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 - <<EOF
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: consoledeveloper
challenge: true
login: true
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: ${HTPASSWD_SECRET}
EOF

sleep 10s
oc create clusterrolebinding ${USERNAME}_role1 --clusterrole=self-provisioner --user=${USERNAME}
oc create clusterrolebinding ${USERNAME}_role2 --clusterrole=view --user=${USERNAME}
sleep 15s
echo -e "\n\e[1;35m User consoledeveloper created with the password developer. Type the below\e[0m \n"
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"
15 changes: 15 additions & 0 deletions hack/install_devconsole/devconsole.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

if oc api-versions | grep -q 'devconsole.openshift.io'; then
echo -e "\n\033[0;32m \xE2\x9C\x94 Devconsole Operator is already installed \033[0m\n"
else
echo -e "Running Openshift Version 4.x \n"
echo -e "\n Installing DevConsole Operator... \n"
echo -e "\n Installing Catalog Source... \n"
oc apply -f ./yamls/catalog_source_OS4.yaml
echo -e "\n Waiting for catalog source to get installed before creating subscription \n"
sleep 60s
echo -e "\n Creating Subscription... \n"
oc apply -f ./yamls/subscription_OS4.yaml
sleep 5s
fi
11 changes: 11 additions & 0 deletions hack/install_devconsole/yamls/catalog_source_OS4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ref. https://github.com/operator-framework/operator-lifecycle-manager
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: my-catalog
namespace: openshift-operator-lifecycle-manager
spec:
sourceType: grpc
image: quay.io/redhat-developer/operator-registry:latest
displayName: Community Operators
publisher: Red Hat
61 changes: 61 additions & 0 deletions hack/install_devconsole/yamls/redeploy-console-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: console-operator
namespace: openshift-console-operator
spec:
replicas: 1
selector:
matchLabels:
name: console-operator
template:
metadata:
labels:
name: console-operator
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
priorityClassName: system-cluster-critical
serviceAccountName: console-operator
containers:
- name: console-operator
image: docker.io/openshift/origin-console-operator:latest
ports:
- containerPort: 60000
name: metrics
command:
- console
- operator
args:
- "-v=4"
- "--create-default-console=true"
# 04-config.yaml provides this config for the operator
- "--config=/var/run/configmaps/config/controller-config.yaml"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /var/run/configmaps/config
name: config
env:
- name: IMAGE
value: quay.io/redhat-developer/console:master-next
imagePullPolicy: Always
- name: RELEASE_VERSION
value: "0.0.1-snapshot"
- name: OPERATOR_NAME
value: "console-operator"
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
resources:
requests:
memory: "100Mi"
cpu: "10m"
volumes:
- name: config
configMap:
name: console-operator-config
11 changes: 11 additions & 0 deletions hack/install_devconsole/yamls/subscription_OS4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ref. https://github.com/operator-framework/operator-lifecycle-manager
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: my-devconsole
namespace: openshift-operators
spec:
channel: alpha
name: devconsole
source: my-catalog
sourceNamespace: openshift-operator-lifecycle-manager
11 changes: 11 additions & 0 deletions hack/install_devconsole/yamls/unmanage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: config.openshift.io/v1
kind: ClusterVersion
metadata:
namespace: openshift-cluster-version
name: version
spec:
overrides:
- kind: Deployment
name: console-operator
namespace: openshift-console-operator
unmanaged: true