loading...
Cover image for How to manage Users & Project in Openshift?

How to manage Users & Project in Openshift?

sagarjadhv23 profile image Sagar Jadhav Updated on ・1 min read

OpenShift Essentials (8 Part Series)

1) How to manage Users & Project in Openshift? 2) How to create route in OpenShift? 3 ... 6 3) How to scale an application in OpenShift? 4) How to use Persistent Storage in OpenShift? 5) How to deploy application using Source to Image (S2I) in OpenShift? 6) How to monitor application using probes in OpenShift? 7) How to limit resources using Quotas & Limit Ranges in OpenShift? 8) How to deploy an application using Templates in OpenShift?

Objective

  • Create project my-project
  • Create 2 Users project-admin & project-developer
  • Assign admin role to user project-admin in project my-project
  • Assign developer role to user project-developer in project my-project

Step 1: Set up OpenShift environment

Go to Katacoda.com & click on start scenario

Step 2: Set up utility

Install httpd tools

yum install httpd-tools

Create file to store user & password

touch passwordfile 

Step 3: List projects

oc projects

Step 4: Create project

oc new-project my-project

Step 5: Create users

oc create user project-admin
htpasswd -b passwordfile project-admin pwd
oc create user project-developer
htpasswd -b passwordfile project-developer pwd

Step 6: Add admin role to user

oc policy add-role-to-user admin project-admin

Step 7: Add developer role to user

oc login -u project-admin -p pwd <SERVER_URL>
oc policy add-role-to-user edit project-developer

Step 8: List role bindings

oc get rolebindings

Step 9: Deploy application

oc login -u project-developer -p pwd <SERVER_URL>
oc new-app --name nginx -l app=demo --docker-image nginx:latest

Step 10: List pods

oc get pods

Step 11: View application logs

oc logs <POD_NAME>

Step 12: Create service account

oc create sa useroot

Step 13: Add scc anyuid to service account

 oc adm policy add-scc-to-user anyuid -z useroot --as system:admin

Step 14: Patch DC with service account

 oc get dc
oc patch dc/nginx --patch \
'{"spec":{"template":{"spec":{"serviceAccountName": "useroot"}}}}'
oc get pods --watch

Step 15: Browse application

oc get pods -o wide
curl http://<POD_IP>:80

OpenShift Essentials (8 Part Series)

1) How to manage Users & Project in Openshift? 2) How to create route in OpenShift? 3 ... 6 3) How to scale an application in OpenShift? 4) How to use Persistent Storage in OpenShift? 5) How to deploy application using Source to Image (S2I) in OpenShift? 6) How to monitor application using probes in OpenShift? 7) How to limit resources using Quotas & Limit Ranges in OpenShift? 8) How to deploy an application using Templates in OpenShift?

Posted on by:

sagarjadhv23 profile

Sagar Jadhav

@sagarjadhv23

Backend Developer (Cloud ☁️) | Cloud Technology Enthusiast (🐳 ☸) Redhat Certified OpenShift Administrator

Discussion

markdown guide