DEV Community

Cover image for How to manage Users & Project in Openshift?
Sagar Jadhav
Sagar Jadhav

Posted on • Edited on • Originally published at developersthought.in

3

How to manage Users & Project 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
Enter fullscreen mode Exit fullscreen mode

Create file to store user & password

touch passwordfile 
Enter fullscreen mode Exit fullscreen mode

Step 3: List projects

oc projects
Enter fullscreen mode Exit fullscreen mode

Step 4: Create project

oc new-project my-project
Enter fullscreen mode Exit fullscreen mode

Step 5: Create users

oc create user project-admin
Enter fullscreen mode Exit fullscreen mode
htpasswd -b passwordfile project-admin pwd
Enter fullscreen mode Exit fullscreen mode
oc create user project-developer
Enter fullscreen mode Exit fullscreen mode
htpasswd -b passwordfile project-developer pwd
Enter fullscreen mode Exit fullscreen mode

Step 6: Add admin role to user

oc policy add-role-to-user admin project-admin
Enter fullscreen mode Exit fullscreen mode

Step 7: Add developer role to user

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

Step 8: List role bindings

oc get rolebindings
Enter fullscreen mode Exit fullscreen mode

Step 9: Deploy application

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

Step 10: List pods

oc get pods
Enter fullscreen mode Exit fullscreen mode

Step 11: View application logs

oc logs <POD_NAME>
Enter fullscreen mode Exit fullscreen mode

Step 12: Create service account

oc create sa useroot
Enter fullscreen mode Exit fullscreen mode

Step 13: Add scc anyuid to service account

 oc adm policy add-scc-to-user anyuid -z useroot --as system:admin
Enter fullscreen mode Exit fullscreen mode

Step 14: Patch DC with service account

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

Step 15: Browse application

oc get pods -o wide
Enter fullscreen mode Exit fullscreen mode
curl http://<POD_IP>:80
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Image of Bright Data

Maintain Seamless Data Collection – No more rotating IPs or server bans.

Avoid detection with our dynamic IP solutions. Perfect for continuous data scraping without interruptions.

Avoid Detection

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay