Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 01a98bc

Browse files
committed
Lab2 instructions
1 parent 303c138 commit 01a98bc

File tree

5 files changed

+364
-36
lines changed

5 files changed

+364
-36
lines changed

workshop/Lab0/README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Pre-work
1+
# Lab 0: Pre-work
22

33
## 1. Setup Kubernetes environment
44

@@ -8,5 +8,33 @@ Run through the instructions listed [here](https://github.com/IBM/kube101/tree/m
88

99
## 3. Docker hub account.
1010

11+
Create a [dockerhub](https://hub.docker.com/) user and set the environment variable.
12+
```
13+
DOCKERUSER=<dockerhub useid>
14+
```
15+
16+
## 4. Set the cluster name
17+
18+
```
19+
ibmcloud ks clusters
20+
21+
OK
22+
Name ID State Created Workers Location Version Resource Group Name Provider
23+
user001-workshop bseqlkkd0o1gdqg4jc10 normal 3 months ago 5 Dallas 4.3.38_1544_openshift default classic
24+
25+
26+
CLUSTERNAME=use001-workshop
27+
```
28+
or
29+
30+
```
31+
CLUSTERNAME=`ibmcloud ks clusters | grep Name -A 1 | awk '{print $1}' | grep -v Name`
32+
33+
echo $CLUSTERNAME
34+
user001-workshop
35+
```
36+
37+
38+
1139

1240

workshop/Lab1/README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# Lab 1. Non-pesistent storage with Kubernetes
1+
# Lab 1: Non-persistent storage with Kubernetes
22

33
Storing data in containers or worker nodes are considered as the [non-persistent](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#local-ephemeral-storage) forms of data storage.
4-
In this lab, we will explore storage options on the IBM Kubernetes worker nodes. Follow this [lab](https://github.com/remkohdev/docker101/tree/master/workshop/lab-3) is you are interested in learning more about container based storage.
4+
In this lab, we will explore storage options on the IBM Kubernetes worker nodes. Follow this [lab](https://github.com/remkohdev/docker101/tree/master/workshop/lab-3) is you are interested in learning more about container-based storage.
55

66
The lab covers the following topics:
7-
- Create and claim persistent volumes based on the [primary]() and secondary storage available on the worker nodes.
7+
- Create and claim IBM Kubernetes [non-persistent](https://cloud.ibm.com/docs/containers?topic=containers-storage_planning#non_persistent_overview) storage based on the primary and secondary storage available on the worker nodes.
88
- Make the volumes available in the `Guestbook` application.
9-
- Use the volumes to stroage application cache and debug information.
9+
- Use the volumes to store application cache and debug information.
1010
- Access the data from the guestbook container using the Kubernetes CLI.
11+
- Assess the impact of losing a pod on data retention.
1112
- Claim back the storage resources and clean up.
1213

1314

14-
The primary storage maps to the volume type `hostPath` and the secondary storage maps to `emptyDir`. Learn more about Kubernetes volume types [here](https://kubernetes.io/docs/concepts/storage/volumes/).
15+
The primary storage maps to the volume type `hostPath` and the secondary storage maps to `emptyDir`. Learn more about Kubernetes volume types [here](https://Kubernetes.io/docs/concepts/storage/volumes/).
1516

1617
## Reserve Persistent Volumes
1718

@@ -44,7 +45,7 @@ spec:
4445
path: "/mnt/data"
4546
```
4647

47-
Create the persistent volume as shown in the comamand below.
48+
Create the persistent volume as shown in the command below:
4849
```
4950
kubectl create -f pv-hostpath.yaml
5051
persistentvolume/guestbook-primary-pv created
@@ -90,15 +91,15 @@ Change to the guestbook application source directory:
9091
```
9192
cd $HOME/guestbook-nodejs/src
9293
```
93-
Review the source `common/models/entry.js`. The application uses storage allocated using `hostPath` to store data cache in the file `data/cache.txt`. The file `logs/debug.txt` records debug messages and is provisioned via the `emptyDir` storage type.
94+
Review the source `common/models/entry.js`. The application uses storage allocated using `hostPath` to store data cache in the file `data/cache.txt`. The file `logs/debug.txt` records debug messages provisioned using the `emptyDir` storage type.
9495

9596
```source
9697
module.exports = function(Entry) {
9798
9899
Entry.greet = function(msg, cb) {
99100
100101
// console.log("testing " + msg);
101-
fs.appendFile('logs/debug.txt', "Recevied message: "+ msg +"\n", function (err) {
102+
fs.appendFile('logs/debug.txt', "Received message: "+ msg +"\n", function (err) {
102103
if (err) throw err;
103104
console.log('Debug stagement printed');
104105
});
@@ -111,23 +112,23 @@ module.exports = function(Entry) {
111112
...
112113
```
113114

114-
Run the commands listed below to build the guestbook image and copy into docker hub registry:
115+
Run the commands listed below to build the guestbook image and copy into the docker hub registry:
115116

116117
```
117118
cd $HOME/guestbook-nodejs/src
118119
docker build -t $DOCKERUSER/guestbook-nodejs:storage .
119-
export DOCKERUSER=rojanjose
120-
docker login -u DOCKERUSER
120+
docker login -u $DOCKERUSER
121121
docker push $DOCKERUSER/guestbook-nodejs:storage
122122
```
123123

124124
Review the deployment yaml file `guestbook-deplopyment.yaml` prior to deploying the application into the cluster.
125125

126126
```
127-
cd $HOME/storage/lab1
128-
cat guestbook-deplopyment.yaml
127+
cd $HOME/guestbook-config/storage/lab1
128+
cat guestbook-deployment.yaml
129129
```
130130

131+
Replace the first part of `image` name with your docker hub user id.
131132
The section `spec.volumes` lists `hostPath` and `emptyDir` volumes. The section `spec.containers.volumeMounts` lists the mount paths that the application uses to write in the volumes.
132133

133134
```
@@ -162,7 +163,7 @@ metadata:
162163
...
163164
```
164165

165-
Deploy Guestbook application:
166+
Deploy the Guestbook application:
166167

167168
```
168169
kubectl create -f guestbook-deployment.yaml
@@ -223,11 +224,11 @@ Nǐn hǎo Kubernetes!
223224
Goedendag Kubernetes!
224225
225226
root@guestbook-v1-6f55cb54c5-jb89d:/home/node/app# cat logs/debug.txt
226-
Recevied message: Hello Kubernetes!
227-
Recevied message: Hola Kubernetes!
228-
Recevied message: Zdravstvuyte Kubernetes!
229-
Recevied message: Nǐn hǎo Kubernetes!
230-
Recevied message: Goedendag Kubernetes!
227+
Received message: Hello Kubernetes!
228+
Received message: Hola Kubernetes!
229+
Received message: Zdravstvuyte Kubernetes!
230+
Received message: Nǐn hǎo Kubernetes!
231+
Received message: Goedendag Kubernetes!
231232
232233
233234
root@guestbook-v1-6f55cb54c5-jb89d:/home/node/app# df -h
@@ -287,14 +288,14 @@ Ciao Kubernetes!
287288
Sayonara Kubernetes!
288289
289290
root@guestbook-v1-5cbc445dc9-sx58j:/home/node/app# cat logs/debug.txt
290-
Recevied message: Bye Kubernetes!
291-
Recevied message: Aloha Kubernetes!
292-
Recevied message: Ciao Kubernetes!
293-
Recevied message: Sayonara Kubernetes!
291+
Received message: Bye Kubernetes!
292+
Received message: Aloha Kubernetes!
293+
Received message: Ciao Kubernetes!
294+
Received message: Sayonara Kubernetes!
294295
root@guestbook-v1-5cbc445dc9-sx58j:/home/node/app#
295296
```
296297

297-
This shows that the storage type `emptyDir` loose data on a pod restart where as `hostPath` data lives until the worker node or cluster is deleted.
298+
This shows that the storage type `emptyDir` loose data on a pod restart whereas `hostPath` data lives until the worker node or cluster is deleted.
298299

299300

300301
## Clean up

0 commit comments

Comments
 (0)