Skip to content

Commit f721c87

Browse files
committed
Openshift 4.16 playground
1 parent c9d467a commit f721c87

File tree

6 files changed

+507
-0
lines changed

6 files changed

+507
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
slug: playground
3+
id: ekm78u6ypkfo
4+
type: challenge
5+
title: OpenShift Playground
6+
notes:
7+
- type: text
8+
contents: |
9+
## Goal
10+
11+
Explore OpenShift version 4.16.
12+
13+
## Concepts
14+
15+
* OpenShift Web Console
16+
* `oc` command line tool
17+
18+
## Use case
19+
20+
You control an OpenShift cluster for one hour. You can deploy your own container image, or set up a pipeline to build your application from source, then use an Operator to deploy and manage a database backend.
21+
22+
This OpenShift cluster will self-destruct in one hour.
23+
tabs:
24+
- id: gokx20ly4oue
25+
title: Terminal
26+
type: terminal
27+
hostname: crc
28+
cmd: /bin/bash
29+
- id: aluytc9bmhm1
30+
title: Web Console
31+
type: website
32+
url: https://console-openshift-console.crc.${_SANDBOX_ID}.instruqt.io
33+
new_window: true
34+
- id: 60xkslm20oxn
35+
title: Visual Editor
36+
type: code
37+
hostname: crc
38+
path: /root
39+
difficulty: basic
40+
timelimit: 3600
41+
---
42+
Before you get started we recommend reading the following tips. They explain
43+
a bit about how the playground environment is setup and what access you have.
44+
45+
## Logging in to the Cluster via Dashboard
46+
47+
Let's also log in to our web console. This can be done by clicking the *Web Console* tab near the top of your screen.
48+
49+
You can login as `admin` user. Use the following credentials:
50+
51+
* Username:
52+
```
53+
admin
54+
```
55+
* Password:
56+
```
57+
admin
58+
```
59+
![Web Console Login](https://raw.githubusercontent.com/openshift-instruqt/instruqt/master/assets/middleware/pipelines/web-console-login.png)
60+
61+
You can also login as the `developer` user. Use the following credentials:
62+
63+
* Username:
64+
```
65+
developer
66+
```
67+
* Password:
68+
```
69+
developer
70+
```
71+
72+
## Logging in to the Cluster via CLI
73+
74+
When the OpenShift playground is created you will be logged in initially as
75+
a cluster admin:
76+
77+
```
78+
oc whoami
79+
```
80+
81+
This will allow you to perform
82+
operations which would normally be performed by a cluster admin.
83+
84+
Before creating any applications, it is recommended you login as a distinct
85+
user. This will be required if you want to log in to the web console and
86+
use it.
87+
88+
To login to the OpenShift cluster from the _Terminal_ run:
89+
90+
```
91+
oc login -u developer -p developer
92+
```
93+
94+
This will log you in using the credentials:
95+
96+
* **Username:** ``developer``
97+
* **Password:** ``developer``
98+
99+
Use the same credentials to log into the web console.
100+
101+
In order that you can still run commands from the command line as a cluster
102+
admin, the ``sudoer`` role has been enabled for the ``developer`` account.
103+
To execute a command as a cluster admin use the ``--as system:admin`` option
104+
to the command. For example:
105+
106+
```
107+
oc get projects --as system:admin
108+
```
109+
110+
## Creating your own Project
111+
112+
To create a new project called ``myproject`` run the command:
113+
114+
```
115+
oc new-project myproject
116+
```
117+
118+
You could instead create the project from the web console. If you do this,
119+
to change to the project from the command line run the command:
120+
121+
```
122+
oc project myproject
123+
```
124+
125+
## Persistent Volume Claims
126+
127+
Persistent volumes have been pre-created in the playground environment.
128+
These will be used if you make persistent volume claims for an application.
129+
The volume sizes are defined as 100Gi each, however you are limited by how
130+
much disk space the host running the OpenShift environment has, which is
131+
much less.
132+
133+
To view the list of available persistent volumes you can run:
134+
135+
```
136+
oc get pv --as system:admin
137+
```
138+
139+
## Builder Images and Templates
140+
141+
The playground environment is pre-loaded with Source-to-Image (S2I) builders
142+
for Java (Wildfly), Javascript (Node.JS), Perl, PHP, Python and Ruby.
143+
Templates are also available for MariaDB, MongoDB, MySQL, PostgreSQL and
144+
Redis.
145+
146+
You can see the list of what is available, and what versions, under _Add to
147+
Project_ in the web console, or by running from the command line:
148+
149+
```
150+
oc new-app -L
151+
```
152+
153+
## Running Images as a Defined User
154+
155+
By default OpenShift prohibits images from running as the ``root`` user
156+
or as a specified user. Instead, each project is assigned its own unique
157+
range of user IDs that application images have to run as.
158+
159+
If you attempt to run an arbitrary image from an external image registry
160+
such a Docker Hub, which is not built to best practices, or requires that
161+
it be run as ``root``, it may not work as a result.
162+
163+
In order to run such an image, you will need to grant additional privileges
164+
to the project you create to allow it to run an application image as any
165+
user ID. This can be done by running the command:
166+
167+
```
168+
oc adm policy add-scc-to-user anyuid -z default -n myproject --as system:admin
169+
```
170+
171+
# Next Steps!
172+
173+
Congratulations on completing this self-paced lab and learning about the capabilities of Red Hat OpenShift. To continue your journey, here's some handy links:
174+
175+
* [Red Hat Developer learning page](https://developers.redhat.com/learn)
176+
* [Want to try a free, instant 30-day OpenShift cluster? Get started with the Developer Sandbox for Red Hat OpenShift](https://developers.redhat.com/developer-sandbox)
177+
178+
Don't forget to finish the lab and provide your feedback on the next page. Thanks for playing!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
echo "Checking user login status..."
5+
WHOAMI=$(oc whoami)
6+
7+
if [ $WHOAMI == "developer" -o $WHOAMI == "admin" ]
8+
then
9+
echo "login successful!"
10+
else
11+
echo "FAIL: User authentication cannot be confirmed. Have you logged in yet?"
12+
exit 1
13+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
echo "Authenticating login credentials using 'oc login'"
5+
6+
oc login -u developer -p developer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
virtualmachines:
3+
- name: crc
4+
image: rhd-devx-instruqt/openshift-4-16-7
5+
machine_type: n1-standard-8
6+
allow_external_ingress:
7+
- http
8+
- https
9+
- high-ports
10+
provision_ssl_certificate: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
slug: playgrounds-openshift416
2+
id: uenvn52euxdw
3+
title: OpenShift Playground 4.16
4+
teaser: Quick access to the web console or the command-line interface to explore Red
5+
Hat OpenShift
6+
description: |
7+
## Goal
8+
9+
Explore OpenShift version 4.16.
10+
11+
## Concepts
12+
13+
* OpenShift Web Console
14+
* `oc` command line tool
15+
16+
## Use case
17+
18+
You control an OpenShift cluster for one hour. You can test and deploy your own container image, or set up a pipeline to build your application from source, then monitor it with Prometheus as it runs.
19+
20+
This OpenShift cluster will self-destruct in one hour.
21+
icon: https://logodix.com/logo/1910931.png
22+
level: beginner
23+
tags:
24+
- prod
25+
- openshift
26+
owner: openshift
27+
developers:
28+
29+
idle_timeout: 1200
30+
timelimit: 3600
31+
lab_config:
32+
overlay: false
33+
width: 33
34+
position: right
35+
feedback_recap_enabled: true
36+
loadingMessages: true
37+
lab_v2: true
38+
theme:
39+
name: original
40+
override_challenge_layout: false
41+
hideStopButton: false
42+
default_layout: AssignmentRight
43+
default_layout_sidebar_size: 33
44+
checksum: "15538197099370922903"

0 commit comments

Comments
 (0)