From 450d65bc2ca9d6b4650a54bb67a1701397b593bc Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Tue, 17 Sep 2024 16:33:27 -0400 Subject: [PATCH] Starts an overview lab (#350) TL;DR ----- Provides a stub for a new overview-style lab Details ------- Implements a stub track for "Meeting the Replicated Platform", a new lab that vendors can use to discover the Replicated Platform. The lab will cover some of the same steps as an overview demo to familiarize vendors with the Platform on their own. --- .../01-accessing-the-platform/assignment.md | 36 + .../01-accessing-the-platform/check-shell | 11 + .../01-accessing-the-platform/cleanup-shell | 11 + .../01-accessing-the-platform/setup-shell | 11 + .../01-accessing-the-platform/solve-shell | 11 + instruqt/meet-the-platform/config.yml | 14 + instruqt/meet-the-platform/track.yml | 43 ++ .../track_scripts/setup-node | 36 + .../track_scripts/setup-shell | 684 ++++++++++++++++++ instruqt/meet-the-platform/vendor/vendor.json | 7 + 10 files changed, 864 insertions(+) create mode 100755 instruqt/meet-the-platform/01-accessing-the-platform/assignment.md create mode 100755 instruqt/meet-the-platform/01-accessing-the-platform/check-shell create mode 100755 instruqt/meet-the-platform/01-accessing-the-platform/cleanup-shell create mode 100755 instruqt/meet-the-platform/01-accessing-the-platform/setup-shell create mode 100755 instruqt/meet-the-platform/01-accessing-the-platform/solve-shell create mode 100644 instruqt/meet-the-platform/config.yml create mode 100755 instruqt/meet-the-platform/track.yml create mode 100755 instruqt/meet-the-platform/track_scripts/setup-node create mode 100755 instruqt/meet-the-platform/track_scripts/setup-shell create mode 100644 instruqt/meet-the-platform/vendor/vendor.json diff --git a/instruqt/meet-the-platform/01-accessing-the-platform/assignment.md b/instruqt/meet-the-platform/01-accessing-the-platform/assignment.md new file mode 100755 index 000000000..e6a5edb9e --- /dev/null +++ b/instruqt/meet-the-platform/01-accessing-the-platform/assignment.md @@ -0,0 +1,36 @@ +--- +slug: accessing-the-platform +id: umt7hoxqedg2 +type: challenge +title: The Replicated Platform +teaser: Learn abot and connect to the Replicated Platform +notes: +- type: text + contents: | + The Replicated Platform supports your team throughout the [Commercial + Software Distribution + Lifecycle](https://youtu.be/FtcnUKQuteU?feature=shared). Your primary + interface to the Platform is the Replicated Vendor Portal. This lab + will introduce you to the Platform and show you how to access the Vendor + Portal. +tabs: +- id: kp9tdilwjwt0 + title: Shell + type: terminal + hostname: shell +difficulty: basic +timelimit: 600 +--- + +The Replicated Platform is a unified platform bringing together everything you +need to navigate your Commercial Software Distribution Lifecycle. You use the +platform to efficiently manage, test, install, support, and measure the +distribution of your app. The Replicated Vendor Portal provides the interfaces +you need to work with the Platform from the web, the command-line, and +anywhere you can invoke its APIs. + +This lab will introduce you to the Replicated Platform through the Vendor +Portal. After getting to know the Vendor Portal, you'll take the role of the +customers and install [SlackerNews](https://slackernews.io), an application +distributed with Replicated. From there, we'll show you how you'll work with +customers having a support issue, and how they'll install a fix. diff --git a/instruqt/meet-the-platform/01-accessing-the-platform/check-shell b/instruqt/meet-the-platform/01-accessing-the-platform/check-shell new file mode 100755 index 000000000..8f9df0d6e --- /dev/null +++ b/instruqt/meet-the-platform/01-accessing-the-platform/check-shell @@ -0,0 +1,11 @@ +#!/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. +# + +echo "This is the check script" + +exit 0 diff --git a/instruqt/meet-the-platform/01-accessing-the-platform/cleanup-shell b/instruqt/meet-the-platform/01-accessing-the-platform/cleanup-shell new file mode 100755 index 000000000..3fab24155 --- /dev/null +++ b/instruqt/meet-the-platform/01-accessing-the-platform/cleanup-shell @@ -0,0 +1,11 @@ +#!/bin/sh +# +# This script runs when the platform cleanup 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. +# + +echo "This is the cleanup script" + +exit 0 diff --git a/instruqt/meet-the-platform/01-accessing-the-platform/setup-shell b/instruqt/meet-the-platform/01-accessing-the-platform/setup-shell new file mode 100755 index 000000000..cd25f332c --- /dev/null +++ b/instruqt/meet-the-platform/01-accessing-the-platform/setup-shell @@ -0,0 +1,11 @@ +#!/bin/sh +# +# This script runs when the platform setup 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. +# + +echo "This is the setup script" + +exit 0 diff --git a/instruqt/meet-the-platform/01-accessing-the-platform/solve-shell b/instruqt/meet-the-platform/01-accessing-the-platform/solve-shell new file mode 100755 index 000000000..a182bdeed --- /dev/null +++ b/instruqt/meet-the-platform/01-accessing-the-platform/solve-shell @@ -0,0 +1,11 @@ +#!/bin/sh +# +# This script runs when the platform solve 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. +# + +echo "This is the solve script" + +exit 0 diff --git a/instruqt/meet-the-platform/config.yml b/instruqt/meet-the-platform/config.yml new file mode 100644 index 000000000..d5184a4af --- /dev/null +++ b/instruqt/meet-the-platform/config.yml @@ -0,0 +1,14 @@ +version: "3" +containers: +- name: shell + image: gcr.io/kots-field-labs/shell:main + shell: tmux new-session -A -s shell su - replicant +virtualmachines: +- name: node + image: kots-field-labs/future-node + shell: /bin/bash + machine_type: n2d-standard-4 + allow_external_ingress: + - http + - https + - high-ports diff --git a/instruqt/meet-the-platform/track.yml b/instruqt/meet-the-platform/track.yml new file mode 100755 index 000000000..ddddc3785 --- /dev/null +++ b/instruqt/meet-the-platform/track.yml @@ -0,0 +1,43 @@ +slug: meet-the-platform +id: bocfnxay34uj +title: Meet the Replicated Platform +teaser: |- + A template track for sharing the shell environment across + challenges +description: |- + This track is a template track to build any lab that requires + maintaining the shell and it's environment between challenges. + + To use it, run: + + ``` + instruqt track create --title [NEW TRACK TITLE] \ + --from shared-env-template + ``` + + The track provides both a shell and a single-node cluster, and + the learner runs their commands as the user `replicant`. + + Another advantage of this template is that you can check what + the learner has typed into their shell by capturing the `tmux` + pane content and running a grep against it, see the sample + check script in the first challenge for an example. +icon: https://storage.googleapis.com/instruqt-frontend/img/tracks/default.png +tags: +- template +owner: replicated +developers: +- chuck@replicated.com +maintenance: true +idle_timeout: 300 +timelimit: 1200 +lab_config: + overlay: false + width: 25 + position: right + sidebar_enabled: true + feedback_recap_enabled: true + feedback_tab_enabled: false + loadingMessages: true + hideStopButton: false +checksum: "11533550873014008068" diff --git a/instruqt/meet-the-platform/track_scripts/setup-node b/instruqt/meet-the-platform/track_scripts/setup-node new file mode 100755 index 000000000..3c24c3215 --- /dev/null +++ b/instruqt/meet-the-platform/track_scripts/setup-node @@ -0,0 +1,36 @@ +#!/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 <> "$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 + +# use our shared libary in setup scripts +curl -s -o /etc/profile.d/header.sh https://raw.githubusercontent.com/replicatedhq/replicated-field-labs/main/libs/header.sh +source /etc/profile.d/header.sh + +api_token=$(get_api_token) +app_slug=$(get_app_slug) +app_id=$(get_app_id) +replicated_sdk_version=$(get_replicated_sdk_version) +embedded_cluster_version=$(get_embedded_cluster_version) + +agent variable set USERNAME $(get_username) +agent variable set PASSWORD $(get_password) +agent variable set SLACKERNEWS_DOMAIN $(get_slackernews_domain) +agent variable set REPLICATED_API_TOKEN ${api_token} +agent variable set REPLICATED_APP ${app_slug} +agent variable set REPLICATED_SDK_VERSION ${replicated_sdk_version} +agent variable set EMBEDDED_CLUSTER_VERSION ${embedded_cluster_version} diff --git a/instruqt/meet-the-platform/track_scripts/setup-shell b/instruqt/meet-the-platform/track_scripts/setup-shell new file mode 100755 index 000000000..e35a21842 --- /dev/null +++ b/instruqt/meet-the-platform/track_scripts/setup-shell @@ -0,0 +1,684 @@ +#!/usr/bin/env bash + +# This set line ensures that all failures will cause the script to error and exit +set -euo pipefail +HOME_DIR=/home/replicant + +while [ ! -f /opt/instruqt/bootstrap/host-bootstrap-completed ] +do + echo "Waiting for Instruqt to finish booting the virtual machine" + sleep 1 +done + +# simple SSH client setup so we can SSH to/from the shell + +cat <> "$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 '' + +# use our shared libary in setup scripts +# TO DO: Change to `main` when preparing to merge +curl -s -o /etc/profile.d/header.sh https://raw.githubusercontent.com/replicatedhq/replicated-field-labs/main/libs/header.sh +source /etc/profile.d/header.sh + +# there's only one app created by the automation, so just grab the first in the list +api_token=$(get_api_token) +app_slug=$(get_app_slug) +app_id=$(get_app_id) +replicated_sdk_version=$(get_replicated_sdk_version) +embedded_cluster_version=$(get_embedded_cluster_version) +customer_id=$(get_customer_id Omozan) + +agent variable set USERNAME $(get_username) +agent variable set PASSWORD $(get_password) +agent variable set REPLICATED_API_TOKEN ${api_token} +agent variable set REPLICATED_APP ${app_slug} +agent variable set REPLICATED_SDK_VERSION ${replicated_sdk_version} +agent variable set EMBEDDED_CLUSTER_VERSION ${embedded_cluster_version} +agent variable set CUSTOMER_ID ${customer_id} + +## release the application with the Replicated SDK +cd ${HOME_DIR} +mkdir ${HOME_DIR}/release + +get_slackernews + +# add preflight checks and support bundle +cat < ${HOME_DIR}/slackernews/templates/troubleshoot/preflights.yaml +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "slackernews.name" . }}-preflight + namespace: {{ .Release.Namespace | quote }} + labels: {{- include "slackernews.labels" . | nindent 4 }} + app.kubernetes.io/component: preflight + troubleshoot.sh/kind: preflight +type: Opaque +stringData: + preflight.yaml: | + apiVersion: troubleshoot.sh/v1beta2 + kind: Preflight + metadata: + name: slackernews-preflight-checks + spec: + analyzers: + - clusterVersion: + outcomes: + - fail: + when: "<= 1.26.x" + message: |- + Your Kubernets cluster is running a version of Kubernetes that is no longer supported by the Kubernetes + community and unable to be supported by Slackernews. Changes in Kubernetse since your current version mean + that you installation will likely not succeed. Please upgrade your cluster or install to a different + cluster running at least Kubernetes 1.26, ideally version 1.28.0 or later. + + If you are receiving extended support from your Kubernetes provider you may be able to ignore + this warning. If not, we recomend that you upgrade your cluster to at least version 1.28.0. + + uri: https://kubernetes.io + - warn: + when: "< 1.27.0" + message: |- + Your Kubernetes cluster is running a version of Kubernetes that will go out of support active support in + less than six months. We recommend that you upgrade your Kubernetes cluster to assure continued success with + your Slackernews implementation. + uri: https://kubernetes.io + - pass: + message: Your cluster is running a version of Kubernetes that is supported by the Slackernews container registry. + - nodeResources: + checkName: Cluster CPU resources are sufficient to install and run Slackernews + outcomes: + - fail: + when: "sum(cpuAllocatable) < 2" + message: |- + Slackernews requires a minimum of 2 CPU cores in order to run, and runs best with + at least 4 cores. Your current cluster has less than 2 CPU cores available to Kubernetes + workloads. Please increase cluster capacity or install into a different cluster. + - warn: + when: "sum(cpuAllocatable) < 4" + message: |- + Slackernews runs best with a minimum of 4 CPU cores. Your current cluster has less + than 4 CPU cores available to run workloads. For the best experience, consider + increasing cluster capacity or installing into a different cluster. + - pass: + message: Your cluster has sufficient CPU resources available to run Slackernews + - nodeResources: + checkName: Cluster memory is sufficient to install and run Slackernews + outcomes: + - fail: + when: "sum(memoryAllocatable) < 4G" + message: |- + Slackernews requires a minimum of 4 GB of memory in order to run, and runs best with + at least 8 GB. Your current cluster has less than 4 GB available to Kubernetes + workloads. Please increase cluster capacity or install into a different cluster. + - warn: + when: "sum(memoryAllocatable) < 8Gi" + message: |- + Slackernews runs best with a minimum of 8 GB of memory. Your current cluster has less + than 8 GB of memory available to run workloads. For the best experience, consider + increasing cluster capacity or installing into a different cluster. + - pass: + message: Your cluster has sufficient memory available to run Slackernews +SLACKERNEWS_PREFLIGHTS + +cat < /home/replicant/slackernews/templates/troubleshoot/support-bundle.yaml +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "slackernews.name" . }}-support-bundle + namespace: {{ .Release.Namespace | quote }} + labels: {{- include "slackernews.labels" . | nindent 4 }} + app.kubernetes.io/component: troubleshoot + troubleshoot.sh/kind: support-bundle +type: Opaque +stringData: + support-bundle-spec: | + apiVersion: troubleshoot.sh/v1beta2 + kind: SupportBundle + metadata: + name: slackernews-support-bundle + spec: + collectors: + - logs: + name: /app/slackernews/logs + selector: + - app=slackernews + - logs: + name: /app/slackernews/logs + selectors: + - app=slackernews-nginx + - logs: + name: /app/slackernews/logs + selectors: + - app=postgres + - logs: + name: /app/slackernews/logs + selectors: + - app.kubernetes.io/name=replicated + - configMap: + name: slackernews-nginx + namespace: slackernews + key: default.conf + includeValue: true + - secret: + name: slackernews-nginx + namespace: slackernews + key: tls.crt + includeValue: true + - secret: + name: slackernews-nginx + key: tls.key + includeVale: true + - secret: + name: slackernews-postgres + namespace: slackernews + key: password + - secret: + name: slackernews-postgres + namespace: slackernews + key: uri + - secret: + name: slackernews-slack + namespace: slackernews + key: clientId + - secret: + name: slackernews-slack + namespace: slackernews + key: clientSecret + - secret: + name: slackernews-slack + namespace: slackernews + key: botToken + - secret: + name: slackernews-slack + namespace: slackernews + key: userToken + analyzers: + - clusterVersion: + outcomes: + - fail: + when: "<= 1.26.x" + message: |- + Your Kubernets cluster is running a version of Kubernetes that is no longer supported by the Kubernetes + community and unable to be supported by Slackernews. Changes in Kubernetse since your current version mean + that you installation will likely not succeed. Please upgrade your cluster or install to a different + cluster running at least Kubernetes 1.26, ideally version 1.28.0 or later. + + If you are receiving extended support from your Kubernetes provider you may be able to ignore + this warning. If not, we recomend that you upgrade your cluster to at least version 1.28.0. + + uri: https://kubernetes.io + - warn: + when: "< 1.27.0" + message: |- + Your Kubernetes cluster is running a version of Kubernetes that will go out of support active support in + less than six months. We recommend that you upgrade your Kubernetes cluster to assure continued success with + your Slackernews implementation. + uri: https://kubernetes.io + - pass: + message: Your cluster is running a version of Kubernetes that is supported by Slackernews. + - nodeResources: + checkName: Cluster CPU resources are sufficient to install and run Slackernews + outcomes: + - fail: + when: "sum(cpuAllocatable) < 2" + message: |- + Slackernews requires a minimum of 2 CPU cores in order to run, and runs best with + at least 4 cores. Your current cluster has less than 2 CPU cores available to Kubernetes + workloads. Please increase cluster capacity or install into a different cluster. + - warn: + when: "sum(cpuAllocatable) < 4" + message: |- + Slackernews runs best with a minimum of 4 CPU cores. Your current cluster has less + than 4 CPU cores available to run workloads. For the best experience, consider + increasing cluster capacity or installing into a different cluster. + - pass: + message: Your cluster has sufficient CPU resources available to run Slackernews + - nodeResources: + checkName: Cluster memory is sufficient to install and run Slackernews + outcomes: + - fail: + when: "sum(memoryAllocatable) < 4G" + message: |- + Slackernews requires a minimum of 4 GB of memory in order to run, and runs best with + at least 8 GB. Your current cluster has less than 4 GB available to Kubernetes + workloads. Please increase cluster capacity or install into a different cluster. + - warn: + when: "sum(memoryAllocatable) < 8Gi" + message: |- + Slackernews runs best with a minimum of 8 GB of memory. Your current cluster has less + than 8 GB of memory available to run workloads. For the best experience, consider + increasing cluster capacity or installing into a different cluster. + - pass: + message: Your cluster has sufficient memory available to run Slackernews + - deploymentStatus: + name: slackernews-frontend + namespace: slackernews + outcomes: + - fail: + when: "absent" + message: | + The Slackernews core component has not been deployed to this cluster. Please be sure to install the Slackernews + application using its Helm chart. + - fail: + when: "< 1" + message: | + The Slackernews application is not currently running on this cluster. Please review the logs in this support + bundle to locate any errors. + - pass: + message: | + Ther Slackernews application is running on this cluster and ready for use. + - deploymentStatus: + name: slackernews-nginx + namespace: slackernews + outcomes: + - fail: + when: "absent" + message: | + The Slackernews web server has not been deployed to this cluster. Please sure to install the Slackernews g application using its Helm chart. + - fail: + when: "< 1" + message: | + The Slackernews web server is not currently running on this cluster. Please review the logs in this support bundle to locate any errors. + - pass: + message: | + Ther Slackernews web server is running on this cluster and ready for use. + - statefulsetStatus: + name: postgres + namespace: slackernews + outcomes: + - fail: + when: "absent" + message: | + The Slackernews database has not been deployed to this cluster. Please sure to install the Slackernews application using its Helm chart. + - fail: + when: "< 1" + message: | + The Slackernews database is not currently running on this cluster. Please review the logs in this support bundle to locate any errors. + - pass: + message: | + Ther Slackernews database is running on this cluster and ready for use. +SLACKERNEWS_SUPPORT_BUNDLE + +## update the support bundle with the URI field +sed -i '17i\ uri: https://storage.googleapis.com/shared-lab-assets/closing-the-information-gap/slackernews/support-bundle.yaml' /home/replicant/slackernews/templates/troubleshoot/support-bundle.yaml + +# add license check that we can re-use in multiple templates if needed +cat <