-
Notifications
You must be signed in to change notification settings - Fork 30
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
Showing
7 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
instruqt/protecting-your-assets/01-validate-connectivity/assignment.md
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 @@ | ||
--- | ||
slug: validate-connectivity | ||
type: challenge | ||
title: validate-connectivity | ||
teaser: Validates connectivity between the shell and the cluster | ||
notes: | ||
- type: text | ||
contents: Let's check that we can connect | ||
tabs: | ||
- title: Shell | ||
type: terminal | ||
hostname: shell | ||
workdir: /home/replicant | ||
- title: Cluster | ||
type: terminal | ||
hostname: cluster | ||
difficulty: basic | ||
timelimit: 3000 | ||
--- | ||
|
||
#### Let's check our connectivity | ||
|
||
``` | ||
kubectl get nodes | ||
``` |
9 changes: 9 additions & 0 deletions
9
instruqt/protecting-your-assets/01-validate-connectivity/check-shell
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,9 @@ | ||
#!/bin/sh | ||
# | ||
# This script runs when the platform check the challenge. | ||
# | ||
# The platform determines if the script was successful using the exit code of this | ||
# script. If the exit code is not 0, the script fails. | ||
# | ||
|
||
kubectl get nodes |
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,11 @@ | ||
version: "3" | ||
containers: | ||
- name: shell | ||
image: gcr.io/kots-field-labs/shell | ||
shell: su - replicant | ||
memory: 256 | ||
virtualmachines: | ||
- name: cluster | ||
image: instruqt/k3s-v1-25-0 | ||
shell: /bin/bash | ||
machine_type: n1-standard-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,24 @@ | ||
slug: protecting-your-assets | ||
title: Protecting Your Assets | ||
teaser: Template track for a shell connecting to a K3s cluster | ||
description: |- | ||
This track is a template track to build any lab that requires | ||
a shell that connects to an existing cluster. To use it, run: | ||
``` | ||
instruqt track create --title [NEW TRACK TITLE] \ | ||
--from shell-and-cluster-template | ||
``` | ||
icon: https://storage.googleapis.com/instruqt-frontend/img/tracks/default.png | ||
level: beginner | ||
tags: | ||
- template | ||
owner: replicated | ||
developers: | ||
- chuck@replicated.com | ||
lab_config: | ||
overlay: false | ||
width: 25 | ||
position: right | ||
feedback_recap_enabled: true | ||
loadingMessages: true |
27 changes: 27 additions & 0 deletions
27
instruqt/protecting-your-assets/track_scripts/setup-cluster
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This set line ensures that all failures will cause the script to error and exit | ||
set -euxo pipefail | ||
|
||
# simple SSH client setup so we can SSH to/from the shell | ||
|
||
cat <<EOF >> "$HOME/.ssh/config" | ||
Host * | ||
StrictHostKeyChecking no | ||
UserKnownHostsFile /dev/null | ||
PubkeyAcceptedKeyTypes +ssh-rsa | ||
EOF | ||
|
||
while ! ssh shell true; do | ||
echo "Waiting for container SSH to be available..." | ||
sleep 1 | ||
done | ||
|
||
ssh shell "mkdir /home/replicant/.kube" | ||
|
||
while ! [[ -f /etc/rancher/k3s/k3s.yaml ]]; do | ||
echo "Waiting for Rancher kubernetes configuration to be available..." | ||
sleep 1 | ||
done | ||
|
||
scp /etc/rancher/k3s/k3s.yaml shell:/home/replicant/.kube/config |
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,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This set line ensures that all failures will cause the script to error and exit | ||
set -euxo pipefail | ||
|
||
# simple SSH client setup so we can SSH to/from the shell | ||
|
||
cat <<EOF >> "$HOME/.ssh/config" | ||
Host * | ||
StrictHostKeyChecking no | ||
UserKnownHostsFile /dev/null | ||
EOF | ||
|
||
# assure an RSA key for Dropbear | ||
ssh-keygen -t rsa -f /etc/dropbear/dropbear_rsa_host_key -N '' | ||
|
||
# change the cluster URI | ||
yq -i '.clusters[0].cluster.server = "https://cluster:6443"' /home/replicant/.kube/config | ||
chown -R replicant /home/replicant/.kube |
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,7 @@ | ||
{ | ||
"name": "Slackernews", | ||
"slug": "slackernews", | ||
"customer": "Omozan", | ||
"yaml_dir": "", | ||
"k8s_installer_yaml_path": "" | ||
} |