-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e228149
commit 6931d36
Showing
15 changed files
with
577 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import yaml | ||
from yaml import CLoader as Loader | ||
from cerberus import Validator | ||
|
||
|
||
|
||
def _load_doc(yamlPath): | ||
with open(yamlPath, 'r') as stream: | ||
try: | ||
return yaml.load(stream, Loader=Loader) | ||
except yaml.YAMLError as exception: | ||
raise exception | ||
|
||
def checker(schema, yamlPath): | ||
#schema = eval(open('./schema.py', 'r').read()) | ||
v = Validator(schema) | ||
doc = _load_doc(yamlPath) | ||
correctness = "" | ||
if v.validate(doc, schema): | ||
correctness = "Your answer is correct!" | ||
else: | ||
correctness = "Your answer was not correct. Please try again." | ||
|
||
print("IS VALID: ", correctness) | ||
print("ERRORS: ", v.errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/python3 | ||
schema = { | ||
'name': { | ||
'required': True, | ||
'type': 'string' | ||
}, | ||
'date': { | ||
'required': True, | ||
'type': 'date' | ||
}, | ||
'metrics': { | ||
'required': True, | ||
'type': 'dict', | ||
'schema': { | ||
'percentage': { | ||
'required': True, | ||
'type': 'dict', | ||
'schema': { | ||
'value': { | ||
'required': True, | ||
'type': 'number', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
'trend': { | ||
'type': 'string', | ||
'nullable': True, | ||
'regex': '^(?i)(down|equal|up)$' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
import checker_common as C | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
startMsg = "Checking your work for Lab-1, Exercise-1..." | ||
print(startMsg) | ||
C.checker(schema, sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: 'my_name' | ||
date: 2017-10-01 | ||
metrics: | ||
percentage: | ||
value: 87 | ||
trend: down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Summary: | ||
|
||
The purpose of the lab exercises is to get you up to speed on using Kubernetes (abbreviated as K8s) with the following learning objectives in mind: | ||
- To get introduced to core terminology | ||
- To become familiar with the core concepts | ||
- To understand how to interact with K8s using kubectl | ||
- To become familiar with the basics of YAML | ||
- To understand how to create or deploy your own resources on K8s using YAML and kubectl | ||
- And to understand how to read an interptet the K8s API documentation | ||
|
||
# About this VM: | ||
In order to help you along your K8s learning path, this VM has been designed to be as lightweight aspossible and with collection of software pre-installed to make your learning experience much easier so you can focus on just using kubernetes. | ||
|
||
The core software that you'll be interacting with in order to learn K8s are: | ||
- Visual Studio Code with the following extensions: | ||
- YAML (from Red Hat) | ||
- Kubernetes (from Microsoft) | ||
- Markdown (from Yu Zhang) | ||
- Docker Community Edition for Linux | ||
- K3d | ||
|
||
VS Code and Docker are popular pieces of software that I'm just going to assume that you already know about, so I won't explain what they are for, but what about K3d? | ||
|
||
# About K3d | ||
K3d, is probably a new name that you haven't heard of before. Basically K3d is a tool developed by Rancher (now owned by Suse) that makes it **super** easy to create single-node or multi-node kubernetes clusters on your local machine. In our case, K3d will be used to help us to easily create and destroy K8s clusters on this VM. | ||
|
||
K3d accomplishes this in a few ways: | ||
1. K3d provides you a very easy to use command line interface that you can use to create, delete, and manage your Kubernetes cluster. | ||
2. When you create a cluster using K3d, all Kubernetes nodes that K3d creates are running inside of a Docker container. | ||
3. The containers that act as K8s nodes all have a very lightweight container runtime which uses containerd, runc, and cri. | ||
4. When you create pods (containers) to run on your K8s cluster, you're essentially creating that container, in another container. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# About | ||
Here is a quick reference document to provide examples of some commonly used commands with K3d. | ||
|
||
# Example Commands | ||
|
||
## Creating stuff | ||
### Creating a single node cluster with a default cluster name: | ||
`k3d cluster create` | ||
|
||
### Creating a single node cluster with a custom cluster name: | ||
`k3d cluster create myCluster1` | ||
|
||
### Creating a multi node cluster with 2 masters and 2 workers: | ||
`k3d cluster create -s 2 -a 2` | ||
|
||
### Adding 2 additional worker nodes to an existing cluster: | ||
`k3d node create myAgent --role agent --replicas 2 -c myCluster1` | ||
|
||
### Adding a master node to an existing cluster: | ||
`k3d node create myMaster --role server -c myCluster1` | ||
|
||
### Creating a private container image registry: | ||
`k3d reg create myReg1` | ||
|
||
--- | ||
## Getting information | ||
### Listing your clusters: | ||
`k3d cluster list` | ||
|
||
### Listing your registries: | ||
`k3d reg list` | ||
|
||
--- | ||
## Deleting stuff | ||
### Deleting a single node cluster with a default cluster name: | ||
`k3d cluster delete` | ||
|
||
### Deleting a single node cluster with a custom cluster name: | ||
`k3d cluster delete myCluster1` | ||
|
||
### Creating a private container image registry: | ||
`k3d reg delete myReg1` |
Oops, something went wrong.