commands Flashcards
Login to Openshift cluster as admin user
oc login -u admin -p redhat https://api.ocp4.example.com:644
Identify the URL for the web console
oc whoami –show-console
Create the comprehensive-review project
oc new-project comprehensive-review
Source the classroom configuration file that is accessible at /usr/local/etc/ocp4.config, and log in as the kubeadmin user
$ source /usr/local/etc/ocp4.config
$ oc login -u kubeadmin -p ${RHT_OCP4_KUBEADM_PASSWD} \
> https://api.ocp4.example.com:6443
Smoke test: Use the oc new-app command to create the hello-world-nginx deployment configuration. Make sure to use the –as-deployment-config option to create the application using a deployment configuration
$ oc new-app –name hello-world-nginx \
> –as-deployment-config \
> https://github.com/RedHatTraining/DO280-apps \
> –context-dir hello-world-nginx
Smoke test: Create a route to the application by exposing the hello-world-nginx service
$ oc expose service hello-world-nginx \
> –hostname hello-world.apps.ocp4.example.com
Smoke test: Verify access to the application
curl -s http://hello-world.apps.ocp4.example.com \
> | grep Hello
Perform a smoke test of the cluster to verify basic cluster functionality. Use a deployment configuration to create an application named hello-world-nginx. The application source code is located in the hello-world-nginx subdirectory of the https://github.com/RedHatTraining/DO280-apps repository.
Create a route for the application using any available hostname in the apps.ocp4.example.com subdomain, and then verify that the application responds to external requests.
- Use the oc new-app command to create the hello-world-nginx deployment configuration. Make sure to use the –as-deployment-config option to create the application using a deployment configuration.
- Create a route to the application by exposing the hello-world-nginx service.
- Wait until the application pod is running.
- Verify access to the application.
As the admin user, create three user groups: leaders, developers, and qa.
Assign the leader user to the leaders group, the developer user to the developers group, and the qa-engineer user to the qa group.
Assign roles to each group:
Assign the self-provisioner role to the leaders group, which allows members to create projects. For this role to be effective, you must also remove the ability of any authenticated user to create new projects. Assign the edit role to the developers group for the comprehensive-review project only, which allows members to create and delete project resources. Assign the view role to the qa group for the comprehensive-review project only, which provides members with read access to project resources.
- Log in as the admin user.
- Create the three user groups.
- Add each user to the appropriate group.
- Allow members of the leaders group to create new projects:
- Remove the self-provisioner cluster role from the system:authenticated:oauth group.
- Allow members of the developers group to create and delete resources in the comprehensive-review project:
- Allow members of the qa group to view project resources:
Log in as the admin user.
$ oc login -u admin -p review
Create the three user groups
$ for group in leaders developers qa
> do
> oc adm groups new ${group}
> done
Add each user to the appropriate group.
$ oc adm groups add-users leaders leader
$ oc adm groups add-users developers developer
$ oc adm groups add-users qa qa-engineer
Allow members of the leaders group to create new projects:
$ oc adm policy add-cluster-role-to-group \
> self-provisioner leaders
Remove the self-provisioner cluster role from the system:authenticated:oauth group.
$ oc adm policy remove-cluster-role-from-group \
> self-provisioner system:authenticated:oauth
Allow members of the developers group to create and delete resources in the comprehensive-review project:
$ oc policy add-role-to-group edit developers