Skip to content

Commit

Permalink
Creates track skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
crdant committed Apr 25, 2024
1 parent 7d84e92 commit ab8de4a
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 0 deletions.
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
```
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
11 changes: 11 additions & 0 deletions instruqt/protecting-your-assets/config.yml
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
24 changes: 24 additions & 0 deletions instruqt/protecting-your-assets/track.yml
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 instruqt/protecting-your-assets/track_scripts/setup-cluster
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
19 changes: 19 additions & 0 deletions instruqt/protecting-your-assets/track_scripts/setup-shell
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
7 changes: 7 additions & 0 deletions instruqt/protecting-your-assets/vendor/vendor.json
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": ""
}

0 comments on commit ab8de4a

Please sign in to comment.